Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didFailToRegisterForRemoteNotificationsWithError: user refused error?

Tags:

ios

push

If the user refuses the enable push notifications, we'll get an error, through didFailToRegisterForRemoteNotificationsWithError. Does anybody know what the code in the NSError object will be in this case (to differentiate it from, say, no connection being available)?

like image 313
Colin Avatar asked Feb 08 '12 19:02

Colin


2 Answers

I don't think your initial statement (always) holds true. If an app is properly signed with a valid provisioning profile, calling registerForRemoteNotificationTypes: will result in application:didRegisterForRemoteNotificationsWithDeviceToken: regardless of the user's Notifications choices in the Settings app. From my experience, the only times I have seen application:didFailToRegisterForRemoteNotificationsWithError: get called was because of an improperly signed app. The error in question mentioned "no valid aps-environment entitlement found for application".

like image 147
Jerred Avatar answered Oct 09 '22 14:10

Jerred


Although this question is old, and agree with most of the @Jerred's answer, i thought of posting an updated answer anyway.

The answer to main question in the thread is NO.

application:didFailToRegisterForRemoteNotificationsWithError: gets called when the app is signed with incorrect provisioning profile.

Also,

application:didRegisterForRemoteNotificationsWithDeviceToken: gets called only when user enables at-least one of the badge, banner/alert or sound setting in the notification center (in Settings app) for your app.

There are scenarios where iOS will not call either of these methods

  • When user refuses to grant permissions for app to send push notifications
  • When there is no network connectivity and user granted permissions to send push notifications.
  • When user disables the push notifications for app from notification center in Settings app.
like image 31
apalvai Avatar answered Oct 09 '22 15:10

apalvai