How to respond to push notification view if app is already running in the background

后端 未结 2 624
北恋
北恋 2020-12-04 07:42

I have something fairly simple I want to do. I attach a custom piece of data to some push notifications that I handle in

-(BOOL)application:(UIApplication *)         


        
2条回答
  •  盖世英雄少女心
    2020-12-04 08:14

    To detect if the app was activated by remote notication, try this:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
        if (userInfo == NULL)
        {
            NSLog(@"didFinishLaunchingWithOptions user startup userinfo: %@", userInfo);
        }
        else
        {
            NSLog(@"didFinishLaunchingWithOptions notification startup userinfo: %@", userInfo);
        }
    }
    

提交回复
热议问题