0
我正在構建的IOS應用程序使用推送通知。蘋果要求你詢問用戶它們是否想要這個與否,他們第一次運行該應用程序:在設置控制器中啓用/禁用通知
if([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
但是,用戶可以使用該應用程序的過程中改變他/她的想法和切換通知或通過使用UISwitch在設置控制器中關閉。
如何捕獲當前通知值並從通知中註冊/取消註冊用戶? 這是我在互聯網上找到,但似乎並沒有工作:
[[UIApplication sharedApplication] registerForRemoteNotifications];
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
[[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
看看這個主題:http://stackoverflow.com/questions/1535403/determine-on-iphone-if-user-has-enabled-push-notifications – 2014-09-29 14:00:43