android - android fcm主题订阅者停止接收通知
问题描述
突然,android 设备停止从服务器接收有关已订阅其工作几天的主题的通知,然后在每次安装后停止,但是当从控制台发送到相同的主题时,它已交付。
我的清单
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="com.myapp.channelId" />
<service
android:name=".firebase.MyFirebaseMessagingService"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
渠道
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationChannel androidChannel = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
androidChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
AudioAttributes audioAttributes =new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.build();
androidChannel.setSound(Uri.parse("android.resources://" + getPackageName() + "/" + R.raw.silence),audioAttributes);
androidChannel.enableLights(true);
androidChannel.setLightColor(Color.RED);
androidChannel.enableVibration(true);
mNotificationManager.createNotificationChannel(androidChannel);
}
我们的 bakend 使用传统的 http Legacy HTTP:https ://fcm.googleapis.com/fcm/send
有了这个 json
{
"condition": "'A' in topics && 'B' in topics" ,
"time_to_live": 3600,
"priority": "high",
"android": {
"priority": "high"
},
"notification": {
"body" : "body",
"title" : "title"
},
"data": {
"id" : "123
}
}";
我们通过从控制台发送主题来确保用户仍然订阅主题,并且它运行良好。
解决方案
推荐阅读
- wpf - 使用 gridSplitter 调整 gridview 单元格宽度
- java - Getting unwanted characters when reading command output from SSH server using JSch
- c++ - 指针转换:指针是否有价值?
- mysql - I get the following error when import CSV to a table in Heidi SQL "SQL Error: Data truncated for column 'SlNo' at row 1"
- reactjs - 编辑要显示的内容时,ract-native 应用程序未更新
- javascript - 如何为每篇文章应用jquery函数
- angularjs - 无法在 chrome 上运行 Protractor 测试用例
- mysql - 从未知数量的带有参数的表中选择
- excel - 引用 .vb 文件中的 VBA 代码(使用 UiPath Invoke VBA 活动)
- angular - 我们如何在Angular 6的多个选择列表中动态选择一些选项