Skip to content

Token-Changed Event Not Firing on iOS #64

@raphaelpreston

Description

@raphaelpreston

Problem description

After further testing with #63, I've found what seems to be a similar bug that also occurs on iOS. I'm trying to add a welcome message that will inform the user that they will be requested to allow push notifications, and then prompt them to enable AFTER they close that alert message. But, with that message added, the on-change event for the token isn't fired, just as with #63 on Android.

/* see existing token */
console.warn("Existing token: " + firebase.Messaging.token);

let i = 1;
setInterval(() => {
  console.warn("token check " + (i++) + ": " + firebase.Messaging.token);
}, 1000);

/* add on-change event for token */
firebase.Messaging.on('tokenChanged', ({token}) => {
  console.warn("Got updated Firebase token: " + token);
});

/* welcome messsage */
new AlertDialog({
  title: "Welcome!",
  message: "Thanks for downloading My App! Make sure to enable notifications when prompted!",
  buttons: {
    ok: 'OK'
  }
})
.on('close', () => { // ask for permissions (only launches when it needs to)
  if (device.platform == 'iOS') firebase.Messaging.requestPermissions();
})
.open();

Output:

> Existing token: undefined
> token check 1: undefined
> token check 2: <token>
> token check 3: <token>
...

As you can see, the token is indeed changing, but the event isn't firing.

Expected Behavior

Without the dialog, everything works as intended:

/* see existing token */
console.warn("Existing token: " + firebase.Messaging.token);

let i = 1;
setInterval(() => {
  console.warn("token check " + (i++) + ": " + firebase.Messaging.token);
}, 1000);

/* add on-change event for token */
firebase.Messaging.on('tokenChanged', ({token}) => {
  console.warn("Got updated Firebase token: " + token);
});

/* prompt */
if (device.platform == 'iOS') firebase.Messaging.requestPermissions();

Output:

> Existing token: undefined
> token check 1: undefined
> Got updated Firebase token: <token> <!-- expected behavior -->
> token check 2: <token>
> token check 3: <token>

Environment

  • Tabris.js version: 3.0.0-beta2
  • Device: iPhone 7
  • OS: iOS 11.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions