Skip to content
This repository was archived by the owner on Feb 7, 2019. It is now read-only.
This repository was archived by the owner on Feb 7, 2019. It is now read-only.

Should the samples call registerUserNotificationSettings() before register()? #210

Open

Description

@joeizy

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.

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.

Activity

  1. zbranzov commented on Apr 13, 2018

    @zbranzov
    Contributor

    We haven't noticed the Apple suggested approach and we might reconsider it. Thanks for pointing out this. In the meantime do you observe any issues that current implementation causes?

  2. joeizy commented on Apr 13, 2018

    @joeizy
    Author

    No issues observed. Seems to work great. Haven’t tested on Android but I don’t think this affect that platform. Thanks for the plug-in!

    Considering the type of problem, I believe the only consequence would be that if a message arrives before the the interactions are registered, that message just wouldn’t have all the bells and whistles it normally would. I didn’t test this so don’t take my word. If my understanding is correct, it’s a super fringe case but wanted to bring it up just in case I’m wrong and it’s a big deal.

  3. zbranzov commented on Apr 13, 2018

    @zbranzov
    Contributor

    @joeizy
    We will be very happy if you contribute to the plugin by implementing the invocation order suggested by Apple. We encourage the community to model the plugins by providing changes so they become better and stabler.

  4. joeizy commented on Apr 13, 2018

    @joeizy
    Author

    Sure, I’ll take a stab at it. I think this change will be breaking though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions