Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatiblity with Phonegap Build #34

Closed
mahmoudajawad opened this issue Aug 18, 2016 · 22 comments
Closed

Compatiblity with Phonegap Build #34

mahmoudajawad opened this issue Aug 18, 2016 · 22 comments

Comments

@mahmoudajawad
Copy link

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?

@robertarnesson
Copy link
Contributor

robertarnesson commented Aug 22, 2016

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

@mahmoudajawad
Copy link
Author

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

@robertarnesson
Copy link
Contributor

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

@maplerichie
Copy link

@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?

@mahmoudajawad
Copy link
Author

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 notifications@github.com 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
#34 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATVPiLrLgdbuB6vx52j1VB-DSAA8lDFks5qjbT0gaJpZM4Jnn_D
.

@robertarnesson
Copy link
Contributor

@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

@robertarnesson
Copy link
Contributor

robertarnesson commented Aug 26, 2016

made an attempt to fix this, see 806af2b

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

@mahmoudajawad
Copy link
Author

mahmoudajawad commented Aug 28, 2016

@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.

@robertarnesson
Copy link
Contributor

robertarnesson commented Aug 28, 2016

@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

@mahmoudajawad
Copy link
Author

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 notifications@github.com
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
#34 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATVPrplOWhGYPQRaNZ9ECYNteS--yy4ks5qkbf1gaJpZM4Jnn_D
.

@mahmoudajawad
Copy link
Author

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.

@robertarnesson
Copy link
Contributor

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

@mahmoudajawad
Copy link
Author

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 notifications@github.com
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
#34 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATVPt3RTpJHeDKjWxnR1iNTKjlXC7HUks5qlYwvgaJpZM4Jnn_D
.

@robertarnesson
Copy link
Contributor

robertarnesson commented Aug 31, 2016

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

@mahmoudajawad
Copy link
Author

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 notifications@github.com 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
#34 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATVPq8m_L19Fl-F9aP0p55mJeLZIqL2ks5qlhGNgaJpZM4Jnn_D
.

@mahmoudajawad
Copy link
Author

mahmoudajawad commented Sep 3, 2016

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.

@robertarnesson
Copy link
Contributor

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?

@mahmoudajawad
Copy link
Author

mahmoudajawad commented Sep 6, 2016

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.

@mahmoudajawad
Copy link
Author

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.

@robertarnesson
Copy link
Contributor

robertarnesson commented Sep 8, 2016

actually it seems like hooks are not supported at all in PGB - phonegap/build#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

@robertarnesson
Copy link
Contributor

updated the readme w/ info about PGB.

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

@CarlosFJ
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants