Ios 推送解析-启动选项在didFinishLaunchingWithOptions中为空
我知道这是一个已经回答过的问题 但是在阅读了很多信息之后,我的问题仍然存在 我使用parse发送了这个json推送:Ios 推送解析-启动选项在didFinishLaunchingWithOptions中为空,ios,push-notification,parse-platform,Ios,Push Notification,Parse Platform,我知道这是一个已经回答过的问题 但是在阅读了很多信息之后,我的问题仍然存在 我使用parse发送了这个json推送: {"aps" : { "alert" : "text msg", "badge" : 1, "sound" : "chime" }, "_3Y" : "0"} 如果应用处于活动状态,则一切正常,userInfo正确接收我的数据: - (void)application:(UIApplication *)application didReceiveRemoteNotificati
{"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。请提供解决方案。我使用launchOptions=nil来面对这个问题。