我试图让firebase在Vuzix刀片上的Unity项目中运行,以便在那里接收推送通知。但是,OnTokenReceived
回调从未被调用,因此我没有任何代币来解决推送通知。
Vuzix Blade在Android 5上运行,我已经安装了Google Play服务和Google Play商店,因为它们默认不安装,而是Firebase需要的。Firebase似乎正常启动,或者至少我在LogCat上没有任何错误消息,并且CheckAndFixDependenciesAsync()
用Firebase.DependencyStatus.Available
正确完成。
相同的APK在我的Android手机(OnePlus 5(上运行良好,在该手机上我获得了一个令牌,并且在应用程序运行和后台可以接收通知。
我正在使用Unity 2018.3和Firebase SDK 5.7.0(尽管结果为5.6.0,但结果相同(。
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 );
}
刀片不是不符合CTS的设备吗?由于Firebase SDK需要设备以启用Google Mobile Services(GMS(以进行功能,因此这不允许Firebase进行操作。