Hello team,
We are not getting token in latest version of fcm 0.1.23. My cordova cli version is 6.4.0, android cordova version is 6.0.0 and iOS cordova version is 4.3.1. Some time we get a null or blank ('') token. We are getting response in success function.
Let us know if any solution u have find.
Thanks in advance.
have the same with 0.1.24
The problem might be in 0-size file platforms/android/google-services.json
got the same problem, getToken() returns NULL,
had the problem with existing google-services.json in /platforms/android/
ive deleted the file, re-added the plugin with cordova
-> the platforms/android/google-services.json was a 0-size file
but the problem is it does not work either. file exists, no luck, what now ?
no luck yet
can you please report:
ionic infoThe issue seems in updating of
platforms/android/res/values/strings.xml
again, current code has an issue in updating
platforms/android/res/values/strings.xml
thank you for your info, cordova plugins add from newest github version works fine !
@sascha1337 you mean from master ?
as 0.1.24 is not working for me
@illya13
I've had exactly the same issue. I fixed it by adding the following manually to my build.gradle file:
apply plugin: 'com.google.gms.google-services'
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:3.0.0'
}
}
I also put the following lines in comment in the strings.xml file:
<!--<string name="google_app_id">@string/google_app_id</string>
<string name="google_api_key">@string/google_api_key</string>-->
The downside is that I manually need to make these changes after each update in order to get the plugin to work. Is there any idea on what's the cause of this issue? In the plugin source, there is a file named build-extra.gradle wit the line "apply plugin: 'com.google.gms.google-services'", but it seems to be ignored.
Change the below lines in the (platforms/android/res/values/strings.xml)strings.xml file:
<string name="google_app_id">@string/google_app_id</string>
<string name="google_api_key">@string/google_api_key</string>
to:
<string name="google_app_id">your google ap id from google-services.json</string>
<string name="google_api_key">your google api key from google-services.json</string>
use android studio to build the apk.
Actually, this plugin is broken pretty badly. @Rajeshtechgeek is correct about the change in strings.xml, but the problem is that you can then must build the app using Android Studio. If you use the Cordova CLI (which I want as part of my automatic release process), the plugin will add the original two lines back and you won't be able to build at all. So the plugin adds invalid gunk in there.
I fixed this by replacinging the two lines @Rajeshtechgeek mentioned, swappping
<string name="google_app_id">@string/google_app_id</string>
<string name="google_api_key">@string/google_api_key</string>
for
<string name="google_app_id">your google app id from google-services.json</string>
<string name="google_api_key">your google api key from google-services.json</string>
And then, for the deep surgery...
plugins/cordova-plugin-firebase/scripts and node_modules/cordova-plugin-firebase/scripts, remove or comment out the entire contents of the updateStringsXml function in after_prepare.js. The documentation actually states that the hook script doesn't work for Phonegap builds, but they simply don't work at all.node_modules and plugins, remove or comment out the config-file blocks for google_app_id and google_api_key. And build as usual.
I know, I know. I should fork and make these changes. I simply don't have the time.
I've had so much drama with the various FCM plugins, when I do have the time, I just may write my own from scratch.
any news on this?
For anyone else who is having this issue, I found a much simpler solution. Im not positive if this is the right way to go about this or not but hopefully, it will be of help to someone else.
@cobusk comment pointed me to this, but as I was implementing his solution, it dawned on me, that all you really need to do is to modify the string.xml file to include your google key and id. Then when you do a build, it will naturally copy over the values.
DETAILS:
file: plugins/cordova-plugin-firebase/plugin.xml
change:
<string name="google_app_id">{Your app id here}</string>
<string name="google_api_key">{Your api key here}</string>
Are you all sure you are exactly on version 0.1.23 and not something like ^0.1.23? Because the last one actually fetches 0.1.24 at the time of writing and that is the version that causes the empty string token on Android for our apps. 0.1.23 works fine across 3 of our apps in production.
@ValentinKlinghammer Youre right! I confirm!
Instructions to fix it in your downloaded code:
Open /plugins/cordova-plugin-firebase/scripts/after_prepare.js
Find the following code part:
// Copy key files to their platform specific folders
if (directoryExists(IOS_DIR)) {
copyKey(PLATFORM.IOS);
} else if (directoryExists(ANDROID_DIR)) {
copyKey(PLATFORM.ANDROID, updateStringsXml)
}
You can now already see the flaw, change it to:
// Copy key files to their platform specific folders
if (directoryExists(IOS_DIR)) {
copyKey(PLATFORM.IOS);
}
if (directoryExists(ANDROID_DIR)) {
copyKey(PLATFORM.ANDROID, updateStringsXml)
}
This should hotfix it until a new version is being deployed as it's already fixed in the current repo's state.
// EDIT: This has been fixed in 86bc2b6.
Install plugin AngularFire, add AngularFireModule with the config to the Firebase project and set after_prepare.js in line 55. It's workin' now. Thank's!
Another solution is here: https://github.com/arnesson/cordova-plugin-firebase/issues/558
To the author: A PR and a fix is URGENT now... ;-)
a fix is urgent , thanks
What worked for me is.
I download google-services.json file again and replaced in the project.
In platforms\android\project.properties file
In platforms\android\cordova-plugin-fcm-with-dependecy-updated\addexplorer-FCMPlugin.gradle file
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:4.0.2'
}
dependencies {
compile 'com.google.firebase:firebase-core:12.0.0'
}
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin`
In platforms\android\cordova-support-google-services\addexplorer-build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:4.0.2'
}
Most helpful comment
Are you all sure you are exactly on version
0.1.23and not something like^0.1.23? Because the last one actually fetches0.1.24at the time of writing and that is the version that causes the empty string token on Android for our apps.0.1.23works fine across 3 of our apps in production.