Skip to content

Commit

Permalink
feat(MobileMessaging): add support for CustomEvents (#3373)
Browse files Browse the repository at this point in the history
* feat(MobileMessaging): add methods for CustomEvents support

* fix(MobileMessaging) change customAttributes type

* fix(MobileMessaging): change methods return type

Co-authored-by: Konstantin Latypov <Konstantin.Latypov@infobip.com>
  • Loading branch information
kostap13 and Konstantin Latypov committed Apr 9, 2020
1 parent 739fe89 commit 3af9c48
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions src/@ionic-native/plugins/mobile-messaging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export type Event =
| 'personalized'
| 'depersonalized';

export interface CustomEvent {
definitionId: string;
properties: Record<string, string | number | boolean>;
}

export interface Configuration {
/**
* The application code of your Application from Push Portal website
Expand Down Expand Up @@ -73,7 +78,7 @@ export interface UserData {
phones?: string[];
emails?: string[];
tags?: string[];
customAttributes?: Record<string, string>;
customAttributes?: Record<string, string | number | boolean>;
}

export interface Installation {
Expand All @@ -92,7 +97,7 @@ export interface Installation {
deviceTimezoneId?: string;
applicationUserId?: string;
deviceName?: string;
customAttributes?: Record<string, string>;
customAttributes?: Record<string, string | number | boolean>;
}

export interface UserIdentity {
Expand Down Expand Up @@ -258,6 +263,53 @@ export class MobileMessaging extends IonicNativePlugin {
return;
}

/**
* Sends an event to the server eventually, handles possible errors and do retries for you.
*
* @name submitEvent
* @param {Object} eventData. An object containing event data
* {
* definitionId: "eventDefinitionId"
* properties: {
* "stringAttribute": "string",
* "numberAttribute": 1,
* "dateAttribute": "2020-02-26T09:41:57Z",
* "booleanAttribute": true
* }
* }
*/
@Cordova({
sync: true
})
submitEvent(event: CustomEvent): void {
return;
}


/**
* Sends an event to the server immediately.
* You have to handle possible connection or server errors, do retries yourself.
*
* @name submitEventImmediately
* @param {Object} eventData. An object containing event data
* {
* definitionId: "eventDefinitionId"
* properties: {
* "stringAttribute": "string",
* "numberAttribute": 1,
* "dateAttribute": "2020-02-26T09:41:57Z",
* "booleanAttribute": true
* }
* }
* @param {Function} callback will be called on result, you have to handle error and do retries yourself
*/
@Cordova({
observable: true
})
submitEventImmediately(event: CustomEvent): Promise<void> {
return;
}

/**
* Saves user data to the server.
*
Expand Down

0 comments on commit 3af9c48

Please sign in to comment.