Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FirebaseInstanceId: background sync failed: SERVICE_NOT_AVAILABLE

I am using this tutorial to implement push notifications using Firebase, but I cannot seem to figure it out. Keeps throwing the error:

FirebaseInstanceId: background sync failed: SERVICE_NOT_AVAILABLE, retry in 40s

I am created a class extending FirebaseMessagingService and onMessageReceived(..). I receive the data. I registered the service in the manifest like:

 <!-- [START firebase_service] -->
        <service android:name="notifications.MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <!-- [END firebase_service] -->

I added latest google-services.json in the root folder of my app. Still, I log nothing.

Naturally, I scoured into StackOverflow to check similar problems. Not many, apparently. Found this, but wasn't very helpful as I still got the same message sent. Any thoughts on something I could have missed?

I tried checking if my device has PlayStore services running and indeed it has:

  public boolean isGooglePlayServicesAvailable() {
        GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
        int status = googleApiAvailability.isGooglePlayServicesAvailable(getApplicationContext());
        if (status != ConnectionResult.SUCCESS) {
            if (googleApiAvailability.isUserResolvableError(status)) {
                googleApiAvailability.getErrorDialog(MainActivity.this, status, 2404).show();
            }
            return false;
        }
        return true;
    }
like image 408
Steve Kamau Avatar asked Feb 05 '23 07:02

Steve Kamau


2 Answers

Thanks guys, i was able to fix the issue by simply enabling Google playstore services in my phone's Settings > Data plan

like image 53
Steve Kamau Avatar answered Feb 08 '23 15:02

Steve Kamau


I had the same problem. I have found that the problem was with my mobile operator Internet Service. I simply installed A third party VPN app (from Google Play Store) to unblock Google Services.

like image 23
smnadim21 Avatar answered Feb 08 '23 16:02

smnadim21