Skip to content

Commit 45bfb6b

Browse files
committed
chore(messaging): add issues to demo
1 parent 489fd5b commit 45bfb6b

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed
Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
11
import { Observable, EventData, Page } from '@nativescript/core';
22
import { DemoSharedFirebaseMessaging } from '@demo/shared';
33
import { firebase } from '@nativescript/firebase-core';
4-
4+
import { AuthorizationStatus } from '@nativescript/firebase-messaging';
55
export function navigatingTo(args: EventData) {
66
const page = <Page>args.object;
77
page.bindingContext = new DemoModel();
88
}
99

1010
export class DemoModel extends DemoSharedFirebaseMessaging {
11-
constructor(){
11+
constructor() {
1212
super();
13-
firebase().messaging().getToken().then(token =>{
14-
console.log('getToken', token);
15-
}).catch(e =>{
16-
console.log('getToken', e);
17-
})
13+
14+
15+
// firebase().messaging().getToken().then(token =>{
16+
// console.log('getToken', token);
17+
// }).catch(e =>{
18+
// console.log('getToken', e);
19+
// })
20+
Promise.all([this.issue_16(), this.issue_17()]);
21+
}
22+
23+
async issue_16() {
24+
var messaging = firebase().messaging();
25+
// This is never called
26+
messaging.onToken(function (token) {
27+
console.log('onToken', token);
28+
});
29+
messaging.showNotificationsWhenInForeground = true;
30+
31+
try {
32+
await messaging.deleteToken();
33+
let token = await messaging.getToken();
34+
console.log('token', token);
35+
} catch (err) {
36+
}
37+
}
38+
39+
async issue_17() {
40+
var messaging = firebase().messaging();
41+
const status = await messaging.requestPermission({ ios: { alert: true } });
42+
console.log('status', status);
43+
console.log('status', status === AuthorizationStatus.AUTHORIZED)
1844
}
1945
}

0 commit comments

Comments
 (0)