I have made the Firebase Cloud Message Notification working even work through the Notification Hub from Azure. The time I can't receive the message is when I try to re-run the application.
Process:
1) Fresh install the application with Visual Studio IDE
2) Stop the debugger
3) Debug and run the application again through Visual Studio IDE
4) Send a test message through FCM Console
If I am not doing 3, I still can receive the message even if the application is in background
LoadApplication(new App());
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);
?
public class MyFirebaseInstanceIdService : FirebaseInstanceIdService
{
const string TAG = "MyFirebaseInstanceIdService";
public override void OnTokenRefresh()
{
var refreshedToken = FirebaseInstanceId.Instance.Token;
Settings.NotificationToken = refreshedToken;
Android.Util.Log.Debug(TAG, "Refreshed token: " + refreshedToken);
SendRegistrationToServer(refreshedToken);
}
void SendRegistrationToServer(string token)
{
}
}
Initially I thought it has a different token but is the same.
Message from Azure Portal:
The token obtained from the token provider is wrong.