繁体   English   中英

推送解析-didFinishLaunchingWithOptions中的launchOptions为null

[英]Push Parse - launchOptions is null in didFinishLaunchingWithOptions

我知道这是一个已经回答的问题。

但是在阅读了大量邮件后,我的问题仍然存在。

使用解析,我发送了这个json推送:

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

如果应用程序处于活动状态,那么可以,userInfo可以正确接收我的数据:

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

如果应用程序处于空闲状态,则会显示徽章和文本通知,但:

如果我单击通知栏上的文本,则该应用程序启动并收到推送

如果单击徽章,该应用程序将启动,但didFinishLaunchingWithOptions中的launchOptions为空!

这是我对didFinishLaunchingWithOptions方法的测试代码:

- (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];
...
}

也许是解析问题?

任何帮助,将不胜感激..

提前致谢!!

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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