In a library that im using there is the method, getToken which is used in the example like:
getApplicationToken() {
window.FirebasePlugin.getToken(function(token) {
console.log('Got FCM token: ' + token);
}, function(error) {
console.log('Failed to get FCM token', error);
});
}
What I want is to create a method that returns the token itself. What I tried:
async getApplicationTokenString(): Promise<string> {
return window.FirebasePlugin.getToken();
}
And calling it by:
let firebaseToken = '';
this.fireBaseService.getApplicationTokenString().then(function(resolveOutput) {
firebaseToken = resolveOutput;
}, function(rejectOutput) {
console.log(rejectOutput);
});
However I get: Firebase token:
so I have no value.
However when I call getApplicationToken the fcm token is logged.
How should I pass the value given by a promise async?