Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何检查应用程序是否已注册远程通知?_Iphone_Ios_Xcode_Push Notification_Apple Push Notifications - Fatal编程技术网

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,这可能会有所帮助:这是否意味着,无需检查是否已注册,您只需在每次应用启动时为其注册???