如果它在前台运行,它会收到推送通知.
知道发生了什么事吗?
在CloudKit开发模式下运行,订阅用于添加,编辑和删除,并使用以下dIDReceiveRemoteNotification:
-(voID)application:(UIApplication *)application dIDReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(voID (^)(UIBackgroundFetchResult))completionHandler{ NSLog(@"Push received."); NSDictionary * apsDict = [userInfo objectForKey:@"aps"]; Nsstring * alertText = [apsDict objectForKey:@"alert"]; //Todo: get the record information from the notification and create the appropriate message string. if(application.applicationState == UIApplicationStateActive) { UIAlertVIEw * alert = [[UIAlertVIEw alloc] initWithTitle:@"Notification" message:alertText delegate:nil cancelbuttonTitle:@"Ok" otherbuttonTitles: nil]; [alert show]; } else { if([application currentUserNotificationSettings].types & UIUserNotificationTypeAlert) { UIlocalnotification * localnotification = [[UIlocalnotification alloc] init]; localnotification.alertbody = NSLocalizedString(@"alert body",nil);; localnotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:2]; [application presentlocalnotificationNow:localnotification]; } } completionHandler(UIBackgroundFetchResultNoData);}解决方法 当您转到应用程序设置功能时,是否为背景模式启用了远程通知?
看这个截图:
除此之外,您是否注册了所有类似的通知类型:
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Alert | .Badge | .sound,categorIEs: nil)) application.registerForRemoteNotifications()
在您的订阅中,您是否为CKNotificationInfo发送alertbody或alertLocalizationKey?如果您这样做,那么您将从 *** 作系统获得通知,而您无需设置本地通知.
更新:正如下面提到的Porton,填写alertbody解决了这个问题.
总结以上是内存溢出为你收集整理的ios8 – CloudKit推送通知,应用程序在后台运行全部内容,希望文章能够帮你解决ios8 – CloudKit推送通知,应用程序在后台运行所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)