Objective c IOS8推送通知
我正在尝试注册Ipad,以便在没有任何运气的情况下进行推送通知。我尝试了以下代码,但在IOS8上出现错误“RegisterForRemotionTificationTypes:在IOS8.0及更高版本中不受支持”。尽管它在IOS7上工作正常Objective c IOS8推送通知,objective-c,cordova,ios7,push-notification,ios8,Objective C,Cordova,Ios7,Push Notification,Ios8,我正在尝试注册Ipad,以便在没有任何运气的情况下进行推送通知。我尝试了以下代码,但在IOS8上出现错误“RegisterForRemotionTificationTypes:在IOS8.0及更高版本中不受支持”。尽管它在IOS7上工作正常 - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { CGRect screenBou
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
NSLog(@"+++++++++++++");
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
NSLog(@"============");
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
更好的方法:
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{
// iOS 8 Notifications
// use registerUserNotificationSettings
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
// iOS < 8 Notifications
// use registerForRemoteNotifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
}
if([[UIApplication sharedApplication]respondsToSelector:@selector(registerUserNotificationSettings:)]))
{
//iOS 8通知
//使用注册表通知设置
[[UIApplication sharedApplication]registerUserNotificationSettings:[UIUserNotificationSettings设置类型:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)类别:nil];
[[UIApplication sharedApplication]注册表项的删除];
}
其他的
{
//iOS<8通知
//使用注册表进行删除
[[UIApplication sharedApplication]RegisterForRemotionTificationType:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
}
我已经尝试过上述代码,但现在出现此错误2014-10-11 13:00:53.555测试应用[927:173651]iOS 8.0及更高版本不支持enabledRemoteNotificationTypes。