2014-09-24 43 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];