-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathNativeRNIterableAPI.ts
More file actions
160 lines (141 loc) · 4.85 KB
/
NativeRNIterableAPI.ts
File metadata and controls
160 lines (141 loc) · 4.85 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* eslint-disable @typescript-eslint/no-wrapper-object-types */
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
// NOTE: No types can be imported because of the way new arch works, so we have
// to re-define the types here.
// Codegen (RN 0.84+) rejects unions that include array types (e.g. `T[] | U`,
// `string | string[]`). Use capital `Object` (not TS `object`) for loose maps;
// lowercase `object` is TSObjectKeyword and fails iOS/Android codegen.
export interface Spec extends TurboModule {
// Initialization
initializeWithApiKey(
apiKey: string,
config: Object,
version: string
): Promise<boolean>;
initialize2WithApiKey(
apiKey: string,
config: Object,
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 (arrays only in spec — RN codegen rejects `T[] | null`; callers
// may still pass null at the bridge when using typed assertions.)
updateSubscriptions(
emailListIds: number[],
unsubscribedChannelIds: number[],
unsubscribedMessageTypeIds: number[],
subscribedMessageTypeIds: number[],
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;
// Embedded Messaging
syncEmbeddedMessages(): void;
startEmbeddedSession(): void;
endEmbeddedSession(): void;
startEmbeddedImpression(messageId: string, placementId: number): void;
pauseEmbeddedImpression(messageId: string): void;
getEmbeddedMessages(placementIds: number[]): Promise<Object[]>;
trackEmbeddedClick(
message: Object,
buttonId: string | null,
clickedUrl: string | null
): 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');