Skip to content

[firebase-messaging] Token change callback is not triggered in android #16

@CatchABus

Description

@CatchABus

It seems that onToken callback is never called. I reinstalled app and deleted token but none of these seem to trigger it.

Sample:

var messaging = firebase().messaging();
// This is never called
messaging.onToken(function(token) {
  console.log(token);
});
messaging.showNotificationsWhenInForeground = true;

try {
  await messaging.deleteToken();
  let token = await messaging.getToken();
} catch(err) {
}

In order to confirm this, I also created my custom Service class and assigned it as a service into my app's manifest file.
The following class method was triggered on app start and token deletion.

package org.dnr;

public class FirebaseMessagingCustom extends com.google.firebase.messaging.FirebaseMessagingService {
	@Override
	public void onNewToken(String token) {
		System.err.println("Token: " + token);
		super.onNewToken(token);
	}
}

I wonder if the following service declaration is really working: https://github.com/NativeScript/firebase/blob/main/packages/firebase-messaging/src-native/android/messaging/src/main/AndroidManifest.xml#L10

Metadata

Metadata

Assignees

No one assigned

    Labels

    androidbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions