fix(one-signal): return Observable instead of promise (#352)

* Added OneSignal wrapper

* documentation

* Changes for callback of notification revieced

* fixes for @Cordova decorators without Promise return

* Merge

* Improvements to OneSignal
extended init function with notificationOpenedCallback as an optional parameter

* Platforms removed
OneSignal supports more than only these 3 platforms. It's available to nearly all Cordova platforms.

* Init method turned into observable
This commit is contained in:
Aaron Czichon 2016-07-25 15:52:17 +02:00 committed by Ibrahim Hadeed
parent 8b9e317519
commit 08fe04e87e

View File

@ -1,4 +1,5 @@
import { Cordova, Plugin } from './plugin'; import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/** /**
@ -28,8 +29,7 @@ import { Cordova, Plugin } from './plugin';
@Plugin({ @Plugin({
plugin: 'onesignal-cordova-plugin', plugin: 'onesignal-cordova-plugin',
pluginRef: 'plugins.OneSignal', pluginRef: 'plugins.OneSignal',
repo: 'https://github.com/OneSignal/OneSignal-Cordova-SDK', repo: 'https://github.com/OneSignal/OneSignal-Cordova-SDK'
platforms: ['Android', 'iOS', 'Windows Phone 8']
}) })
export class OneSignal { export class OneSignal {
@ -38,14 +38,14 @@ export class OneSignal {
* *
* @param {appId} Your AppId from your OneSignal app * @param {appId} Your AppId from your OneSignal app
* @param {options} The Google Project Number (which you can get from the Google Developer Potal) and the autoRegister option. * @param {options} The Google Project Number (which you can get from the Google Developer Potal) and the autoRegister option.
* @returns {Promise} Returns a Promise that resolves when remote notification was recieved. * @returns {Observable} when a notification is received. Handle your notification action here.
*/ */
@Cordova() @Cordova({ observable: true })
static init(appId: string, static init(appId: string,
options: { options: {
googleProjectNumber: string, googleProjectNumber: string,
autoRegister: boolean autoRegister: boolean
}): Promise<any> { return; } }): Observable<any> { return; }
/** /**
@ -253,4 +253,4 @@ export class OneSignal {
visualLevel: number visualLevel: number
}): void { } }): void { }
} }