1
我看到this question,但不明白是否有明確的答案。我如何知道用戶是否允許推送通知
如果用戶通過設置標誌,按下「不允許」的第二次發射的應用程序,我可以告訴:
BOOL didRequest = [[NSUserDefaults standardUserDefaults] boolForKey:@"DidRequestPushNotifications"];
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone && didRequest)
{
[self showAlertToUserToEnableRemoteNotificationsOnDeviceInSettings];
}
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"DidRequestPushNotifications"];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
但對於首批推出的應用程序 - 成功的兩個委託方法失敗並沒有被調用,這意味着沒有辦法知道肯定。
任何解決方法?