Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token-Changed Event Not Firing on iOS #64

Open
raphaelpreston opened this issue Mar 5, 2019 · 1 comment
Open

Token-Changed Event Not Firing on iOS #64

raphaelpreston opened this issue Mar 5, 2019 · 1 comment

Comments

@raphaelpreston
Copy link

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
@mpost
Copy link
Member

mpost commented Apr 10, 2019

We are looking into the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants