Monthly Archives: January 2018

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

node -v –> version node
npm -v

install ionic
-> npm install -g ionic cordova

create project
–> ionic start MyDecApp blank

start service kat dalam folder project
–> ionic serve

create file baru
–> ionic g page Profile

tgk template
–> ionic start –list

generate provider
–> ionic g provider webservices

remove platform android
–> ionic cordova platform remove android

add platform android
–> ionic cordova platform add android

built android
–> ionic cordova build android

tukar icon
–> ionic cordova resources

built android
google play
–> ionic cordova build android –prod –release

keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias <– run sekali je kunci ni

keytool -genkey -v -keystore upminfokey.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upminfo

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks android-release-unsigned.apk my-alias

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore upminfokey.jks android-release-unsigned.apk upminfo

zipalign -v 4 android-release-unsigned.apk HelloWorld.apk

zipalign -v 4 android-release-unsigned.apk UPMScanner.apk

apksigner verify HelloWorld.apk

apksigner verify UPMScanner.apk