Xamarin Android: Receiving Firebase Notification Token

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Xamarin Android: Receiving Firebase Notification Token



I can receive refresh token from onRefreshToken when the application first installed. When I recompiled and run the application without removing the application (eg. Update), the application no longer receives the notification from Azure Notification Hub. I suspected the token was changed but onRefreshToken was not called.


if (FirebaseApp.GetInstance(FirebaseApp.DefaultAppName) == null)

FirebaseOptions options = new FirebaseOptions.Builder()
.SetApplicationId(GetString(Resource.String.fcmAppId))
.SetApiKey(GetString(Resource.String.fcmApiKey))
.SetGcmSenderId(GetString(Resource.String.fcmGCMSenderId))
.Build();

FirebaseApp.InitializeApp(Android.App.Application.Context, options);



[Service]
[IntentFilter(new "com.google.firebase.INSTANCE_ID_EVENT" )]
public class MyFirebaseInstanceIdService : FirebaseInstanceIdService
{
const string TAG = "MyFirebaseInstanceIdService";

public override void OnTokenRefresh()

var refreshedToken = FirebaseInstanceId.Instance.Token;
Settings.NotificationToken = refreshedToken;
Settings.HasInstalledWithNH = false;
Android.Util.Log.Debug(TAG, "Refreshed token: " + refreshedToken);
SendRegistrationToServer(refreshedToken);




1 Answer
1



I need to call FirebaseInstanceId.Instance and delete the token so the app can receive a new one.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard