我使用FirebaseMessagingService处理传入的通知.当我的应用程序处于前台和后台时,消息将到达.当我滑出应用程序时,通知即将到达.但是,如果我重新启动设备,则直到运行我的应用程序时才会收到通知.以同样的方式,Telegram和WhatsApp在重新启动后继续接收通知.我已经实现了onNewToken()方法,并添加了将新令牌发送到服务器的逻辑,但这并没有帮助.重新启动后如何继续接收通知?
I use the FirebaseMessagingService to handle incoming notifications. When my app is in the foreground and background the messages are being arrived. When I swipe-out the app, notifications are being arrived. But if I restart my device, notifications are not being arrived until I run my app. In the same way, Telegram and WhatsApp continue receiving notifications after reboot. I have implemented the onNewToken() method and have added logic to send new token to the server but it hasn't helped. How can I continue receiving notification after reboot?
推荐答案实际上,如果要在重新启动后启动服务,则必须添加意图过滤器操作.尝试在您的意图过滤器中添加BOOT_COMPLETED操作.在清单中添加以下行.但基本上对于Firebase Notification,无需添加此操作.
Actually, If you want to start service after restarted then you have to add intent-filter action. try to add BOOT_COMPLETED action in your intent-filter. Add below lines in the manifest. But basically for Firebase Notification, No need to add this action.
<service android:name="mon.service.NotificationService" android:enabled="true" android:exported="true" android:permission="android.permission.BIND_JOB_SERVICE" android:process=":notification_service"> <intent-filter> <action android:name="com.abc.xyz.restart_service" /> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>更多推荐
设备重启后,Android推送通知
发布评论