Rav*_*jha 9 objective-c ios parse-platform ios8
我在我的项目中使用Parse SDK进行推送通知.我已经didFinishLaunchingWithOptions:在parse.com上添加了代码
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
Run Code Online (Sandbox Code Playgroud)
它的工作正常,如果设备或模拟器版本是iOS 8,但它在iOS 6.1中不起作用,并显示消息
[UIApplication registerUserNotificationSettings:]: unrecognized selector sent to instance 0x208406c0
谁能告诉我怎么解决呢?
SGD*_*Dev 29
在didFinishLaunchingWithOptions方法中使用此代码,它可以在ios 6和7中使用
[application registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
Run Code Online (Sandbox Code Playgroud)
如果您想在所有情况下使用ios 6,7,8,那么在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)];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6291 次 |
| 最近记录: |