isRegisteredForRemoteNotifications always returns no

apple registerforremotenotifications
registerforremotenotifications swift
uiapplication registerforremotenotifications must be used from main thread only
didregisterforremotenotificationswithdevicetoken called multiple times
uiapplication delegate
didregisterforremotenotificationswithdevicetoken ios 13
didregisterforremotenotificationswithdevicetoken not called swift 4
apns device token

I got the pop up, i have accepted, i see it in the notifications and it is turned on but this code always returns no and i cant seem to find out why

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");
}

I think what makes it happen might be:

  1. isRegisteredForRemoteNotifications will always return NO in simulators.
  2. registerForRemoteNotifications fails.

isRegisteredForRemoteNotifications returns true even though I , As per the Apple documentation isRegisteredForRemoteNotifications will return NO if registration has not occurred, has failed, or has been denied by the user. YES will be returned if the app has registered for remote notifications and has received is device token. So we have a notification screen where users can customize the push notifications they want to receive. In this view controller, we check if [application isRegisteredForRemoteNotifications], we allow users to use the screen, else we show them the prompt that deep links to settings for the app. Now, what's happing is that certain users are complaining that this prompt never disappears even when they turn on in settings.

I was struggling with the same problem, this worked for me.

BOOL enabled = NO;
UIUserNotificationSettings *notificationSettings = [SharedApplication currentUserNotificationSettings];
enabled = notificationSettings.types < 4;

isRegisteredForRemoteNotifications returns TRUE |Apple , It looks like the behavior of isRegisteredForRemoteNotifications API provided by apple has regressed in iOS 9. This API always remained in sync with the system settings. Did you get any response from apple support. Now, I know that in iOS 8 isRegisteredForRemoteNotifications DOES return true after an uninstall and reinstall, as long as the app is reinstalled within 24 hours. This happens because the system settings (under Settings->Notifications) are retained for an app within that 24 hour period.

As per the Apple documentation isRegisteredForRemoteNotifications will return NO if registration has not occurred, has failed, or has been denied by the user. YES will be returned if the app has registered for remote notifications and has received is device token. So in answer to your question NO it will not always return no it will also return yes if a your app has registered for remote notifications and it has received it device token.

Checkout the Apple Documentation for a better description

Return Value

YES if the app is registered for remote notifications and received its device token or NO if registration has not occurred, has failed, or has been denied by the user.

Discussion

This method reflects only the successful completion of the remote registration process that begins when you call the registerForRemoteNotifications method. This method does not reflect whether remote notifications are actually available due to connectivity issues. The value returned by this method takes into account the user’s preferences for receiving remote notifications.

isRegisteredForRemoteNotifications, isRegisteredForRemoteNotifications. A Boolean indicating whether the app is currently registered for remote notifications. SDKs. iOS 8.0+; Mac Catalyst 13.0+  This method reflects whether the remote registration process completed successfully—a process that begins when you call the register For Remote Notifications() method. This method does not reflect whether remote notifications are actually available due to connectivity issues.

I think the simulator will always return no, try running your code on a real device and see if the behavior continues

Background refresh and Pushnotifications , isRegisteredForRemoteNotifications] always returns true when his token is not available No Push Token (uninstalled app for exemple),  As per the Apple documentation isRegisteredForRemoteNotifications will return NO if registration has not occurred, has failed, or has been denied by the user. YES will be returned if the app has registered for remote notifications and has received is device token.

After iOS10 and to make it work both on the simulator and on a real device you should use something like this:

[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
     if (settings.alertStyle == UNAlertStyleNone)
         NSLog(@"ACCESS DENIED!");
     else
         NSLog(@"ACCESS GRANTED!");
 }];

If you are NOT planning to test on the simulator you may use the code below (unfortunately this will always return NO on the simulator):

[[UIApplication sharedApplication] isRegisteredForRemoteNotifications];

Do NOT use the code below if you are planning to compile for iOS 10 or iOS11 because it has been deprecated on iOS10:

[SharedApplication currentUserNotificationSettings];

How to check if push notification is actually enabled in iOS, I got the pop up, i have accepted, i see it in the notifications and it is turned on but this code always returns no and i cant seem to find out why  firebase token is null #63. Closed Firebase.InstanceID.InstanceId.SharedInstance.Token method always returns nil. If I don’t get that token, I can’t send

ios, isRegisteredForRemoteNotifications is that your app has connected currentUserNotificationSettings is for user permissions, without this, there is no alert, banner or sound push notification delivered to the app currentUserNotificationSettings else { return false } return iOS 13: launchOptions always nil? For urgent returns, you may return your items via contactless curbside return at select DICK'S Sporting Goods locations with a receipt or order number. At this time, we can only accept curbside returns for purchases that were made with a debit or credit card (no cash or gift cards).

`isRegisteredForRemoteNotifications` returns false first time I query , as per apple documentation isregisteredforremotenotifications return no if registration has not occurred, has failed, or has been denied user. windows 10 file explorer search always returns 'no items match your search' even with a file titled 'how to.docx' in the current folder, search fails to find it. I even tried extension:pdf and got nothing.

ios, If I check isRegisteredForRemoteNotifications it always returns no before the first registerForRemoteNotifications is called so that is not an option. I could call  Error: This condition will always return 'false' since the types 'A' and 'I' have no overlap. TypeScript Version: 2.9.2. Error: Operator '===' cannot be applied to types 'A' and 'I'. Search Terms: Operator '===' cannot be applied to types. This condition will always return 'false' since the types have no overlap.

Comments
  • When you register for notifications is UIRemoteNotificationTypeAlert one of the types you register for?
  • #define SharedApplication [UIApplication sharedApplication]
  • This has a huge chance of actually lying to you. If you haven't registered for remote notifications you could still have the notification settings setup so this could return true when in fact it is false. You should be relying on the returned value in isRegisteredForRemoteNotifications and if this is returning NO this means something has gone wrong with your registration for remote notifications.
  • notificationSettings.types > 0 is a better approach. 7 means banner, sound and alert are enabled, but it will return false because of 7 > 4