问题描述
我在项目中使用Parse SDK进行推送通知。我在 didFinishLaunchingWithOptions:
中添加了代码,如parse.com上所示
I am using the Parse SDK for push notification in my project. I have added the code in didFinishLaunchingWithOptions:
as given on the parse.com
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
工作正常,如果设备或模拟器版本是iOS 8,但它在iOS 6.1中不起作用,和消息出现
its working fine, if device or simulator version is iOS 8, but its not working in iOS 6.1 ,and message appear
[UIApplication registerUserNotificationSettings:]:无法识别的选择器发送到实例0x208406c0
任何人都可以告诉我如何解决它?
Can any one tell me how can i solve it?
推荐答案
在didFinishLaunchingWithOptions方法中使用此代码它适用于ios 6和7
use this code in didFinishLaunchingWithOptions method it is work in ios 6 and 7
[application registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
如果您想在所有情况下使用ios 6,7,8,那么在此处使用此代码didFinishLaunchingWithOptions
if you want to work in ios 6,7,8 in all cases then used this code inside a didFinishLaunchingWithOptions
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)];
}
这篇关于RegisterUserNotificationSettings在ios 6.1中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!