Skip to main content

Working tutorials on ionic push notification.

Working tutorials on ionic push notification.

https://github.com/replysam2009/ionic2-push-notifications



ionic start --v2 myApp blank

npm install @ionic/cloud-angular --save

ionic plugin add phonegap-plugin-push --variable SENDER_ID=XXXXXXXXX

How to get SENDER_ID: https://medium.com/@ankushaggarwal/gcm-setup-for-android-push-notifications-656cfdd8adbd#.2dfwmb64z


Go to : https://apps.ionic.io/

Create account

give command : ionic upload

See app in account here  :  https://apps.ionic.io/

Upload app

Copy app id 


in app.module.ts

import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';
import { CloudSettings, CloudModule } from '@ionic/cloud-angular';

const cloudSettings: CloudSettings = {
  'core': {
    'app_id': '0e886220'
  },
  'push': {
    'sender_id': '884500026100',
    'pluginConfig': {
      'ios': {
        'badge': true,
        'sound': true
      },
      'android': {
        'iconColor': '#343434'
      }
    }
  }
};

@NgModule({
  declarations: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  imports: [
    IonicModule.forRoot(MyApp),
    CloudModule.forRoot(cloudSettings)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}

home.ts

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import {
  Push,
  PushToken
} from '@ionic/cloud-angular';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController,public push: Push, public platform: Platform) {
      if(( this.platform.is('ios') || this.platform.is('android') )){
        this.push.register().then((t: PushToken) => {
          return this.push.saveToken(t);
        }).then((t: PushToken) => {
          console.log('Token saved:', t.token);
        });

        this.push.rx.notification()
          .subscribe((msg) => {
            alert(msg.title + ': ' + msg.text);
          });
      }    
  }

}



To create security profile in ionic: 

https://docs.ionic.io/services/profiles/

Android App Keystore
The Android keystore, used for signing apps, can be generated using keytool, which is included in the Java JDK. Change MY-RELEASE-KEY and MY_ALIAS_NAME to be relevant to your app. The tool will ask you to enter a keystore password and a key password.
$ keytool -genkey -v -keystore MY-RELEASE-KEY.keystore -alias MY_ALIAS_NAME -keyalg RSA -keysize 2048 -validity 10000

Then follow : https://devdactic.com/ionic-2-push-notifications/
https://devdactic.com/ionic-2-push-notifications/








Comments

Popular posts from this blog

Error: ios-deploy was not found. Please download, build and install version 1.9.0 or greater from https://github.com/phonegap/ios-deploy into your path, or do 'npm install -g ios-deploy' solution this solved the issue sudo npm install -g ios-deploy -unsafe-perm

Error: ios-deploy was not found. Please download, build and install version 1.9.0 or greater from https://github.com/phonegap/ios-deploy into your path, or do 'npm install -g ios-deploy' solution this solved the issue sudo npm install -g ios-deploy -unsafe-perm

How to upload file in MEAN Stack

How to upload file in MEAN Stack Do these steps 1. npm install ng-file-upload 2. include ng-file-upload.min.js in your angular index .html 3. Use this example to copy form to your angular page from where u want to upload file. -- http://jsfiddle.net/0m29o9k7/ or http://jsfiddle.net/danialfarid/2vq88rfs/136/ Copy this code outside of any form which is already there: 4. Change this url from example code to where you want to upload files -- url: 'https://angular-file-upload-cors-srv.appspot.com/upload', 6. In your server.js or app.js which ever you are using as (node server.js) to start app add these lines     var crypto = require('crypto');         var mime = require('mime');         var multer  = require('multer');                     var storage = multer.diskStorage({           destination: function (req, file, cb) {     ...