From eec3fec7ff820e96443e6e3f0d7bf96dac359038 Mon Sep 17 00:00:00 2001 From: Cristiano Fromagio <16294559+cristianofromagio@users.noreply.github.com> Date: Fri, 14 Aug 2020 12:35:32 -0300 Subject: [PATCH] feat(onesignal): add in-app messages methods (#3481) --- src/@ionic-native/plugins/onesignal/index.ts | 98 ++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/src/@ionic-native/plugins/onesignal/index.ts b/src/@ionic-native/plugins/onesignal/index.ts index c568f1479f..3f190dc056 100644 --- a/src/@ionic-native/plugins/onesignal/index.ts +++ b/src/@ionic-native/plugins/onesignal/index.ts @@ -303,6 +303,28 @@ export enum OSActionType { ActionTake = 1, } +/** + * Details about the In-App Message action element (button or image) that was tapped on. + */ +export interface OSInAppMessageAction { + /** + * An optional click name defined for the action element. null or nil (iOS) if not set. + */ + click_name: string; + /** + * An optional URL that opens when the action takes place. null or nil (iOS) if not set. + */ + click_url: string; + /** + * `true` if this is the first time the user has pressed any action on the In-App Message. + */ + first_click: boolean; + /** + * If `true`, the In-App Message will animate off the screen. If `false`, the In-App Message will stay on screen until the user dismisses it. + */ + closes_message: boolean; +} + /** * @name OneSignal * @description @@ -406,6 +428,7 @@ export enum OSActionType { * OSBackgroundImageLayout * OSNotificationOpenedResult * OSActionType + * OSInAppMessageAction */ @Plugin({ pluginName: 'OneSignal', @@ -464,6 +487,18 @@ export class OneSignal extends IonicNativePlugin { return; } + /** + * Use to process an In-App Message the user just tapped on. + * + * @return {Observable} + */ + @Cordova({ + observable: true, + }) + handleInAppMessageClicked(): Observable { + return; + } + /** * **iOS** - Settings for iOS apps * @@ -781,4 +816,67 @@ export class OneSignal extends IonicNativePlugin { */ @Cordova() removeExternalUserId(): void {} + + /** + * Add a trigger. May show an In-App Message if its trigger conditions were met. + * + * @param {string} key Key for the trigger. + * @param {string | number | Object} value Value for the trigger. String or number recommended. Object passed in will be converted to a string. + */ + @Cordova({ + sync: true, + }) + addTrigger(key: string, value: string | number | Object): void {} + + /** + * Add a map of triggers. May show an In-App Message if its trigger conditions were met. + * + * @param {Object.} triggers Allows you to set multiple trigger key/value pairs simultaneously. Pass a json object with key/value pairs like: `{"key": "value", "key2": "value2"}`. + */ + @Cordova({ + sync: true, + }) + addTriggers(triggers: Object): void {} + + /** + * Removes a single trigger for the given key. May show an In-App Message if its trigger conditions were met. + * + * @param {string} key Key for trigger to remove. + */ + @Cordova({ + sync: true, + }) + removeTriggerForKey(key: string): void {} + + /** + * Removes a list of triggers based on a collection (array) of keys. May show an In-App Message if its trigger conditions were met. + * + * @param {string[]} keys Removes a collection of triggers from their keys. Pass an array of trigger keys like: `["key1", "key2", "key3"]`. + */ + @Cordova({ + sync: true, + }) + removeTriggersForKeys(keys: string[]): void {} + + /** + * Gets a trigger value for a provided trigger key. + * + * @param {string} key Key for trigger to get value. + * @returns {Promise} Return value set with `addTrigger`, or `null`/`nil` (iOS) if never set or removed. + */ + @Cordova() + getTriggerValueForKey(key: string): Promise { + return; + } + + /** + * Allows you to temporarily pause all In-App Messages. You may want to do this while the user is engaged in an activity that you don't want a message to interrupt (such as watching a video). + * An In-App Message that would display if not paused will display right after resume if its conditions to display remains satisfied. + * + * @param {boolean} pause To pause, set `true`. To resume, set `false`. + */ + @Cordova({ + sync: true, + }) + pauseInAppMessages(pause: boolean): void {} }