skip to Main Content

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?

2

Answers


  1. They have a background service which starts the service on bootup. You need to implement such a service. It will increase battery consumption. This might help you.

    Login or Signup to reply.
  2. 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=".common.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>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search