-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin): add Microsoft App Center Push plugin
- Loading branch information
1 parent
a38381d
commit cdabebd
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; | ||
import { Observable } from 'rxjs/Observable'; | ||
|
||
/** | ||
* @name App Center Push | ||
* @description | ||
* | ||
* For more info, please see https://docs.microsoft.com/en-us/appcenter/sdk/push/cordova | ||
* | ||
* @usage | ||
* ```typescript | ||
* 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); | ||
* }); | ||
* }); | ||
* | ||
* ``` | ||
*/ | ||
@Plugin({ | ||
pluginName: 'AppCenterPush', | ||
plugin: 'cordova-plugin-appcenter-push', | ||
pluginRef: 'AppCenter.Push', | ||
repo: | ||
'https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-push', | ||
platforms: ['Android', 'iOS'] | ||
}) | ||
@Injectable() | ||
export class AppCenterPush extends IonicNativePlugin { | ||
/** | ||
* Subscribe to an event | ||
* @param {string} eventname Event name | ||
* @returns {Observable<any>} | ||
*/ | ||
@Cordova({ | ||
observable: true, | ||
clearFunction: 'removeEventListener' | ||
}) | ||
addEventListener(eventname: string): Observable<any> { | ||
return; | ||
} | ||
/** | ||
* Check if App Center Push is enabled | ||
* @returns {Promise<boolean>} | ||
*/ | ||
@Cordova() | ||
isEnabled(): Promise<boolean> { | ||
return; | ||
} | ||
|
||
/** | ||
* Enable or disable App Center Push at runtime | ||
* @param {boolean} shouldEnable Set value | ||
* @returns {Promise<void>} | ||
*/ | ||
@Cordova() | ||
setEnabled(shouldEnable: boolean): Promise<void> { | ||
return; | ||
} | ||
} |