Sie können diesen Code verwenden können:
if ([[UIApplication sharedApplication] respondsToSelector:@selector(currentUserNotificationSettings)]) {
UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
if (types == UIUserNotificationTypeNone) {
// Do something
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) {
// Do something
}
}
Oder diese, wenn Sie nur den Benutzer überprüfen wollen, für Remote-Benachrichtigungen registriert:
if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
BOOL isRegisteredForRemoteNotifications = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
if (isRegisteredForRemoteNotifications) {
// Do something
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) {
// Do something
}
}
was über dieses http: // Stackoverflow .com/questions/25111644/detect-allow-benachrichtigungen-is-on-off-for-ios8? –