This repository was archived by the owner on Feb 7, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 45
This repository was archived by the owner on Feb 7, 2019. It is now read-only.
Should the samples call registerUserNotificationSettings() before register()? #210
Copy link
Copy link
Open
Labels
Description
In the README.md and in the demo app, it first calls pushPlugin.register() then calls pushPlugin.registerUserNotificationSettings(). It seems like this is the reverse of the example in the Configuring Remote Notification Support (in the Obtaining a Device Token in iOS and tvOS section) of the Apple Docs.
push-plugin/demo/app/main-view-model.ts
Lines 53 to 70 in a096afc
| onRegisterButtonTap() { | |
| let self = this; | |
| pushPlugin.register(this.pushSettings, (token: String) => { | |
| self.updateMessage("Device registered. Access token: " + token); | |
| // token displayed in console for easier copying and debugging durng development | |
| console.log("Device registered. Access token: " + token); | |
| if (pushPlugin.registerUserNotificationSettings) { | |
| pushPlugin.registerUserNotificationSettings(() => { | |
| self.updateMessage("Successfully registered for interactive push."); | |
| }, (err) => { | |
| self.updateMessage("Error registering for interactive push: " + JSON.stringify(err)); | |
| }); | |
| } | |
| }, (errorMessage: String) => { | |
| self.updateMessage(JSON.stringify(errorMessage)); | |
| }); | |
| } |
Apple Sample Code:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Configure the user interactions first.
self.configureUserInteractions()
// Register with APNs
UIApplication.shared.registerForRemoteNotifications()
}
It makes sense that you would want to setup the interactions first so that you don't run into a race condition trying to configure interactions before a notification comes in.
I'm totally new to mobile dev and just happened to be reading the Apple Docs to make sure I understood how this stuff works.