mar*_*101 6 iphone xcode objective-c apple-push-notifications ios8
我得到了弹出窗口,我接受了,我在通知中看到它并且它已打开但是这段代码总是返回否,我似乎无法找出原因
UIApplication *application = [UIApplication sharedApplication];
BOOL enabled;
// Try to use the newer isRegisteredForRemoteNotifications otherwise use the enabledRemoteNotificationTypes.
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
enabled = [application isRegisteredForRemoteNotifications];
}
else
{
UIRemoteNotificationType types = [application enabledRemoteNotificationTypes];
enabled = types & UIRemoteNotificationTypeAlert;
}
if (enabled){
NSLog(@"is registered");
}else{
NSLog(@"is not registered");
}
Run Code Online (Sandbox Code Playgroud)
小智 1
我正在努力解决同样的问题,这对我有用。
BOOL enabled = NO;
UIUserNotificationSettings *notificationSettings = [SharedApplication currentUserNotificationSettings];
enabled = notificationSettings.types < 4;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5554 次 |
最近记录: |