When I call the method window.cordova.plugins.firebase.messaging.getToken() I get null.
And not entirely sure what I'm doing wrong, what I've read I should just call it and get a token.
And when I looked at the Java file and compare it with the older versions I can't really understand what went wrong.
I fixed it by doing like this:
@CordovaMethod
private void getToken(String type, final CallbackContext callbackContext) {
// type can still be null, so if we call type.isEmpty() and is null it will crash.
if (type != null && type.isEmpty()) {
callbackContext.sendPluginResult(
new PluginResult(PluginResult.Status.OK, (String)null));
} else {
firebaseMessaging.getToken().addOnCompleteListener(cordova.getActivity(), task -> {
if (task.isSuccessful()) {
callbackContext.success(task.getResult());
} else {
callbackContext.error(task.getException().getMessage());
}
});
}
}
But if there is another solution I wouldn't mind getting a answer. Since I rather just not mess with the source unless I really need to.
When I call the method
window.cordova.plugins.firebase.messaging.getToken()
I get null.And not entirely sure what I'm doing wrong, what I've read I should just call it and get a token. And when I looked at the Java file and compare it with the older versions I can't really understand what went wrong.
I fixed it by doing like this:
But if there is another solution I wouldn't mind getting a answer. Since I rather just not mess with the source unless I really need to.