首先,我已将 FirebaseAnalytics 添加到我的 Android Unity 项目中,并且在测试中运行良好。然后,当我添加 FirebaseMessaging 并构建应用程序并从 FireBase 面板发送消息时,该消息将不会显示在设备/模拟器上,并且我在 Logcat 中收到此错误:
E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
1722-4448/system_process W/ActivityManager: Unable to start service Intent { act=com.google.firebase.MESSAGING_EVENT pkg=pack_name (has extras) } U=0: not found
E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
有一个主题here没有具体的问题答案。
我关注了 FireBase walkthrough将 FirebaseMessaging.unitypackage 添加到我的项目中,并据此将这些行添加到我的 list 中:
<!-- The MessagingUnityPlayerActivity is a class that extends
UnityPlayerActivity to work around a known issue when receiving
notification data payloads in the background. -->
<activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<service android:name="com.google.firebase.messaging.MessageForwardingService" android:exported="false" />
附注:
在 @jeevashankar 答案中添加提到的服务到我的 list 后,当通知到达时,我收到此错误:
E/BufferQueueProducer: [SurfaceView - pack_name/com.google.firebase.MessagingUnityPlayerActivity#0] query: BufferQueue has been abandoned [SurfaceView - /com.google.firebase.MessagingUnityPlayerActivity#0] connect: BufferQueue has been abandoned E/BufferQueueProducer: [SurfaceView - pack_name/com.google.firebase.MessagingUnityPlayerActivity#0]
更新: 我在一个空的 Unity 项目中测试了 FirebaseMessaging,并在模拟器/设备上进行了测试,它一直工作到 Android 7.1.1。但在 Android 8 (API 26) 及更高版本中会出现此错误并且不会收到消息:
system_process E/NotificationService: No Channel found for pkg=, channelId=null, id=0, tag=campaign_collapse_key_4015583716848879920, opPkg=, callingUid=10122, userId=0, incomingUserId=0, notificationUid=10122, notification=Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x10 color=0x00000000 vis=PRIVATE)
最佳答案
我也遇到了同样的问题:
E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found
过了一段时间,我通过在 list 中导出服务找到了解决方案
<service
android:name=".MyMessagingService"
android:exported="true"
tools:ignore="ExportedService" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
关于android - E/FirebaseInstanceId : Error while delivering the message: ServiceIntent not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54531674/