简体   繁体   中英

Push Parse - launchOptions is null in didFinishLaunchingWithOptions

I know that this is a question already answered.

but after reading a lot of messages my problem is still here.

Using parse i sent this json push:

{"aps" : { "alert" : "text msg", "badge" : 1, "sound" : "chime" }, "_3Y" : "0"}

If app is active, then is all right, userInfo receive my data correctly:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[PFPush handlePush:userInfo];
...
}

If the app is idle, the badge and the text notification appears but:

If I click on the text on notification bar, the app starts and I receive the push

If I click on the badge, the app starts but launchOptions in didFinishLaunchingWithOptions is null!

This is my test code for didFinishLaunchingWithOptions method:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];

    NSDictionary *aPushNotification = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
//    NSDictionary* aPushNotification = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];

    NSString *test = [aPushNotification objectForKey:@"_3Y"];

    [[[UIAlertView alloc] initWithTitle:test message:[aPushNotification description] delegate:NULL cancelButtonTitle:NSLocalizedString(@"LOC018", @"Ok") otherButtonTitles:nil, nil] show];
...
}

Maybe is a Parse problem ?

Any help would be appreciated..

Thanks in advance!!

仅当通过通知启动应用程序时才设置launchOptions,如果通过图标上的徽章启动应用程序,则启动时不带参数,launchOptions = nil。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM