I'm running an Ionic App with Angular. I'm using the Diagnostic plug-in of Ionic, but one of the method I use doesn't work with the Diagnostic plugin, so I'm using cordova.plugins.diagnostic.
https://ionicframework.com/docs/native/diagnostic
https://github.com/dpa99c/cordova-diagnostic-plugin
My code is like this :
onClickEnable() {
cordova.plugins.diagnostic.requestRemoteNotificationsAuthorization({
successCallback() {
console.log('Successfully requested remote notifications authorization');
// HERE I WOULD LIKE TO DO A THIS.ROUTER.NAVIGATE(['/page']);
},
errorCallback(err) {
console.error('Error requesting remote notifications authorization: ' + err);
},
types: [
// some value
],
omitRegistration: false,
});
}
When I run the app, my pop-up shows, and I get the console.log
But what I want is that after the user checked an option on the pop-up, it navigates to another page.
So I'm trying to put a this.router.navigate(['/page]);
inside the success Callback, but it doesn't work.
EDIT : Like this, doesn't work
onClickEnable() {
cordova.plugins.diagnostic.requestRemoteNotificationsAuthorization({
successCallback: () => {
console.log('Successfully requested remote notifications authorization');
this.router.navigate(['/page']);
},
errorCallback: (err) => {
console.error('Error requesting remote notifications authorization: ' + err);
}
I know I'm using it the wrong way. Can someone explain me how to do this? I also tried to put a .then()...
after the method, but it doesn't work.
And if I call the router.navigate
after the end of the requestRemoteNotificationsAuthorization
method, it navigates to the page, even if the user did not touch the pop-up.