Push Notifications Android & IOS


Sabino Civita

Hello everybody,

how to implement in the app a push notifications service ?
Simply as possible..........

Thank you in advance for your help

sabinocivita


DecSoft

Hello Sabino,

Thanks for your interest in App Builder. Are you take a look at the "Pusher" and the "PushPlugin" app samples? Maybe one of them can be useful to your purpose, so try it and post here if you have some further question.



Sabino Civita

Hello David, just to be sure, I explain quicky what I done.
I made a simple app using iframes control to display my magazine site.
My site is done in WordPress.
What I want to do is to send a push notification to all user that will install app when a new post is present.

Is it simply to do ?


DecSoft

Hello Sabino,

Certainly we can do it. In fact the "PushPlugin" app sample demonstrates how to do it. As you can see in that sample we need to use certain Apache Cordova's plugin, deal with a little of pure Javascript (just an app's Javascript function) and finally an account in the Google Cloud Service API.

We can send the push notifications using some server script (like the "PushPlugin" does) or just by using the Google service console. Basically we "push" a message and then anyone who have the application installed receive such message as a notification which the users can click in order to open our application.

The problem is, Sabino, you already can found this ready in the "PushPlugin" app sample... so I am not sure how to help you... since you can simply copy the appropiate code to your application, etc. So if you have any further question don't hesitate to post it here.



DecSoft

Hello to all,

I update App Builder right now in order to include certain changes made over the "PushPlugin" app sample. Now, instead of use one PHP script for both, the registration process and the send message process, we use two separates PHP scripts, and also an HTML file with a form, which we can fill to send a push notification easily.

On the other hand, remember this application uses certain Google API authorization and credentials made specifically for the sample, so, if you want to use the "Push plugin" in your application, you must get your own Google API authorization and credentials. If anyone need some help about this question post here and I will try to help.

If anyone want to try, folowing the below link you can download the "PushPlugin" APK file, then you can install it in your Android device.

PushPlugin.zip

Once you do that you can already request a push notification (as a sample) from the application, or, even better, using the below HTML form:

https://www.decsoftutils.com/Humm/Sites/Main/Views/Data/AppBuilder/Samples/PushPlugin/sendpush.html

Attention! I have the sample application installed, then any message you send arrive also to me and to other possible users too!



Sabino Civita

Hello David,

thank you so much for your deep and accurate help ! You solved my issue and now all works great !

Great Job !!!!!!!!!!!!!

Sabino

PS: Compliments for your APPBuilder !!! No APPBuilder No Party !!!!!!!


DecSoft

Hello Sabino,

Hello David,

thank you so much for your deep and accurate help ! You solved my issue and now all works great !

Great Job !!!!!!!!!!!!!

Sabino

PS: Compliments for your APPBuilder !!! No APPBuilder No Party !!!!!!!

Thanks very much! I am happy to help and certainly Push notifications appear a very good addition to our applications. I know you have lot of works yet in the application, then let me know if I can help in something.

Thanks again for your kindly words Sabino.



Guest

Fantastic post.
I have tried this but i am getting

"Registration ID send failed" what am i missing here.


DecSoft

Hello to all,

Registration ID send failed

If the above exactly the error message that you get? Or the message include some more information?



Guest

Hi david
thats all i get.

I think it has to do with the register.php, line 18

if (issset($_Post['RegisterID']))


DecSoft

Hello,

Are you trying with the application sample without modification or you are trying to use your own server scripts and Google credentials? I asume you build the sample with Apache Cordova and you are trying in an Android device (for example), it's this correct?



Guest

Hi
I used the sample, and have done all the modifications in the phps; Api key and sender ID, RegisterPush and SendRegisterID functions and built with cordova.

But i think my problem is with the POST in register.php.

Do I need to have a file on my server called RegisterID and what type of file should it be.


DecSoft

Hello,

I am triying right now with the PushPlugin sample and they works as expected. Why do you think that the problem can be in the "register.php" script? Can you provide me with a little application sample in order to take a look?



Guest

Ok


DecSoft

Hello,

Ok

Ok for what? :)



Guest

providing you with a little application sample in order to take a look


DecSoft

Hello,

providing you with a little application sample in order to take a look

That's ok! Please include at least the "register.php" script in order to take a look too... And anyway, since the PushPlugin sample works as expected here... please take a look at that in order to look how they works and possible differences with your own implementation.



Guest

Hi David
I did as u advised and finally got it right.

I added all phps as is to the test server and edited the api key right on the server.
Edited the sender ID in the app functions
Redirected all links to the test server
Compiled and built with Cordova.
and voila it worked


DecSoft

Hello,

Hi David
I did as u advised and finally got it right.

I added all phps as is to the test server and edited the api key right on the server.
Edited the sender ID in the app functions
Redirected all links to the test server
Compiled and built with Cordova.
and voila it worked

Well, glad to know they are worked. Certainly the PushPlugin sample works also here as expected, so they must work also for you!



Guest

By the way, can the notifications be styled like in Html.
For example with font color, add icons etc.


DecSoft

Hello to all,

By the way, can the notifications be styled like in Html.
For example with font color, add icons etc.

I don't remember if the Cordova's Push plugin offer something like you wanted. The notification's icon is the the application's icon and, by default, other apparence is determined by the system. Once the user tap on the notification, then, yes, you can shown to the user whatever kind of app's message, view, etc.



Romeo Ross

Hi David

Hope all is well. My Pushplugin notifications stopped working.

Thanks


DecSoft

Hello Romeo,

I use the Apache Cordova push plugin in certain app and they works as expected. May I can take a look at the specific sample when have some time. Can you please be a little more specific about the errors that you found? Are that errors related with App Builder or with Apache Cordova and the Push plugin or maybe other Apache Cordova plugins?

Please, note that I remove the link that you place in the above entry. That link is certainly more or less public, but, I think may are not good for the forum.



Romeo Ross

Hi David 

I had to downgrade the cordova version in order for it to work again. Thank you.

I was wondering is there any way to see the message within the app itself again. After you click O.K. its gone.

Regards 
 

DecSoft

Hello Romeo,

I was wondering is there any way to see the message within the app itself again. After you click O.K. its gone.

Please, can you explain a little more this question? I am not sure if understand well. Thanks in advance Romeo.



Romeo Ross

Hi David 

When you send a push notification it comes to phone in alert popup box which is nice, then after you read message, it opens the app.

But how can you save that message in the app?

Thanks




DecSoft

Hello Romeo,

Hi David

When you send a push notification it comes to phone in alert popup box which is nice, then after you read message, it opens the app.

But how can you save that message in the app?

Thanks

If I can understand well, it's completely up to you what to do with the notification contents. For example, in an app that I am developing, we certainly save the notifications (not all of them, only what we wanted) in a database. Then, in an specific app's view, the user can read again all the previously sended (and saved) notifications.

But it's completely up to you to do that if you need it. And probably not save the notification when arrives to the app, but, when send it to the app. That is, the same server's script who send the notification can also save it into a database. Then the app only receive, process and shown notifications, and, additionally, list past notifications too.



Amin Mousavi
Hi David,
I am working on adding notification to our app. PushPlugin sample however fails to build for android. I have read its documents and have proper IDs needed however I think the problem is sources elsewhere. Since this tread is aged, I was wondering, is this sample still functional? I have no issue in building other android projects with Cordova. For reference, error begins by "compileSdkVersion is not specified".

Any help is greatly appreciated. Thanks a mill

DecSoft

Hello Amin,

Yes; don't worry, the Cordova push notifications plugin works like a charm in Android and iOS. Certainly I don't get the same error that you mention (you know that in fact we are talking here about Apache Cordova errors, not App Builder errors, in the sense that different installations of the Android SDK, Cordova, etc., can cause the problem), but, certainly have some problems with the PushPlugin sample.

Please, Amin, upgrade your AB copy: I made certain changes in the PushPlugin sample, and, I can compile the APK now without any problems and also see running it in Android like expected. So upgrade your AB copy and try with the modified PushPlugin sample. You need to see it working like expected: then you can starts from that sample to implement the notifications in your apps.

Post here if you find any problem, however, remember that we are talking about Apache Cordova... so a good Google search with the error message plus "push plugin Cordova" can be useful to solve a possible problem. However, since the PushPlugin app sample works like expected here, in principle you must see it working also for you. Post here your results, please.



Amin Mousavi
Hi David,

Thanks for the swift response as always and updating the sample, it builds flawlessly now. Yesterday I built and tested it on Android and today I built it for windows. Both build correctly but both read the response text in the Response text area as [object Object]. Should not be a big deal. Have to fix something urgent on our server. Will continue the work on the notifications this evening and will post my progress here.

As always thanks a mill for your GREAT support David!

DecSoft

Hello Amin,

Yes; I know you are testing around... because I have installed the sample here in my Android device and receive some notifications. Yes; I also note the "[object]" in the sample... honestly, I am not sure right now about, since the notifications arrive as expected: maybe a mistake in the same. On the other hand, apparently the "[object]" appear only when we send a notification... from the sample app itself... in other words, when we receive a notification from the HTML form, the text appear as expected in both the notification message and the sample app.



Amin Mousavi
Hi David,
Back to the notifications again, just wanted to let you know that I have tested it in android on my own Firebase IDs and it works great! Just a few points that I leave here for future reference, in case someone find it useful some day

> App ID should be the same all over the app, otherwise it does not build, it is an easy error to fix because Cordova clearly points it out
> I was building the notifications for an app that is already installed on my test mobile, using the same ID as one installed app on your phone will cause error during install, it says the app already exists while it is not! goes for update but fails! took me an hour to figure out where it goes wrong!
> in the sendpush.php there is an API key, the name got me confused so I tried the web API key from my firebase account and the API key in google-service.json and neither worked, but infact what I was looking for is named server key under cloud messaging tab in my application account.

Thanks alot for the great AB, its very useful plugins and your fantastic support, you make development much easier and more enjoyable David :-)

DecSoft

Hello Amin,

Thanks for sharing that information here. And yes; certainly the push notifications can be really useful. :-)


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.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.