Ionic 3 Push Notification

Keperluan :

  1. Google app id/ sender id(From firebase console)
  2. Server key(From firebase console)
  3. One Signal appId (From One Signal Dashboard after creating one signal application)

Google app id/ Sender id

  1. Login (https://console.firebase.google.com/)
  2.  “Add project”
  3. Isi maklumat projek.
  4. Klik gear icon > Project setting> Cloud Messaging. Dapatkan server key and sender id bawah tab cloud messaging tab.

Ionic 3 dengan One Signal Push Notification Service

  1. (https://onesignal.com)
  2. Selepas login create new app
  3. Create new One Signal application.
  4. Klik app yang hendak buat notifikasi
  5. Pilih (Google Android GCM) dan NEXT.
  6. Masukkan server key and google project number(sender id or Google app id)
  7. Kemudian pilih Ionic and NEXT.
  8. Akan dapat One Signal App Id. Id yang akan digunakan dalam ionic. Klik “check subscribed users” untuk test.

Push notification in ionic 3 application.

Install the Cordova and Ionic Native plugins:

$ ionic cordova plugin add onesignal-cordova-plugin
$ npm install --save @ionic-native/onesignal

Usage

var notificationOpenedCallback = function(jsonData) {
 alert('notificationOpenedCallback: ' + JSON.stringify(jsonData));
 };
window["plugins"].OneSignal
 .startInit("ff919ce0-8b1e-4e97-8215-04aef5118800", "286346003172")
 .handleNotificationOpened(notificationOpenedCallback)
 .endInit();

Rujukan

Leave a Reply

Your email address will not be published. Required fields are marked *