Iphone 如何检查应用程序是否已注册远程通知?
我尝试在方法中注册远程通知Iphone 如何检查应用程序是否已注册远程通知?,iphone,ios,xcode,push-notification,apple-push-notifications,Iphone,Ios,Xcode,Push Notification,Apple Push Notifications,我尝试在方法中注册远程通知 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 因此,每次启动应用程序时,它都会要求远程注册。依我看不应该是这样。如果该应用程序已注册或未注册,则应显示 但是我没有找到任何方法来检查这个想法 我的想法是对的还是有其他出路?试试这个: +(BOOL)isHaveRegistrationForNotif
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
因此,每次启动应用程序时,它都会要求远程注册。依我看不应该是这样。如果该应用程序已注册或未注册,则应显示
但是我没有找到任何方法来检查这个想法
我的想法是对的还是有其他出路?试试这个:
+(BOOL)isHaveRegistrationForNotification{
//For ios >= 8.0
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
return [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
//For ios < 8
else{
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
BOOL deviceEnabled = !(types == UIRemoteNotificationTypeNone);
return deviceEnabled;
}
}
+(BOOL)iShareRegistrationforNotification{
//对于ios>=8.0
如果([[[UIDevice currentDevice]systemVersion]floatValue]>=8.0)
返回[[UIApplication sharedApplication]isRegisteredForRemoteNotifications];
//对于ios<8
否则{
UIRemoteNotificationType=[[UIApplication sharedApplication]EnabledRemoteNotificationType];
布尔设备启用=!(类型==UIRemoteNotificationTypeNone);
返回设备已启用;
}
}
试试这个:
+(BOOL)isHaveRegistrationForNotification{
//For ios >= 8.0
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
return [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
//For ios < 8
else{
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
BOOL deviceEnabled = !(types == UIRemoteNotificationTypeNone);
return deviceEnabled;
}
}
+(BOOL)iShareRegistrationforNotification{
//对于ios>=8.0
如果([[[UIDevice currentDevice]systemVersion]floatValue]>=8.0)
返回[[UIApplication sharedApplication]isRegisteredForRemoteNotifications];
//对于ios<8
否则{
UIRemoteNotificationType=[[UIApplication sharedApplication]EnabledRemoteNotificationType];
布尔设备启用=!(类型==UIRemoteNotificationTypeNone);
返回设备已启用;
}
}
请遵循URL,这可能会有所帮助:这是否意味着,无需检查是否已注册,您只需在每次应用启动时为其注册???请遵循URL,这可能会有所帮助:这是否意味着,无需检查是否已注册,您只需在每次应用启动时为其注册???