I'm trying to get Firebase to run in a Unity project on a Vuzix Blade in order to receive Push notifications there. However, the OnTokenReceived
callback is never called, so I don't get any token to address push notifications to.
The Vuzix Blade runs on Android 5, and I have installed the Google Play Services and the Google Play Store, as they are not installed by default, but needed by Firebase. Firebase seems to start normally, or at least I don't get any error messages on logcat, and CheckAndFixDependenciesAsync()
correctly finishes with Firebase.DependencyStatus.Available
.
The same apk runs fine on my Android phone (OnePlus 5), where I get a token and can receive notifications both while the app is running and in the background.
I'm using Unity 2018.3 and the Firebase SDK 5.7.0 (the result is the same with 5.6.0, though).
private void Awake()
{
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(
task =>
{
var dependencyStatus = task.Result;
if ( dependencyStatus == Firebase.DependencyStatus.Available ) // this is always true
{
// Create and hold a reference to your FirebaseApp,
// where app is a Firebase.FirebaseApp property of your application class.
m_kFirebaseApp = Firebase.FirebaseApp.DefaultInstance;
// Set a flag here to indicate whether Firebase is ready to use by your app.
Firebase.Messaging.FirebaseMessaging.TokenRegistrationOnInitEnabled = true;
Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
}
else
{
Debug.LogError(string.Format("Could not resolve all Firebase dependencies: {0}", dependencyStatus ) );
// Firebase Unity SDK is not safe to use here.
}
} );
}
// This never gets called!
public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token )
{
m_kToken = token.Token;
Debug.Log( "Received Registration Token: " + token.Token );
}