Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

App Center Push

Improve this doc

For more info, please see https://docs.microsoft.com/en-us/appcenter/sdk/push/cordova

Repo: https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-push

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-appcenter-push
    $ npm install --save @ionic-native/app-center-push@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { AppCenterPush } from '@ionic-native/app-center-push';


constructor(private appCenterPush: AppCenterPush) { }

...

this.appCenterPush.setEnabled(true).then(() => {
   this.appCenterPush.addEventListener('My Event').subscribe(pushNotification => {
       console.log('Recived push notification', pushNotification);
   });
});

Instance Members

addEventListener(eventName)

Subscribe to an event

Param Type Details
eventName string

Event name

Returns: Observable<any>

isEnabled()

Check if App Center Push is enabled

Returns: Promise<boolean>

setEnabled(shouldEnable)

Enable or disable App Center Push at runtime

Param Type Details
shouldEnable boolean

Set value

Returns: Promise<void>

API

Native

General