Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
109 stars 139 forks source link

FcmRegistrarWorker] FCM registration error: Failed to retrieve token. Is firebase configured correctly? #386

Closed joe-at-startupmedia closed 9 months ago

joe-at-startupmedia commented 1 year ago

This is an error I'm getting in the log and here is how I resolved it.

E/Pushwoosh: [FcmRegistrarWorker] FCM registration error: Failed to retrieve token. Is firebase configured correctly?
I/WM-WorkerWrapper: Worker result SUCCESS for Work [ id=XXXXXXXX-9e9d-XXXX-81ee-0c9ba1XXXXXX, tags={ com.pushwoosh.firebase.internal.registrar.FcmRegistrarWorker } ]

After research I found that it's related to cordova config setting in the project cdv-gradle-config.json file

  "IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,

When I change this to true I get the following build error:

> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[17.0.
  0,20.0.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

That's because the resolved version from

cordova.system.library.5=com.google.android.gms:play-services-location:+

Results in resolving to 21.0.1 (the current latest version) which is greater than 20.0.99.

So now If I manually specify the version in project setting and build.gradle: 20.0.0 (which as a security vulnerability: CVE-2022-2390) https://mvnrepository.com/artifact/com.google.android.gms/play-services-location/20.0.0

I get the following error:

In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[17.0.
0,20.0.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

Dependency failing: com.pushwoosh:pushwoosh-location:6.6.7 -> com.google.android.gms:play-services-location@[17.0.0,20.0
.99], but play-services-location version was 20.0.0.

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.android.gms:play-services-location@{strictly 20.0.0}
-- Project 'app' depends onto com.google.android.gms:play-services-location@20.0.0
-- Project 'app' depends onto com.pushwoosh:pushwoosh-location@{strictly 6.6.7}
-- Project 'app' depends onto com.pushwoosh:pushwoosh-location@6.6.7

For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = true }" to your bu
ild.gradle file.

Next I modified by app/build.gradle file from

if (cordovaConfig.IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED) {
    apply plugin: 'com.google.gms.google-services'
}

to

if (cordovaConfig.IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED) {
    apply plugin: 'com.google.gms.google-services'
    googleServices.disableVersionCheck = true
}

This resulted in the FcmRegistrarWorker successfully registering the token.

I/Pushwoosh: [FcmRegistrarWorker] FCM token is dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxM-iuxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxUeoXY-f5xxxxxxxxxxxxxxxxxxxxx9b_mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoYsHxxxxxxxxxxxxxxxxxxxxxH9C_D
D/Pushwoosh: [DeviceRegistrar] Registering for pushes...
enginseer-dev commented 11 months ago

@joe-at-startupmedia We apologize for the delay in addressing this issue. We experienced some difficulties with our GitHub integration, and as a result, some tickets including this one were overlooked.

Could you please confirm whether this issue is still occurring for you?

joe-at-startupmedia commented 11 months ago

@joe-at-startupmedia We apologize for the delay in addressing this issue. We experienced some difficulties with our GitHub integration, and as a result, some tickets including this one were overlooked.

Could you please confirm whether this issue is still occurring for you?

Hello, based on the solution I provided above, it's no longer an issue for me. With that being said, others may experience the same issue without following the steps I've provided above. You can try to replicate the issue by following the steps as I've documented. Feel free to close this issue as it's been so long since I've encountered it that I've since moved on to other things.

enginseer-dev commented 10 months ago

@joe-at-startupmedia, thank you for your answer. We've checked it and found out the root cause of this issue. We should update the pushwoosh-location plugin to fix it, and this will be done soon. Appreciate your cooperation!

wfhm commented 9 months ago

We've bumped max com.google.android.gms:play-services-location dependency version to 21.0.99, so you can now use the plugin with the latest Google library version. However, we cannot affect your local Cordova project settings from the plugin, so you'll still have to change "IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED" parameter value manually.

Also, it's quite strange that you had to manually add googleServices.disableVersionCheck = true line to your build.gradle, as the plugin should already do that. However, if it does not happen, it seems that your solution should still work.