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)?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
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
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 inapplication:didRegisterForRemoteNotificationsWithDeviceToken:
regardless of the user's Notifications choices in the Settings app. From my experience, the only times I have seenapplication:didFailToRegisterForRemoteNotificationsWithError:
get called was because of an improperly signed app. The error in question mentioned "no valid aps-environment entitlement found for application".To my experience,
didFailToRegisterForRemoteNotificationsWithError:
method is reserved for more serious cases which prevents the app from even showing the notification permission request dialog to the user. The cases that I know of include the app being run on devices that do not support push notifications, (e.g. Simulator) or some misconfiguration in the aps-environment entitlement in the app binary.For me there was 2 files that held the entitlements, here I added Aps-enviroment : production and it worked after