-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathNativeRNIterableAPI.ts
More file actions
140 lines (122 loc) · 4.05 KB
/
NativeRNIterableAPI.ts
File metadata and controls
140 lines (122 loc) · 4.05 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
export interface Spec extends TurboModule {
// Initialization
initializeWithApiKey(
apiKey: string,
config: { [key: string]: string | number | boolean | undefined | string[] },
version: string
): Promise<boolean>;
initialize2WithApiKey(
apiKey: string,
config: { [key: string]: string | number | boolean | undefined | string[] },
version: string,
apiEndPointOverride: string
): Promise<boolean>;
// User management
setEmail(email: string | null, authToken?: string | null): void;
getEmail(): Promise<string | null>;
setUserId(userId?: string | null, authToken?: string | null): void;
getUserId(): Promise<string | null | undefined>;
// In-app messaging
setInAppShowResponse(number: number): void;
getInAppMessages(): Promise<{ [key: string]: string | number | boolean }[]>;
getInboxMessages(): Promise<{ [key: string]: string | number | boolean }[]>;
getUnreadInboxMessagesCount(): Promise<number>;
showMessage(messageId: string, consume: boolean): Promise<string | null>;
removeMessage(messageId: string, location: number, source: number): void;
setReadForMessage(messageId: string, read: boolean): void;
setAutoDisplayPaused(autoDisplayPaused: boolean): void;
// Tracking
trackEvent(
name: string,
dataFields?: { [key: string]: string | number | boolean }
): void;
trackPushOpenWithCampaignId(
campaignId: number,
templateId: number | null,
messageId: string,
appAlreadyRunning: boolean,
dataFields?: { [key: string]: string | number | boolean }
): void;
trackInAppOpen(messageId: string, location: number): void;
trackInAppClick(
messageId: string,
location: number,
clickedUrl: string
): void;
trackInAppClose(
messageId: string,
location: number,
source: number,
clickedUrl?: string | null
): void;
inAppConsume(messageId: string, location: number, source: number): void;
// Commerce
updateCart(items: { [key: string]: string | number | boolean }[]): void;
trackPurchase(
total: number,
items: { [key: string]: string | number | boolean }[],
dataFields?: { [key: string]: string | number | boolean }
): void;
// User data
updateUser(
dataFields: { [key: string]: string | number | boolean },
mergeNestedObjects: boolean
): void;
updateEmail(email: string, authToken?: string): void;
// Attribution
getAttributionInfo(): Promise<{
[key: string]: string | number | boolean;
} | null>;
setAttributionInfo(
dict: { [key: string]: string | number | boolean } | null
): void;
// Device management
disableDeviceForCurrentUser(): void;
getLastPushPayload(): Promise<{
[key: string]: string | number | boolean;
} | null>;
// Content
getHtmlInAppContentForMessage(
messageId: string
): Promise<{ [key: string]: string | number | boolean }>;
// App links
handleAppLink(appLink: string): Promise<boolean>;
// Subscriptions
updateSubscriptions(
emailListIds: number[] | null,
unsubscribedChannelIds: number[] | null,
unsubscribedMessageTypeIds: number[] | null,
subscribedMessageTypeIds: number[] | null,
campaignId: number,
templateId: number
): void;
// Session tracking
startSession(
visibleRows: { [key: string]: string | number | boolean }[]
): void;
endSession(): void;
updateVisibleRows(
visibleRows: { [key: string]: string | number | boolean }[]
): void;
// Auth
passAlongAuthToken(authToken?: string | null): void;
pauseAuthRetries(pauseRetry: boolean): void;
// Wake app -- android only
wakeApp(): void;
// REQUIRED for RCTEventEmitter
addListener(eventName: string): void;
removeListeners(count: number): void;
}
// Check if we're in a test environment
const isTestEnvironment = () => {
return (
typeof jest !== 'undefined' ||
process.env.NODE_ENV === 'test' ||
process.env.JEST_WORKER_ID !== undefined
);
};
export default isTestEnvironment()
? undefined
: TurboModuleRegistry.getEnforcing<Spec>('RNIterableAPI');