2014-09-24 59 views
3

iOS 8推送通知的新方法是什么?什么是iOS 8的推送通知方法?

我正在使用这种方法,但它不工作。

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound]; 

有人可以指导我吗?

回答

2

“无声”推送是不会创建用户界面的推送通知;他们会告诉您的应用程序获取或对在线可用的新内容做出反应。

在iOS 8中,Apple已分离出UI和推送的权限。推送权限也是默认自动接受的!这意味着您的iOS 8应用将能够更加可靠取决于接收无声的通知中的iOS 8

要迁移应用程序,更改下面的代码的能力:

// iOS的8前:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound]; 

//对于iOS 8:

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]; 

[[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 
[[UIApplication sharedApplication] registerForRemoteNotifications];