@Chonch說真話,但如果你想繼承人如何做到這一點:
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
{
//UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert) categories:nil];
//[application registerUserNotificationSettings:settings];
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil]];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
} else {
//register to receive notifications
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[application registerForRemoteNotificationTypes:myTypes];
}
然後你只需取消通知,如果您的用戶已註銷或者沒有登錄:)
。