Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(MobileMessaging): add support for CustomEvents #3373

Merged
merged 3 commits into from
Apr 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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