Cloud Messaging
1、清单文件配置
a、(可选)一项扩展 FirebaseMessagingService
的服务。除了接收通知外,如果您还希望在后台应用中进行消息处理,则必须添加此服务。例如,您需要在前台应用中接收通知、接收数据载荷以及发送上行消息等,就必须扩展此服务
<service
android:name=".java.MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
b、(可选)应用组件中用于设置默认通知图标和颜色的元数据元素。如果传入的消息未明确设置图标和颜色,Android 就会使用这些值。
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_ic_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"