Skip to content

Commit eec3fec

Browse files
feat(onesignal): add in-app messages methods (#3481)
1 parent a010bb1 commit eec3fec

File tree

1 file changed

+98
-0
lines changed
  • src/@ionic-native/plugins/onesignal

1 file changed

+98
-0
lines changed

src/@ionic-native/plugins/onesignal/index.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,28 @@ export enum OSActionType {
303303
ActionTake = 1,
304304
}
305305

306+
/**
307+
* Details about the In-App Message action element (button or image) that was tapped on.
308+
*/
309+
export interface OSInAppMessageAction {
310+
/**
311+
* An optional click name defined for the action element. null or nil (iOS) if not set.
312+
*/
313+
click_name: string;
314+
/**
315+
* An optional URL that opens when the action takes place. null or nil (iOS) if not set.
316+
*/
317+
click_url: string;
318+
/**
319+
* `true` if this is the first time the user has pressed any action on the In-App Message.
320+
*/
321+
first_click: boolean;
322+
/**
323+
* 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.
324+
*/
325+
closes_message: boolean;
326+
}
327+
306328
/**
307329
* @name OneSignal
308330
* @description
@@ -406,6 +428,7 @@ export enum OSActionType {
406428
* OSBackgroundImageLayout
407429
* OSNotificationOpenedResult
408430
* OSActionType
431+
* OSInAppMessageAction
409432
*/
410433
@Plugin({
411434
pluginName: 'OneSignal',
@@ -464,6 +487,18 @@ export class OneSignal extends IonicNativePlugin {
464487
return;
465488
}
466489

490+
/**
491+
* Use to process an In-App Message the user just tapped on.
492+
*
493+
* @return {Observable<OSInAppMessageAction>}
494+
*/
495+
@Cordova({
496+
observable: true,
497+
})
498+
handleInAppMessageClicked(): Observable<OSInAppMessageAction> {
499+
return;
500+
}
501+
467502
/**
468503
* **iOS** - Settings for iOS apps
469504
*
@@ -781,4 +816,67 @@ export class OneSignal extends IonicNativePlugin {
781816
*/
782817
@Cordova()
783818
removeExternalUserId(): void {}
819+
820+
/**
821+
* Add a trigger. May show an In-App Message if its trigger conditions were met.
822+
*
823+
* @param {string} key Key for the trigger.
824+
* @param {string | number | Object} value Value for the trigger. String or number recommended. Object passed in will be converted to a string.
825+
*/
826+
@Cordova({
827+
sync: true,
828+
})
829+
addTrigger(key: string, value: string | number | Object): void {}
830+
831+
/**
832+
* Add a map of triggers. May show an In-App Message if its trigger conditions were met.
833+
*
834+
* @param {Object.<string, string | number | 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"}`.
835+
*/
836+
@Cordova({
837+
sync: true,
838+
})
839+
addTriggers(triggers: Object): void {}
840+
841+
/**
842+
* Removes a single trigger for the given key. May show an In-App Message if its trigger conditions were met.
843+
*
844+
* @param {string} key Key for trigger to remove.
845+
*/
846+
@Cordova({
847+
sync: true,
848+
})
849+
removeTriggerForKey(key: string): void {}
850+
851+
/**
852+
* Removes a list of triggers based on a collection (array) of keys. May show an In-App Message if its trigger conditions were met.
853+
*
854+
* @param {string[]} keys Removes a collection of triggers from their keys. Pass an array of trigger keys like: `["key1", "key2", "key3"]`.
855+
*/
856+
@Cordova({
857+
sync: true,
858+
})
859+
removeTriggersForKeys(keys: string[]): void {}
860+
861+
/**
862+
* Gets a trigger value for a provided trigger key.
863+
*
864+
* @param {string} key Key for trigger to get value.
865+
* @returns {Promise<string | number | Object>} Return value set with `addTrigger`, or `null`/`nil` (iOS) if never set or removed.
866+
*/
867+
@Cordova()
868+
getTriggerValueForKey(key: string): Promise<string | number | Object> {
869+
return;
870+
}
871+
872+
/**
873+
* 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).
874+
* An In-App Message that would display if not paused will display right after resume if its conditions to display remains satisfied.
875+
*
876+
* @param {boolean} pause To pause, set `true`. To resume, set `false`.
877+
*/
878+
@Cordova({
879+
sync: true,
880+
})
881+
pauseInAppMessages(pause: boolean): void {}
784882
}

0 commit comments

Comments
 (0)