I need to implement push notifications in a PhoneGap Build app that I'm developing.
I didn't find much documentation on using the new Google service, Firebase Cloud Messaging (FCM), but since it is supposed to be what we have to use now I searched for an API that could make my life easier.
I found: https://www.npmjs.com/package/cordova-plugin-firebase
So I added to my config.xml:
<plugin name="cordova-plugin-fcm" source="npm" />
And put the google-services.json I've created from https://console.firebase.google.com/ in the root of the folder I zip to upload to the Phonegap Build.
But I get the following error:
Execution failed for task ':processReleaseGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
/project/src/release/google-services.json
/project/google-services.json
I created the "project" folder in the root and put the file there but that doesn't work neither.
Currently my app folder looks like:
\css
\img
\js
\res (icons and splashscreens)
index.html
config.xml
google-services.json
If anyone knows where I've to put that file or have any other way to implement this even using other API, I would really appreciate it. I've never used Phonegap CLI, I've always been using Phonegap Build.
Cordova introduced the resource-file
tag some time ago and it also works in Phonegap Build.
You can use that instead of a forked plugin to copy the google-services.json
and GoogleService-Info.plist
files
Put the in the root of your project and the use the resource-file
tag in the config.xml like this:
If using cordova-android 7 or newer:
<platform name="android">
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>
older versions
<platform name="android">
<resource-file src="google-services.json" target="google-services.json" />
</platform>
iOS
<platform name="ios">
<resource-file src="GoogleService-Info.plist" />
</platform>
You can also put it inside www
folder, in that case in my examples add www/
before the file name in the src
field.
https://cordova.apache.org/docs/en/7.x/config_ref/index.html#resource-file