根据推送通知显示不同的视图控制器

时间:2018-06-23 04:10:07

标签: ios iphone swift swift3 ios10

如何在应用程序启动时根据是否启用推送通知来显示2个视图控制器之间的差异?我有以下代码,但是在启动小故事板后屏幕变黑了一段时间,而且速度太慢。

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
    {

        let current =  UNUserNotificationCenter.current();

        current.getNotificationSettings(completionHandler:
        {
            (settings) in

            if settings.authorizationStatus == .notDetermined
            {
                // self.window = UIWindow(frame: UIScreen.main.bounds);
                self.window = UIWindow(frame: UIScreen.main.bounds)

                let aViewController = AViewController();

                self.window?.rootViewController = aViewController;

                self.window?.makeKeyAndVisible();
            }
            else
            {
                // self.window = UIWindow(frame: UIScreen.main.bounds);
                self.window = UIWindow(frame: UIScreen.main.bounds)

                let bViewController = BViewController();

                self.window?.rootViewController = bViewController;

                self.window?.makeKeyAndVisible();
            }
        });

        // Override point for customization after application launch.

        return true
    }

我可以将此代码放在其他地方吗?等待时可以扩展启动屏幕吗?谢谢。

0 个答案:

没有答案