Push Notification PHP via Onesignal

Last week I had worked with my friend to publish a new Android application, the application process started with adding the quotes through the back-end -which created by CodeIgniter- once the admin adds a new quote users notified with the updates across multiple platforms, also the admin should have the ability to notify specific users, this better than opening the application to check if there were a new quotes or not, it should be via push notifications API.

Quite simple, is it?!

Important note:

This Part For Android Notifications,So if You Are Not Going To Integrate Android Platform With OneSignal Skip This Part.

Why Onesignal over firebase for push notifications?

After some discussion we chose Onesignal as a great option over firebase for some reasons:

1- Firebase not completely free, but Onesignal is a full Free API at least until now.

2- Firebase is specified to Android devices, so you could not apply the cloud messaging Aka (FCM) to other platforms like iPhone or Windows phone, although the client has not released the quotes application on other platforms, but if he did that in the future We would stick with this task again and again to support the new platforms rather than changing some lines of code to tie the new platforms to Onesignal API, because Onesignal API supported many platforms, it’s like doing it once run everywhere.

3-Onesignal has a very clear documentation, step by step instructions, that helped me a lot.

Important note:

google has integrated the old cloud messaging service (GCM) to their firebase services package (FCM).

The Push notifications cycle through PHP

1-When you integrate Onesignal SDK with your any platform like (Android, iPhone,,etc.) or your website, the SDK will detect the platform information and create new identification Id, which is unique id for this device (Android, iPhone) or browser (chrome, Firefox) and send all these data to their cloud API.

Additionally, it’s recommended to add your custom data after subscription process to have the ability to track subscribers across all platforms, in this situation I prefer to add a user ID.

OneSignal supports tagging users with simple string data, Tags can be used for targeting notifications to specific users or groups, Tags values can also be used as variables in notification content. You can send your custom data like age, gender, user name, etc.

2-Then To Create Notification open your application (as example PHP) and put your dynamic data and click send, which will call the Onesignal restful API to create a notification..

3-Onesignal will take your custom data (as example title, icon, and the targeted users) and create a notification for those users depends on their devices data that has already registered.

- See more at: http://webeasystep.com/blog/view_article/Push_Notification_PHP_via_Onesignal#sthash.c3zQXIBW.dpuf