【发布时间】:2014-11-13 08:59:32
【问题描述】:
我的问题似乎与this one 重复,但事实并非如此。当应用程序被杀死并且没有在后台运行时,如果我收到推送通知并单击通知横幅,它工作正常。 “userInfo”不为空,应用程序处理通知。 但是如果我关闭通知横幅并通过单击应用程序图标打开应用程序,则此“userInfo”返回 nil。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
NSDictionary* userInfo = [launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if(userInfo != nil){
//Handling notification
}
}
还有
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
if([application applicationState] == UIApplicationStateActive) {
NSLog(@"...1");
}else if([application applicationState] == UIApplicationStateInactive){
NSLog(@"...2");
}else if([application applicationState] == UIApplicationStateBackground){
NSLog(@"...2");
}
completionHandler(UIBackgroundFetchResultNoData);
}
有没有办法处理这些通知,还是我应该自己处理?
【问题讨论】:
标签: ios objective-c notifications apple-push-notifications