forked from aemr3/nativescript-intercom-bridge
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathintercom-bridge.ios.ts
87 lines (69 loc) · 2.28 KB
/
intercom-bridge.ios.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
declare var Intercom: any;
export class IntercomBridge {
static init(apiKey: string, appId: string) {
Intercom.setApiKeyForAppId(apiKey, appId);
}
static registerIdentifiedUser(options: {userId?: string|number, email?: string}) {
if (typeof options.userId == 'number') {
options.userId = String(options.userId);
}
if (options.userId && options.email && options.userId.length > 0 && options.email.length > 0) {
Intercom.registerUserWithUserIdEmail(options.userId, options.email);
} else if (options.userId && options.userId.length > 0) {
Intercom.registerUserWithUserId(options.userId);
} else if (options.email && options.email.length > 0) {
Intercom.registerUserWithEmail(options.email);
} else {
console.log('[Intercom-NativeScript] ERROR - No user registered. You must supply an email, a userId or both');
}
}
static registerUnidentifiedUser() {
Intercom.registerUnidentifiedUser();
}
static reset() {
Intercom.reset();
}
static setSecureMode(secureHash: string, secureData: string) {
Intercom.setHMACData(secureHash, secureData);
}
static setUserHash(hmac: string) {
Intercom.setUserHash(hmac);
}
static updateUser(attributes: any) {
Intercom.updateUserWithAttributes(attributes);
}
static logEvent(eventName:string, metaData?: any) {
if (metaData && metaData.length) {
Intercom.logEventWithNameMetaData(eventName, metaData);
} else {
Intercom.logEventWithName(eventName);
}
}
static displayMessenger() {
Intercom.presentMessenger();
}
static displayMessageComposer() {
Intercom.presentMessageComposer();
}
static displayMessageComposerWithInitialMessage(initialMessage: string) {
Intercom.presentMessageComposerWithInitialMessage(initialMessage);
}
static displayConversationsList() {
Intercom.presentConversationList();
}
static unreadConversationCount() {
return Intercom.unreadConversationCount();
}
static setLauncherVisibility(visible: boolean) {
Intercom.setLauncherVisible(visible);
}
static setInAppMessageVisibility(visible: boolean) {
Intercom.setInAppMessagesVisible(visible);
}
static hideMessenger() {
Intercom.hideMessenger();
}
static enableLogging() {
Intercom.enableLogging();
}
}