Cordova-plugin-firebase: Compatiblity with Phonegap Build

Created on 18 Aug 2016  Â·  22Comments  Â·  Source: arnesson/cordova-plugin-firebase

Hello,,

It seems there's no way to include the Firebase config files in the root directory of a Phonegap Build package as this kind of package is usually just the www folder.
Can the plugin be modified to locate the config files either in the root dir or the www dir?

Most helpful comment

actually it seems like hooks are not supported at all in PGB - https://github.com/phonegap/build/issues/425

This means you have to manually make sure the config files are in the right place.

The only way I can think of is to fork this plugin and replace the empty config files with your own actual ones (make a private fork ;). If anyone knows a better way, please correct me

All 22 comments

Yes we can have it search both root and www, I don't see any reason not to

Thanks for the answer, @robertarnesson.
when do you think this will be implemented?

can you try it out yourself and send a pr? I don't use phonegap build myself. its very easy to patch https://github.com/arnesson/cordova-plugin-firebase/blob/master/scripts/after_prepare.js to look in www as well

@robertarnesson
Sorry, im didnt understand this. Will PGB auto use after_prepare.js and im just require to place both config file inside /www folder?

I'll try to work on it in the next days. I'll have a look at the code then
only.
Thanks for directing me to the related file though.

On Thu, Aug 25, 2016, 19:30 maplerichie [email protected] wrote:

@robertarnesson https://github.com/robertarnesson
Sorry, im didnt understand this. Will PGB auto use after_prepare.js and im
just require to place both config file inside /www folder?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/arnesson/cordova-plugin-firebase/issues/34#issuecomment-242430042,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATVPiLrLgdbuB6vx52j1VB-DSAA8lDFks5qjbT0gaJpZM4Jnn_D
.

@maplerichie PGB is not supported at this point. See my earlier reply for what is needed. Once this issue is fixed it should work by putting the config files in www instead of root

made an attempt to fix this, see 806af2b

you can test this by installing from github master instead of version X

@robertarnesson, thanks for your attempt.
the thing about PGB is that you upload only the main www folder. no platform specific folders get uploaded. so, as i reviewed your code, i saw that you are looking for the files either in the root dir or the platform specific www folder which again won't work.
the paths need to be changed on both ios and android sides to:
line #37: var paths = ["GoogleService-Info.plist", "www/GoogleService-Info.plist"];
line #54:var paths = ["google-services.json", "www/google-services.json"];
this will make the plugin look for the said files either in the root dir or the main www folder.

@AjawadMahmoud you still put the files in the www folder. During prepare cordova copies the files in www to each platform folder. Our hook is triggered after prepare so the files will be available there. This way using merges is also supported which might come in handy for some users

Alright, I missed this point. Let me give it a try with a proof-of-concept
to see how does this work with PGB.

On Sun, Aug 28, 2016, 20:31 Robert Arnesson [email protected]
wrote:

@AjawadMahmoud https://github.com/AjawadMahmoud you still put the files
in the www folder. During prepare cordova copies the files in www to each
platform folder. Our hook is triggered after prepare so they will be
available there. This way using merges is also supported

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/arnesson/cordova-plugin-firebase/issues/34#issuecomment-242984167,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATVPrplOWhGYPQRaNZ9ECYNteS--yy4ks5qkbf1gaJpZM4Jnn_D
.

okay. it's not working.
i'm not having time to figure out where things are going wrong. however, at the runtime i'm not getting firebase plugin to register the device.

is the app launching though? if so the config files are where they should be

So your plugin breaks the app if it doesn't locate the config files? I
actually don't think so as the plugin was always installed in my project
even before adding the files.

On Wed, Aug 31, 2016, 18:24 Robert Arnesson [email protected]
wrote:

is the app launching though? if so the config files are where they should
be

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/arnesson/cordova-plugin-firebase/issues/34#issuecomment-243777413,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATVPt3RTpJHeDKjWxnR1iNTKjlXC7HUks5qlYwvgaJpZM4Jnn_D
.

erm no, but the firebase sdk will not work at all if it finds no config file and the app will crash. This is a requirement by Firebase not by the plugin itself.

Can you confirm that firebase starts up without errors/warnings about the config files? The device not registering could be just a problem with your app code

Could be.
I'm in a very busy week. As soon as I confirm it I'll let you know.

On Thu, Sep 1, 2016, 06:09 Robert Arnesson [email protected] wrote:

erm no, but the firebase sdk will not work at all if it finds no config
file. At least on ios this will cause the app to crash. This is a
requirement by Firebase not by the plugin itself.

Can you confirm that firebase starts up without errors/warnings about the
config files? The device not registering could be just a problem with your
app code

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/arnesson/cordova-plugin-firebase/issues/34#issuecomment-243935504,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATVPq8m_L19Fl-F9aP0p55mJeLZIqL2ks5qlhGNgaJpZM4Jnn_D
.

So, window.FireBasePlugin is available, however when i'm trying to do getInstanceId() i'm being answered back with null in the promise function.
UPDATE:
I tried an update testcase with the badge number and it worked, however, it's still declining to provide me an instance ID.

Great, so the fix worked! You could open another ticket for the issue with getInstanceId, so that we can close this one. getInstanceId will return null if FCM is not connected yet when you make the call. Are you testing ios or android?

So, if setting a badge number works it means the plugin is able to reach the config files?
UPDATE:
Sorry, i was writing this reply on the go. i'm testing on android right now.

Here's an update on the case.
I just tried building two different apps; one with config files and the other without. the results are identical; both the apps set the badge counter to 3, and both of them returned null from the token callback when i called getInstanceId().
i have a feeling this means the fix doesn't actually work.

actually it seems like hooks are not supported at all in PGB - https://github.com/phonegap/build/issues/425

This means you have to manually make sure the config files are in the right place.

The only way I can think of is to fork this plugin and replace the empty config files with your own actual ones (make a private fork ;). If anyone knows a better way, please correct me

updated the readme w/ info about PGB.

Reopen this if you find a better way to make it work

Well i was forked a branch to FCMPlugin with my own certs and add a tag in config.xml and phonegap build in android but not in ios

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielpalen picture danielpalen  Â·  5Comments

merbin2012 picture merbin2012  Â·  4Comments

DanielAccorsi picture DanielAccorsi  Â·  3Comments

JonSmart picture JonSmart  Â·  3Comments

rlz picture rlz  Â·  4Comments