0

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 );
}

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Hovering
  • 73
  • 6
  • Did you get the google-service.json file and add it to your project ? For Android — Click Download google-services.json. You can download your Firebase Android config file again at any time. Note: The Firebase config file contains unique, but non-secret identifiers for your project. Visit Understand Firebase Projects to learn more about this config file. https://firebase.google.com/docs/unity/setup#register_unity_project – Qusai Azzam Apr 29 '19 at 15:39
  • Yes I did - as mentioned above, the same apk performs as expected on my Android phone, just not on the Vuzix Blade. I just cannot find out why or how to fix that. – Hovering Apr 29 '19 at 20:42
  • does the Vuzix Blade gets notifications ?!, if yes, you should set the minimum API Level to [Android 5.0 Lollipop]. – Qusai Azzam Apr 30 '19 at 05:52
  • I can successfully generate (local) notifications from an Android app on the Blade. For the Unity project, I have tried different minimum API levels between 16 (Jelly Bean) and 21 (Lollipop), all with identical results. The problem is that I don't even get an error message, or in fact any indication that something goes wrong, except for the fact that no token is received. I also know that a token is only generated on a mobile device (not, e.g., in the Unity Editor), which shows similar behavior, but I cannot imagine why the Blade as a normal Android device should behave that way. – Hovering Apr 30 '19 at 07:19

1 Answers1

0

Isn't the Blade a non CTS compliant device? This would not allow Firebase to work on it since the Firebase SDK requires a device to have Google Mobile Services (GMS) enabled in order to function.

Arnold
  • 1