fix(onesignal): update to match latest api (#671)

closes #667
This commit is contained in:
Ibrahim Hadeed 2016-10-11 01:12:43 -07:00 committed by GitHub
parent c5fd83ddb6
commit 7c6e6d8b6b

View File

@ -14,13 +14,19 @@ import { Observable } from 'rxjs/Observable';
* ```typescript * ```typescript
* import { OneSignal } from 'ionic-native'; * import { OneSignal } from 'ionic-native';
* *
* OneSignal.init('b2f7f966-d8cc-11e4-bed1-df8f05be55ba', * OneSignal.startInit('b2f7f966-d8cc-11e4-bed1-df8f05be55ba', '703322744261');
* {googleProjectNumber: '703322744261'})
* .subscribe(jsonData => {
* console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
* });
* *
* OneSignal.enableInAppAlertNotification(true); * OneSignal.enableInAppAlertNotification(true);
*
* OneSignal.handleNotificationReceived().subscribe(() => {
* // do something when notification is received
* });
*
* OneSignal.handleNotificationOpened().subscribe(() => {
* // do something when a notification is opened
* });
*
* OneSignal.endInit();
* ``` * ```
* *
*/ */
@ -32,26 +38,71 @@ import { Observable } from 'rxjs/Observable';
export class OneSignal { export class OneSignal {
/** /**
* Only required method you need to call to setup OneSignal to receive push notifications. Call this from the `deviceready` event. * @private
*
* @param {string} 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.
* @returns {Observable} when a notification is received. Handle your notification action here.
*/ */
@Cordova({ observable: true }) static OSInFocusDisplayOption = {
static init(appId: string, None: 0,
options: { InAppAlert : 1,
googleProjectNumber: string; Notification : 2
autoRegister: boolean; };
}): Observable<any> { return; }
/** /**
* Call this when you would like to prompt an iOS user to accept push notifications with the default system prompt. * Start the initialization process. Once you are done configuring OneSignal, call the endInit function.
* Only use if you passed false to autoRegister when calling init. *
* @param {string} appId Your AppId from your OneSignal app
* @param {string} googleProjectNumber The Google Project Number (which you can get from the Google Developer Portal) and the autoRegister option.
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
static registerForPushNotifications(): void { } static startInit(appId: string, googleProjectNumber: string): any { return; }
/**
* Callback to run when a notification is received
* @return {Observable<any>}
*/
@Cordova({
observable: true
})
static handleNotificationReceived(): Observable<any> { return; }
/**
* Callback to run when a notification is opened
* @return {Observable<any>}
*/
@Cordova({
observable: true
})
static handleNotificationOpened(): Observable<any> { return; }
/**
*
* @param settings
*/
@Cordova({ sync: true })
static iOSSettings(settings: {
kOSSettingsKeyInAppLaunchURL: boolean;
kOSSettingsKeyAutoPrompt: boolean;
}): any { return; }
@Cordova({ sync: true })
static endInit(): any { return; }
/**
* Retrieve a list of tags that have been set on the user from the OneSignal server.
*
* @returns {Promise} Returns a Promise that resolves when tags are recieved.
*/
@Cordova()
static getTags(): Promise<any> { return; }
/**
* Lets you retrieve the OneSignal user id and device token.
* Your handler is called after the device is successfully registered with OneSignal.
*
* @returns {Promise} Returns a Promise that reolves if the device was successfully registered.
* It returns a JSON with `userId`and `pushToken`.
*/
@Cordova()
static getIds(): Promise<any> { return; }
/** /**
@ -73,14 +124,6 @@ export class OneSignal {
@Cordova({ sync: true }) @Cordova({ sync: true })
static sendTags(json: any): void { } static sendTags(json: any): void { }
/**
* Retrieve a list of tags that have been set on the user from the OneSignal server.
*
* @returns {Promise} Returns a Promise that resolves when tags are recieved.
*/
@Cordova()
static getTags(): Promise<any> { return; }
/** /**
* Deletes a tag that was previously set on a user with `sendTag` or `sendTags`. Use `deleteTags` if you need to delete more than one. * Deletes a tag that was previously set on a user with `sendTag` or `sendTags`. Use `deleteTags` if you need to delete more than one.
* *
@ -98,14 +141,11 @@ export class OneSignal {
static deleteTags(keys: string[]): void { } static deleteTags(keys: string[]): void { }
/** /**
* Lets you retrieve the OneSignal user id and device token. * Call this when you would like to prompt an iOS user to accept push notifications with the default system prompt.
* Your handler is called after the device is successfully registered with OneSignal. * Only use if you passed false to autoRegister when calling init.
*
* @returns {Promise} Returns a Promise that reolves if the device was successfully registered.
* It returns a JSON with `userId`and `pushToken`.
*/ */
@Cordova() @Cordova({ sync: true })
static getIds(): Promise<any> { return; } static registerForPushNotifications(): void { }
/** /**
* Warning: * Warning:
@ -143,15 +183,6 @@ export class OneSignal {
@Cordova({ sync: true }) @Cordova({ sync: true })
static enableNotificationsWhenActive(enable: boolean): void { } static enableNotificationsWhenActive(enable: boolean): void { }
/**
* By default this is false and notifications will not be shown when the user is in your app, instead the notificationOpenedCallback is fired.
* If set to true notifications will be shown as native alert boxes if a notification is received when the user is in your app.
* The notificationOpenedCallback is then fired after the alert box is closed.
*
* @param {boolean} enable
*/
@Cordova({ sync: true })
static enableInAppAlertNotification(enable: boolean): void { }
/** /**
* You can call this method with false to opt users out of receiving all notifications through OneSignal. * You can call this method with false to opt users out of receiving all notifications through OneSignal.
@ -176,6 +207,13 @@ export class OneSignal {
@Cordova({ sync: true }) @Cordova({ sync: true })
static promptLocation(): void { } static promptLocation(): void { }
/**
*
* @param email {string}
*/
@Cordova({ sync: true })
static syncHashedEmail(email: string): void { }
/** /**
* Enable logging to help debug if you run into an issue setting up OneSignal. * Enable logging to help debug if you run into an issue setting up OneSignal.
* The logging levels are as follows: 0 = None, 1= Fatal, 2 = Errors, 3 = Warnings, 4 = Info, 5 = Debug, 6 = Verbose * The logging levels are as follows: 0 = None, 1= Fatal, 2 = Errors, 3 = Warnings, 4 = Info, 5 = Debug, 6 = Verbose