Push notifications



Peter Bradstreet
Hi David,

Well, I have had a productive week as I now have all of the google mapping stuff working and I also hit a home run with instant messaging and have it working using a firebase realtime database back-end. Thanks for all of your help in getting this far!

One of my final hurdles is to get push notifications working. I have started by trying to get the PushPlugin sample working (AB1) so that I can figure it all out. As soon as the app runs on my phone I get the error about registering. I can see that this is coming from the RegisterPush function. I also see in your example description:

I can see the extra XML code as mentioned but the custom plugin text box in Cordova -> General is empty. Should there be something defined in this box? What do I need to do to get this sample working so that I can start to create my own solution?

Cheers, Pete

David Esperalta

Hello Peter,

Take a look at the App options -> Cordova -> Batch -> After. As you can see we use that to require the "add phonegap-plugin-push" plugin to be installed. About the registration fail, it's a mistake: look at the "SendRegisterID" app function and change the URL of the used HTTP Client control to HTTPS. We can't use HTTP in Android 9+ except if we add some especific option to allow it. If you change the URL to HTTPS you can see the app successfully register.



Peter Bradstreet
Hi, Thanks for that but still no luck. I am thinking that this AB1 sample is based on Google cloud service rather than Firebase Cloud Messaging which is now defunct? The AB2 sample (PushNotif) seems to work and looks like it is working with the FCM which replaced GCM? Pete

David Esperalta

Hello Peter,

Humm... in fact AB1 and AB2 uses the same Cordova plugin... and I compile the AB1 sample here and works as expected. Yesterday I receive some push notifications... and think that come from you testing the sample app. :-)

You must refer to the Cordova plugin documentation in order to see if the plugin's configuration did not allow what you wanted or if allow what you wanted... but it's rare that the AB2 sample works for you and the AB1 don't, because, we are talking about the same internally...



Peter Bradstreet
Okay thanks, I will take another look.
Pete

David Esperalta

Hello Peter,

We use push notifications in various apps, and, works like a charm. We use a Firebase Cloud Messaging account from Google for both Android and iOS platforms. So yes, take a look again, because the app must work as expected in AB1 and AB2 (the app which I am talking about is developed in AB1 right now).



Peter Bradstreet
Hi David,

I must be doing something centrally wrong. I have opened up a fresh and clean instance of PushPlugin.ab and make the single change in it to set the HttpSetUrl to https instead of http. I then compile the app and go into the compiled folder and click on cordova_android_run.bat but I am getting the following error:

I am assuming that the error that is breaking it is referring to minSdkVersion but I am not sure where that is set? Any ideas?

Pete

David Esperalta

Hello Peter,

Yes; since you refer before that you can try the app, I asume that you already see the "min SDK problem" and then can compile the APK. Certainly, you must change the "min SDK" to API 19. You can do it in the app options -> Cordova -> Android -> Genera -> Minimum SDK.



Peter Bradstreet
Sorry, I was not paying attention and didn't realize that I had the min sdk way too low. I have fixed it and it is working now. Now that I have a working example I should be able to take it from here. Thanks! Pete

David Esperalta

No problem, Peter. Just post here if you have any question: as I told you we are using push notifications and works very well, so, probably I can help you, or, at least I will try it.



Amin Mousavi
Having the sample running you may find this document helpful

https://firebase.google.com/docs/cloud-messaging/http-server-ref
android and ios accept two different notification payload format. In my case I really wanted to send the icon that android accepts but ios does not, so I read user device platform and send notifications with different formats like below.


Amin Mousavi
Having the sample running you may find this document helpful

https://firebase.google.com/docs/cloud-messaging/http-server-ref
android and ios accept two different notification payload format. In my case I really wanted to send the icon that android accepts but ios does not, so I read user device platform and send notifications with different formats like below.


David Esperalta

Hello to all,

Thanks, Amin, for share such information here. You are right, of course, Android and iOS can have different notifications' payloads.



Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.