firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.27k stars 577 forks source link

When trying to get a token, the exception SERVICE_NOT_AVAILABLE is coming out on WEAR OS device #1395

Closed frodonumb closed 4 years ago

frodonumb commented 4 years ago

Describe your environment

Describe the problem

WearOS devices connected to some of iPhone (but not for all iPhone devices, on some of them it's working fine) recently started getting SERVICE_NOT_AVAILABLE errors when calling FirebaseInstanceId.getInstanceId().

A watch os version: Ticwatch

Steps to reproduce:

Connect Ticwatch Pro to an iPhone device. Waiting for FirebaseMessagingService onNewToken but nothing happened, trying to get FirebaseInstanceId.getInstance().getInstanceId() and on callback task not successful with message SERVICE_NOT_AVAILABLE

Relevant Code:

FirebaseInstanceId.getInstance().getInstanceId()
                .addOnCompleteListener(task -> {
                    if (!task.isSuccessful()) {
                        Timber.e(task.getException());
                        return;
                    }
                    String token = Objects.requireNonNull(task.getResult()).getToken();
                    getSharedPreferences("_", MODE_PRIVATE).edit().putString("fb", token).apply();
                });
google-oss-bot commented 4 years ago

I found a few problems with this issue:

andirayo commented 4 years ago

@frodonumb : This sounds like there might be Firebase options missing during initialization of Firebase, or otherwise misconfigured FirebaseApp instance that prevents the Firebase Installations SDK (FIS), a new dependency of FirebaseInstanceId, to successfully communicate to its servers.

A couple of questions to you:

frodonumb commented 4 years ago

@frodonumb : This sounds like there might be Firebase options missing during initialization of Firebase, or otherwise misconfigured FirebaseApp instance that prevents the Firebase Installations SDK (FIS), a new dependency of FirebaseInstanceId, to successfully communicate to its servers.

A couple of questions to you:

  • Do you have a full stack trace of the error that occurs.
  • Are you willing to share either project number, project ID, or Firebase application ID (which is non-secret information about your application), so I can check our logs for failing client requests to confirm/reject my assumption?

@andirayo i don't think so, because on some of wear os devices connected to iPhone it works fine, and no problems with taking token from FirebaseInstanceId. For first i haven't set up yet crashlytics, i'll give it as soon as possible. For second i can share Firebase application ID : time-4a5b9.

andirayo commented 4 years ago

@frodonumb :
The behavior described by you can be symptomatic for missing Firebase options.

Background

FirebaseInstanceId is an infrastructure service that is used by various Firebase services like Messaging (FCM). With the recent version (v20.1.0), FirebaseInstanceId introduced a new dependency: The Firebase Installations SDK (FIS).

Firebase Installations is an infrastructure service (identity provider and authentication scheme) that is used under the hood by many Firebase services (like Analytics). Usually, you do not need to explicitly include it, but you will get it as transitive dependency (through Firebase InstanceId).

Different to most Firebase SDKs, FirebaseInstanceId did not require a valid API key to function. However, Firebase Installations does. Thus, a misconfiguration might only have become apparent with the recent version update.

Old installations of your applications already have valid FCM registration tokens which are necessary to send push notifications. New installations might not be able to get those tokens and thus malfunction.

Your app

Thank you for sharing your Project ID. I looked into our server logs. However I can only see 5 (successful) requests in the last week for this project. Are you sure you gave me the correct identifier (and the ID of a test project)?

fyi: I will try to reach out to you via email to make debugging easier.

frodonumb commented 4 years ago

@frodonumb : The behavior described by you can be symptomatic for missing Firebase options.

Background

FirebaseInstanceId is an infrastructure service that is used by various Firebase services like Messaging (FCM). With the recent version (v20.1.0), FirebaseInstanceId introduced a new dependency: The Firebase Installations SDK (FIS).

Firebase Installations is an infrastructure service (identity provider and authentication scheme) that is used under the hood by many Firebase services (like Analytics). Usually, you do not need to explicitly include it, but you will get it as transitive dependency (through Firebase InstanceId).

Different to most Firebase SDKs, FirebaseInstanceId did not require a valid API key to function. However, Firebase Installations does. Thus, a misconfiguration might only have become apparent with the recent version update.

Old installations of your applications already have valid FCM registration tokens which are necessary to send push notifications. New installations might not be able to get those tokens and thus malfunction.

Your app

Thank you for sharing your Project ID. I looked into our server logs. However I can only see 5 (successful) requests in the last week for this project. Are you sure you gave me the correct identifier (and the ID of a test project)?

fyi: I will try to reach out to you via email to make debugging easier.

@andirayo yes i'm sure, there are not many active users now, the project is under testing

ankitaj224 commented 4 years ago

@frodonumb Really sorry not responding earlier. Are you still facing the same issue?

google-oss-bot commented 4 years ago

Hey @frodonumb. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 4 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@frodonumb if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.