eclipsesource / eclipsesource/tabris-plugin-firebase

Token-Changed Event Not Firing on iOS

Open
#64 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
6
Forks
5
PR merge metrics
No merged PRs in 30d

Description

### 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.

```javascript
/* 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:
```html
> Existing token: undefined
> token check 1: undefined
> token check 2:
> token check 3:
...
```
As you can see, the token is indeed changing, but the event isn't firing.

### Expected Behavior
Without the dialog, everything works as intended:

```javascript
/* 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:
```html
> Existing token: undefined
> token check 1: undefined
> Got updated Firebase token:
> token check 2:
> token check 3:
```

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.