Firebase消息传递服务可以为android:exported ="false"吗? [英] Can firebase messaging services can be android:exported="false"?
问题描述
就像确认我们是否可以为实例ID服务和消息传递服务设置 android:exported ="false"
一样.
Like to confirm if we can set android:exported="false"
for instance id service and messaging service.
我通过保持 android:exported ="false"
进行测试,并且通知运行正常.
I tested by keeping android:exported="false"
and notifications are working fine.
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service
android:name=".MyFirebaseInstanceIDService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
推荐答案
firebase消息库以低优先级(-500)导出自己的未专门化的 FirebaseMessagingService
.您可以在合并的AndroidManifest.xml中看到它.此服务可以处理带有通知的推送消息,例如可以通过Firebase控制台发送的推送消息.
The firebase-messaging library exports an unspecialized FirebaseMessagingService
of its own with low priority (-500). You can see it in your merged AndroidManifest.xml. This service can handle the push messages that carry notifications, like the ones you can send through the Firebase console.
如果未导出您的专业服务类,则系统会将邮件从Google服务包路由到该非专业服务,并且通知会正常工作.
If your specialized service class isn't exported, then the system will route messages from the Google services package to this unspecialized service, and notifications will work fine.
但这意味着,例如,当您收到消息或处理自定义数据有效载荷时,您将无法执行其他操作.
But that means you wouldn't be able to, for example, perform other actions when receiving a message or process custom data payloads.
这篇关于Firebase消息传递服务可以为android:exported ="false"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!