@altcraft/react-native-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +46 -0
- package/Sdk.podspec +48 -0
- package/android/build.gradle +78 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +1242 -0
- package/android/src/main/java/com/altcraft/sdk/SdkPackage.kt +33 -0
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnFCMProvider.kt +27 -0
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnHMSProvider.kt +32 -0
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnJWTProvider.kt +21 -0
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnRustoreProvider.kt +53 -0
- package/ios/Sdk.h +19 -0
- package/ios/Sdk.mm +1112 -0
- package/ios/SdkModule.swift +888 -0
- package/ios/protocols/RNAPNSProvider.swift +15 -0
- package/ios/protocols/RNFCMProvider.swift +24 -0
- package/ios/protocols/RNHMSProvider.swift +24 -0
- package/ios/protocols/RNJWTProvider.swift +15 -0
- package/lib/module/NativeSdk.js +13 -0
- package/lib/module/NativeSdk.js.map +1 -0
- package/lib/module/index.js +561 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeSdk.d.ts +114 -0
- package/lib/typescript/src/NativeSdk.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +391 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +128 -0
- package/react-native.config.js +10 -0
- package/src/NativeSdk.ts +171 -0
- package/src/index.tsx +670 -0
package/src/NativeSdk.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { TurboModuleRegistry, type TurboModule } from 'react-native';
|
|
2
|
+
|
|
3
|
+
// ---------------- Data models ----------------
|
|
4
|
+
|
|
5
|
+
export type CategoryData = {
|
|
6
|
+
name?: string | null;
|
|
7
|
+
title?: string | null;
|
|
8
|
+
steady?: boolean | null;
|
|
9
|
+
active?: boolean | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type SubscriptionData = {
|
|
13
|
+
subscriptionId?: string | null;
|
|
14
|
+
hashId?: string | null;
|
|
15
|
+
provider?: string | null;
|
|
16
|
+
status?: string | null;
|
|
17
|
+
|
|
18
|
+
fields?: { [key: string]: string } | null;
|
|
19
|
+
|
|
20
|
+
cats?: CategoryData[] | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ProfileData {
|
|
24
|
+
id?: string | null;
|
|
25
|
+
status?: string | null;
|
|
26
|
+
isTest?: boolean | null;
|
|
27
|
+
subscription?: SubscriptionData | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Response {
|
|
31
|
+
error?: number | null;
|
|
32
|
+
errorText?: string | null;
|
|
33
|
+
profile?: ProfileData | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ResponseWithHttpCode {
|
|
37
|
+
httpCode: number | null;
|
|
38
|
+
response: Response | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface AppInfo {
|
|
42
|
+
appID: string;
|
|
43
|
+
appIID: string;
|
|
44
|
+
appVer: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface AltcraftConfig {
|
|
48
|
+
apiUrl: string;
|
|
49
|
+
rToken?: string | null;
|
|
50
|
+
appInfo?: AppInfo | null;
|
|
51
|
+
providerPriorityList?: string[] | null;
|
|
52
|
+
enableLogging?: boolean | null;
|
|
53
|
+
|
|
54
|
+
// -------- ANDROID-ONLY --------
|
|
55
|
+
android_icon?: number | null;
|
|
56
|
+
android_usingService?: boolean | null;
|
|
57
|
+
android_serviceMessage?: string | null;
|
|
58
|
+
android_pushReceiverModules?: string[] | null;
|
|
59
|
+
android_pushChannelName?: string | null;
|
|
60
|
+
android_pushChannelDescription?: string | null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface TokenData {
|
|
64
|
+
provider: string | null;
|
|
65
|
+
token: string | null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ---------------- TurboModule Spec ----------------
|
|
69
|
+
|
|
70
|
+
export interface Spec extends TurboModule {
|
|
71
|
+
// init
|
|
72
|
+
initialize(config: AltcraftConfig): Promise<void>;
|
|
73
|
+
|
|
74
|
+
// auth
|
|
75
|
+
setJwt(token: string | null): void;
|
|
76
|
+
|
|
77
|
+
// platform-specific token setters
|
|
78
|
+
setAndroidFcmToken(token: string | null): void;
|
|
79
|
+
setAndroidHmsToken(token: string | null): void;
|
|
80
|
+
|
|
81
|
+
setIosFcmToken(token: string | null): void;
|
|
82
|
+
setIosHmsToken(token: string | null): void;
|
|
83
|
+
|
|
84
|
+
// other tokens
|
|
85
|
+
setApnsToken(token: string | null): void; // iOS-only (no-op on Android)
|
|
86
|
+
setRustoreToken(token: string | null): void; // Android-only (no-op on iOS)
|
|
87
|
+
|
|
88
|
+
// subscription (✅ string maps in spec)
|
|
89
|
+
pushSubscribe(
|
|
90
|
+
sync: boolean | null,
|
|
91
|
+
profileFields: { [key: string]: string } | null,
|
|
92
|
+
customFields: { [key: string]: string } | null,
|
|
93
|
+
cats: CategoryData[] | null,
|
|
94
|
+
replace: boolean | null,
|
|
95
|
+
skipTriggers: boolean | null
|
|
96
|
+
): void;
|
|
97
|
+
|
|
98
|
+
pushSuspend(
|
|
99
|
+
sync: boolean | null,
|
|
100
|
+
profileFields: { [key: string]: string } | null,
|
|
101
|
+
customFields: { [key: string]: string } | null,
|
|
102
|
+
cats: CategoryData[] | null,
|
|
103
|
+
replace: boolean | null,
|
|
104
|
+
skipTriggers: boolean | null
|
|
105
|
+
): void;
|
|
106
|
+
|
|
107
|
+
pushUnSubscribe(
|
|
108
|
+
sync: boolean | null,
|
|
109
|
+
profileFields: { [key: string]: string } | null,
|
|
110
|
+
customFields: { [key: string]: string } | null,
|
|
111
|
+
cats: CategoryData[] | null,
|
|
112
|
+
replace: boolean | null,
|
|
113
|
+
skipTriggers: boolean | null
|
|
114
|
+
): void;
|
|
115
|
+
|
|
116
|
+
unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null>;
|
|
117
|
+
getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null>;
|
|
118
|
+
getStatusOfLatestSubscriptionForProvider(
|
|
119
|
+
provider: string | null
|
|
120
|
+
): Promise<ResponseWithHttpCode | null>;
|
|
121
|
+
getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null>;
|
|
122
|
+
|
|
123
|
+
// push payload (string-only)
|
|
124
|
+
takePush(message: { [key: string]: string } | null): void;
|
|
125
|
+
|
|
126
|
+
// events
|
|
127
|
+
subscribeToEvents(): void;
|
|
128
|
+
unsubscribeFromEvent(): void;
|
|
129
|
+
|
|
130
|
+
// required for NativeEventEmitter
|
|
131
|
+
addListener(eventName: string): void;
|
|
132
|
+
removeListeners(count: number): void;
|
|
133
|
+
|
|
134
|
+
// token API
|
|
135
|
+
getPushToken(): Promise<TokenData | null>;
|
|
136
|
+
deleteDeviceToken(provider: string | null): Promise<void>;
|
|
137
|
+
forcedTokenUpdate(): Promise<void>;
|
|
138
|
+
changePushProviderPriorityList(priorityList: string[] | null): Promise<void>;
|
|
139
|
+
setPushToken(provider: string, token: string | null): Promise<void>;
|
|
140
|
+
|
|
141
|
+
// sdk
|
|
142
|
+
clear(): Promise<void>;
|
|
143
|
+
reinitializeRetryControlInThisSession(): void;
|
|
144
|
+
requestNotificationPermission(): void;
|
|
145
|
+
|
|
146
|
+
// mobile events (✅ string maps in spec)
|
|
147
|
+
mobileEvent(
|
|
148
|
+
sid: string,
|
|
149
|
+
eventName: string,
|
|
150
|
+
sendMessageId: string | null,
|
|
151
|
+
payload: { [key: string]: string } | null,
|
|
152
|
+
matching: { [key: string]: string } | null,
|
|
153
|
+
matchingType: string | null,
|
|
154
|
+
profileFields: { [key: string]: string } | null
|
|
155
|
+
): void;
|
|
156
|
+
|
|
157
|
+
deliveryEvent(
|
|
158
|
+
message: { [key: string]: string } | null,
|
|
159
|
+
messageUID: string | null
|
|
160
|
+
): void;
|
|
161
|
+
|
|
162
|
+
openEvent(
|
|
163
|
+
message: { [key: string]: string } | null,
|
|
164
|
+
messageUID: string | null
|
|
165
|
+
): void;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ---------------- Export ----------------
|
|
169
|
+
|
|
170
|
+
const NativeSDK = TurboModuleRegistry.getEnforcing<Spec>('Sdk');
|
|
171
|
+
export default NativeSDK;
|