// Add registration for remote notificationsif ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { NSLog(@"iOS 8 Registering for remote notification"); UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categorIEs:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings]; [[UIApplication sharedApplication] registerForRemoteNotifications];} else { NSLog(@"Registering for remote notification"); [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];}
此代码适用于运行iOS 8的手机,而不适用于iOS 7.
另外一点信息我们设法通过连接手机的xcode运行应用程序后,推送通知才能在iOS 7手机上运行.然后,我们将与广告Hoc部署相同的代码部署到运行iOS 7的另一部iPhone和iPad,但两者均无效.
有什么明显的东西我在这里失踪了.
-(BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions{if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]){// iOS 8 Notifications[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categorIEs:nil]];[application registerForRemoteNotifications];}else{// iOS < 8 Notifications[application registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];}return YES;}总结
以上是内存溢出为你收集整理的registerForRemoteNotificationTypes不能正常工作iOS7 xcode 6全部内容,希望文章能够帮你解决registerForRemoteNotificationTypes不能正常工作iOS7 xcode 6所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)