Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push Notifications with Ionic Framework

I'm trying to implement Push Notifications with Ionic and I'm pretty confused. Until now, I've tried the following alternatives with no success:

Ionic Push

Seems to be the best solution. It "simulates" the notifications in browser making easy test. There are two versions:

  1. Version 1.0: the docs are avaiable at http://docs.ionic.io/v1.0/docs/push-overview. The page displays an warning at the bottom saying to check the latest version (2.0beta). If I keep in the page and try to follow the instructions, everything seems to work fine, but if I send the push to https://push.ionic.io/api/v1/push no message arrives. Looking at firebug I found that $ionicPush is querying the 2.0alpha API instead of query the 1.0 API.

  2. Version 2.0: the docs are avaiable at http://docs.ionic.io/docs/push-overview. It is very similar to 1.0 and it works fine in browser, Android (development and production) and iOS development enviroments. But, I can't get messages on IOS production (after publish the app to store). I searched hard for a solution, but I found some answers saying that it is alpha and should not be used.

So, if version 1.0 does not exists (it is using the v2.0 API) and v2.0 is alpha and should not be used, I concluded Ionic Push can't be used.

Question 1: is possible use ionic push to send notifications to iOS and Android?

Question 2: using the 2.0 setup, can I send messages with Apns PHP instead of Ionic Push ?

Cordova Phonegap Plugin Push

This plugin is used by Ionic Push behind the scenes I guess. But, I can't figure out how use it. The tutorials and docs I found are obsolete and references an deprecated version (https://github.com/phonegap-build/PushPlugin.git). Even ngCordova references this deprecated version (http://ngcordova.com/docs/plugins/pushNotifications/). ngCordova suggests Ionic Push also. I can't find an full example showing how to use https://github.com/phonegap/phonegap-plugin-push with ionic.

Question 3: how setup Cordova Phonegap Plugin Push with ionic?

like image 981
Arivan Bastos Avatar asked Apr 18 '16 21:04

Arivan Bastos


People also ask

Does ionic support push notification?

Ionic is easy to integrate with Firebase and Firebase Cloud Messaging, which allows you to enable push notifications quickly.

What is FCM ionic?

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably send messages at no cost. Messaging.


2 Answers

I didn't use Ionic Push yet, so I can only try to answer your third question.

Actually I think the examples on the GitHub plugin page are pretty good so I'm gonna reference those. If you have any further questions feel free to comment and I will elaborate on it.

To start, include the example script in your index.html inside a deviceready listener callback and initialize the plugin with your settings. In the registration event handler, you get the device ID of the current user via data.registrationId which you can save in your database.

To actually send out push messages, I use node-gcm (Android) and apnagent (iOS) server-sided. There are also some good example at least for Android on the plugin page.

like image 64
kolli Avatar answered Sep 29 '22 19:09

kolli


I had been struggling with this for a couple of days, until I found this guide which seems to be really useful: https://github.com/yafraorg/yafra/wiki/Blog-Ionic-PushV5

Hope that can help someone else too!

This is the unofficial documentation for cordovaPushv5, see the actual implementation here: https://github.com/driftyco/ng-cordova/blob/master/src/plugins/push_v5.js

like image 41
IonicBurger Avatar answered Sep 29 '22 18:09

IonicBurger