我想区分应用是否响应RemoteNotification单击而变为Active。怎么做 ?

最佳答案

你可以这样检查

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
       NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
                if (notification) {

                // it's launch from notification


                }
                else
                {
                     // normal launch on app icon click
                }

    }


为了迅速请使用此

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

        if (launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? NSDictionary) != nil {

           // it's launch from notification
                   }
        else
        {
              // normal launch on app icon click
        }

        // Override point for customization after application launch.
        return true
    }

关于ios - 检查应用是否由于RemoteNotification而激活(应用已启动),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40506636/

10-10 20:36