This ends up in the catch block, with error being null.
if (this.platform.is('ios')) {
this.firebase.grantPermission().then(data => {
console.log(`*** FCM: grantPermission`, data);
}).catch(error => {
console.error('*** FCM: Error grantPermission', error);
});
}
I'm currently using version 1.0.5. Last known version to work is 0.1.25.
Anyone else struggling with this?
Hi, this is my example of code, this work with topics on Android and iOS
and work check permissions
_Function for coll after device ready_
private registrPushFn(): boolean {
if (!this.platform.is('cordova')) {
console.warn('Push notifications not initialized. Cordova is not available - Run in physical device');
return true;
}
if (this.platform.is('ios')) {
this.firebase.hasPermission().then(data => {
if (!data.isEnabled) {
this.firebase.grantPermission().then(data => {
return this.getTokenPush();
})
.catch(error => {
console.error('Error getting permissions', error);
return false;
});
} else {
return this.getTokenPush();
}
});
} else {
return this.getTokenPush();
}
}
_Function for Get tocken_
private getTokenPush() {
this.firebase.getToken()
.then(token => {
this.globalVars.userData.userServiceInfo.gmsToken = token;
}) // save the token server-side and use it to push notifications to this device
.catch(error => console.error('Error getting token', error));
this.firebase.onTokenRefresh()
.subscribe((token: string) => {
this.globalVars.userData.userServiceInfo.gmsToken = token;
});
// this.firebase.onNotificationOpen().subscribe(data => { });
this.setTopicPush();
return true;
}
_And function for subscribe to topic_ (Attention!!! for android good topic with /topics/blabla_bla-bla but for iOS must be without /topics/ example blabla_bla-bla)
private setTopicPush() {
let topic = "/topics/MyTopic-User_ENGLISH";
if (this.platform.is('ios')) {
topic = "MyTopic-User_ENGLISH"
}
this.firebase.subscribe(topic);
}
closing as resolved per the above comment
Most helpful comment
Hi, this is my example of code, this work with topics on Android and iOS
and work check permissions
_Function for coll after device ready_
_Function for Get tocken_
_And function for subscribe to topic_ (Attention!!! for android good topic with /topics/blabla_bla-bla but for iOS must be without /topics/ example blabla_bla-bla)