@altcraft/react-native-sdk 0.0.2 → 0.0.4
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 -20
- package/README.md +119 -27
- package/Sdk.podspec +2 -2
- package/android/build.gradle +3 -4
- package/android/src/main/java/com/altcraft/sdk/SdkEventEmitter.kt +50 -0
- package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +663 -480
- package/android/src/main/java/com/altcraft/sdk/SdkPackage.kt +16 -8
- package/android/src/main/java/com/altcraft/sdk/utilities/Converter.kt +164 -0
- package/android/src/main/java/com/altcraft/sdk/utilities/Extension.kt +72 -0
- package/ios/Converter.swift +485 -48
- package/ios/Sdk.mm +195 -270
- package/ios/SdkModule.swift +456 -507
- package/lib/module/NativeSdk.js +35 -0
- package/lib/module/NativeSdk.js.map +1 -1
- package/lib/module/Utilities.js +178 -0
- package/lib/module/Utilities.js.map +1 -0
- package/lib/module/index.js +335 -245
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeSdk.d.ts +125 -33
- package/lib/typescript/src/NativeSdk.d.ts.map +1 -1
- package/lib/typescript/src/Utilities.d.ts +47 -0
- package/lib/typescript/src/Utilities.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +218 -94
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeSdk.ts +169 -46
- package/src/Utilities.ts +180 -0
- package/src/index.tsx +410 -312
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnFCMProvider.kt +0 -26
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnHMSProvider.kt +0 -32
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnJWTProvider.kt +0 -21
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnRustoreProvider.kt +0 -53
- package/ios/protocols/RNAPNSProvider.swift +0 -15
- package/ios/protocols/RNFCMProvider.swift +0 -24
- package/ios/protocols/RNHMSProvider.swift +0 -24
- package/ios/protocols/RNJWTProvider.swift +0 -15
package/ios/Sdk.mm
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Sdk.mm
|
|
2
|
+
|
|
2
3
|
#import "Sdk.h"
|
|
3
4
|
|
|
4
5
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
@@ -23,7 +24,6 @@
|
|
|
23
24
|
#if __has_include(<React/RCTCallableJSModules.h>)
|
|
24
25
|
#import <React/RCTCallableJSModules.h>
|
|
25
26
|
#else
|
|
26
|
-
/// Minimal protocol for calling JS from native when headers are not available.
|
|
27
27
|
@protocol RCTCallableJSModules <NSObject>
|
|
28
28
|
- (void)invokeModule:(NSString *)moduleName
|
|
29
29
|
method:(NSString *)methodName
|
|
@@ -32,12 +32,10 @@
|
|
|
32
32
|
#endif
|
|
33
33
|
|
|
34
34
|
#ifndef RCTPromiseResolveBlock
|
|
35
|
-
/// React Native promise resolver.
|
|
36
35
|
typedef void (^RCTPromiseResolveBlock)(id _Nullable result);
|
|
37
36
|
#endif
|
|
38
37
|
|
|
39
38
|
#ifndef RCTPromiseRejectBlock
|
|
40
|
-
/// React Native promise rejecter.
|
|
41
39
|
typedef void (^RCTPromiseRejectBlock)(NSString * _Nonnull code,
|
|
42
40
|
NSString * _Nullable message,
|
|
43
41
|
NSError * _Nullable error);
|
|
@@ -45,36 +43,30 @@ typedef void (^RCTPromiseRejectBlock)(NSString * _Nonnull code,
|
|
|
45
43
|
|
|
46
44
|
#pragma mark - Runtime helpers
|
|
47
45
|
|
|
48
|
-
/// Builds selector from string.
|
|
49
46
|
static SEL SdkSel(NSString *name) {
|
|
50
47
|
return NSSelectorFromString(name);
|
|
51
48
|
}
|
|
52
49
|
|
|
53
|
-
/// Returns YES if instance responds to selector.
|
|
54
50
|
static BOOL SdkResponds(id obj, SEL sel) {
|
|
55
51
|
return obj && sel && [obj respondsToSelector:sel];
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
/// Returns YES if class responds to selector.
|
|
59
54
|
static BOOL SdkClassResponds(Class cls, SEL sel) {
|
|
60
55
|
return cls && sel && [cls respondsToSelector:sel];
|
|
61
56
|
}
|
|
62
57
|
|
|
63
58
|
#pragma mark - NSNull -> nil
|
|
64
59
|
|
|
65
|
-
/// Converts NSNull / kCFNull to nil (keeps other values as-is).
|
|
66
60
|
static inline id SdkNilIfNSNull(id v) {
|
|
67
61
|
return (v == (id)kCFNull || [v isKindOfClass:[NSNull class]]) ? nil : v;
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
#pragma mark - Swift runtime bridge (no Sdk-Swift.h needed)
|
|
71
65
|
|
|
72
|
-
/// Returns SdkModule class if present (resolved by name at runtime).
|
|
73
66
|
static Class SdkAppModuleClass(void) {
|
|
74
67
|
Class cls = NSClassFromString(@"SdkModule");
|
|
75
68
|
|
|
76
69
|
#ifdef DEBUG
|
|
77
|
-
// Debug-only: attempt to discover module name with namespace suffix.
|
|
78
70
|
if (!cls) {
|
|
79
71
|
int count = objc_getClassList(NULL, 0);
|
|
80
72
|
if (count > 0) {
|
|
@@ -99,7 +91,6 @@ static Class SdkAppModuleClass(void) {
|
|
|
99
91
|
return cls;
|
|
100
92
|
}
|
|
101
93
|
|
|
102
|
-
/// Returns shared Swift module instance via +[SdkModule shared].
|
|
103
94
|
static id SdkAppModuleSharedInstance(void) {
|
|
104
95
|
Class cls = SdkAppModuleClass();
|
|
105
96
|
if (!cls) return nil;
|
|
@@ -114,7 +105,6 @@ static id SdkAppModuleSharedInstance(void) {
|
|
|
114
105
|
return func((id)cls, sel);
|
|
115
106
|
}
|
|
116
107
|
|
|
117
|
-
/// Ensures push providers are installed/configured inside Swift module.
|
|
118
108
|
static void EnsureProvidersInstalled(id instance) {
|
|
119
109
|
if (!instance) return;
|
|
120
110
|
|
|
@@ -128,35 +118,8 @@ static void EnsureProvidersInstalled(id instance) {
|
|
|
128
118
|
func(instance, sel);
|
|
129
119
|
}
|
|
130
120
|
|
|
131
|
-
|
|
132
|
-
static void CallSetToken(id instance, NSString *selectorName, NSString * _Nullable token) {
|
|
133
|
-
if (!instance) return;
|
|
134
|
-
|
|
135
|
-
SEL sel = SdkSel(selectorName);
|
|
136
|
-
if (!SdkResponds(instance, sel)) return;
|
|
137
|
-
|
|
138
|
-
IMP imp = [instance methodForSelector:sel];
|
|
139
|
-
if (!imp) return;
|
|
140
|
-
|
|
141
|
-
void (*func)(id, SEL, id) = (void (*)(id, SEL, id))imp;
|
|
142
|
-
func(instance, sel, token);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/// Sets App Group name on Swift module.
|
|
146
|
-
static void CallSetAppGroup(id instance, NSString * _Nullable groupName) {
|
|
147
|
-
if (!instance) return;
|
|
148
|
-
|
|
149
|
-
SEL sel = SdkSel(@"setAppGroupWithName:");
|
|
150
|
-
if (!SdkResponds(instance, sel)) return;
|
|
151
|
-
|
|
152
|
-
IMP imp = [instance methodForSelector:sel];
|
|
153
|
-
if (!imp) return;
|
|
154
|
-
|
|
155
|
-
void (*func)(id, SEL, id) = (void (*)(id, SEL, id))imp;
|
|
156
|
-
func(instance, sel, groupName);
|
|
157
|
-
}
|
|
121
|
+
#pragma mark - Swift calls (UserDefaults)
|
|
158
122
|
|
|
159
|
-
///Stores a value in UserDefaults via Swift module.
|
|
160
123
|
static void CallSetUserDefaultsValue(id instance,
|
|
161
124
|
NSString * _Nullable suiteName,
|
|
162
125
|
NSString *key,
|
|
@@ -173,21 +136,8 @@ static void CallSetUserDefaultsValue(id instance,
|
|
|
173
136
|
func(instance, sel, suiteName, key, value);
|
|
174
137
|
}
|
|
175
138
|
|
|
176
|
-
|
|
177
|
-
static void CallDeleteDeviceToken(id instance, NSString * _Nullable provider, void (^completion)(BOOL ok)) {
|
|
178
|
-
if (!instance) { completion(NO); return; }
|
|
179
|
-
|
|
180
|
-
SEL sel = SdkSel(@"deleteDeviceTokenWithProvider:completion:");
|
|
181
|
-
if (!SdkResponds(instance, sel)) { completion(NO); return; }
|
|
182
|
-
|
|
183
|
-
IMP imp = [instance methodForSelector:sel];
|
|
184
|
-
if (!imp) { completion(NO); return; }
|
|
185
|
-
|
|
186
|
-
void (*func)(id, SEL, id, id) = (void (*)(id, SEL, id, id))imp;
|
|
187
|
-
func(instance, sel, provider, completion);
|
|
188
|
-
}
|
|
139
|
+
#pragma mark - Push token API (ONLY getPushToken / setPushToken)
|
|
189
140
|
|
|
190
|
-
/// Retrieves current push token from Swift module.
|
|
191
141
|
static void CallGetPushToken(id instance, void (^completion)(id _Nullable tokenObjC)) {
|
|
192
142
|
if (!instance) { completion(nil); return; }
|
|
193
143
|
|
|
@@ -201,35 +151,6 @@ static void CallGetPushToken(id instance, void (^completion)(id _Nullable tokenO
|
|
|
201
151
|
func(instance, sel, completion);
|
|
202
152
|
}
|
|
203
153
|
|
|
204
|
-
/// Forces token update on Swift module.
|
|
205
|
-
static void CallForcedTokenUpdate(id instance, void (^completion)(void)) {
|
|
206
|
-
if (!instance) { completion(); return; }
|
|
207
|
-
|
|
208
|
-
SEL sel = SdkSel(@"forcedTokenUpdateWithCompletion:");
|
|
209
|
-
if (!SdkResponds(instance, sel)) { completion(); return; }
|
|
210
|
-
|
|
211
|
-
IMP imp = [instance methodForSelector:sel];
|
|
212
|
-
if (!imp) { completion(); return; }
|
|
213
|
-
|
|
214
|
-
void (*func)(id, SEL, id) = (void (*)(id, SEL, id))imp;
|
|
215
|
-
func(instance, sel, completion);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/// Changes push provider priority list on Swift module.
|
|
219
|
-
static void CallChangeProviderPriorityList(id instance, NSArray * _Nullable list, void (^completion)(BOOL ok)) {
|
|
220
|
-
if (!instance) { completion(NO); return; }
|
|
221
|
-
|
|
222
|
-
SEL sel = SdkSel(@"changePushProviderPriorityListWithList:completion:");
|
|
223
|
-
if (!SdkResponds(instance, sel)) { completion(NO); return; }
|
|
224
|
-
|
|
225
|
-
IMP imp = [instance methodForSelector:sel];
|
|
226
|
-
if (!imp) { completion(NO); return; }
|
|
227
|
-
|
|
228
|
-
void (*func)(id, SEL, id, id) = (void (*)(id, SEL, id, id))imp;
|
|
229
|
-
func(instance, sel, list, completion);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/// Sets push token with provider on Swift module.
|
|
233
154
|
static void CallSetPushToken(id instance, NSString *provider, NSString * _Nullable token) {
|
|
234
155
|
if (!instance) return;
|
|
235
156
|
|
|
@@ -245,7 +166,6 @@ static void CallSetPushToken(id instance, NSString *provider, NSString * _Nullab
|
|
|
245
166
|
|
|
246
167
|
#pragma mark - Push subscription calls
|
|
247
168
|
|
|
248
|
-
/// Invokes subscription-related methods on Swift module.
|
|
249
169
|
static void CallPushSubscription(id instance,
|
|
250
170
|
NSString *selectorName,
|
|
251
171
|
NSNumber *sync,
|
|
@@ -268,9 +188,8 @@ static void CallPushSubscription(id instance,
|
|
|
268
188
|
func(instance, sel, sync, profileFields, customFields, cats, replace, skipTriggers);
|
|
269
189
|
}
|
|
270
190
|
|
|
271
|
-
#pragma mark - Mobile Event calls
|
|
191
|
+
#pragma mark - Mobile Event calls (with subscription param)
|
|
272
192
|
|
|
273
|
-
///Sends mobile event to Swift module (includes `utm`).
|
|
274
193
|
static void CallMobileEvent(id instance,
|
|
275
194
|
NSString *sid,
|
|
276
195
|
NSString *eventName,
|
|
@@ -279,24 +198,24 @@ static void CallMobileEvent(id instance,
|
|
|
279
198
|
NSDictionary * _Nullable matching,
|
|
280
199
|
NSString * _Nullable matchingType,
|
|
281
200
|
NSDictionary * _Nullable profileFields,
|
|
201
|
+
NSDictionary * _Nullable subscription,
|
|
282
202
|
NSDictionary * _Nullable utm) {
|
|
283
203
|
if (!instance) return;
|
|
284
204
|
|
|
285
|
-
SEL sel = SdkSel(@"mobileEvent:eventName:sendMessageId:payload:matching:matchingType:profileFields:utm:");
|
|
205
|
+
SEL sel = SdkSel(@"mobileEvent:eventName:sendMessageId:payload:matching:matchingType:profileFields:subscription:utm:");
|
|
286
206
|
if (!SdkResponds(instance, sel)) return;
|
|
287
207
|
|
|
288
208
|
IMP imp = [instance methodForSelector:sel];
|
|
289
209
|
if (!imp) return;
|
|
290
210
|
|
|
291
|
-
void (*func)(id, SEL, id, id, id, id, id, id, id, id) =
|
|
292
|
-
(void (*)(id, SEL, id, id, id, id, id, id, id, id))imp;
|
|
211
|
+
void (*func)(id, SEL, id, id, id, id, id, id, id, id, id) =
|
|
212
|
+
(void (*)(id, SEL, id, id, id, id, id, id, id, id, id))imp;
|
|
293
213
|
|
|
294
|
-
func(instance, sel, sid, eventName, sendMessageId, payload, matching, matchingType, profileFields, utm);
|
|
214
|
+
func(instance, sel, sid, eventName, sendMessageId, payload, matching, matchingType, profileFields, subscription, utm);
|
|
295
215
|
}
|
|
296
216
|
|
|
297
217
|
#pragma mark - Promise helpers
|
|
298
218
|
|
|
299
|
-
/// Calls a Swift method with signature (resolver, rejecter).
|
|
300
219
|
static void CallPromise0Args(id instance,
|
|
301
220
|
NSString *selectorName,
|
|
302
221
|
RCTPromiseResolveBlock resolve,
|
|
@@ -314,7 +233,6 @@ static void CallPromise0Args(id instance,
|
|
|
314
233
|
return;
|
|
315
234
|
}
|
|
316
235
|
|
|
317
|
-
// React Native expects promise calls on main thread.
|
|
318
236
|
if (![NSThread isMainThread]) {
|
|
319
237
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
320
238
|
CallPromise0Args(instance, selectorName, resolve, reject);
|
|
@@ -324,7 +242,6 @@ static void CallPromise0Args(id instance,
|
|
|
324
242
|
|
|
325
243
|
IMP imp = [instance methodForSelector:sel];
|
|
326
244
|
if (!imp) {
|
|
327
|
-
// Fallback for cases where methodForSelector returns NULL in mixed ObjC/Swift builds.
|
|
328
245
|
NSMethodSignature *sig = [instance methodSignatureForSelector:sel];
|
|
329
246
|
if (!sig) {
|
|
330
247
|
NSError *err = [NSError errorWithDomain:@"Sdk" code:20 userInfo:@{NSLocalizedDescriptionKey:@"No signature"}];
|
|
@@ -349,7 +266,6 @@ static void CallPromise0Args(id instance,
|
|
|
349
266
|
func(instance, sel, resolve, reject);
|
|
350
267
|
}
|
|
351
268
|
|
|
352
|
-
/// Calls a Swift method with signature (String?, resolver, rejecter).
|
|
353
269
|
static void CallPromise1StringArg(id instance,
|
|
354
270
|
NSString *selectorName,
|
|
355
271
|
NSString * _Nullable arg,
|
|
@@ -368,7 +284,6 @@ static void CallPromise1StringArg(id instance,
|
|
|
368
284
|
return;
|
|
369
285
|
}
|
|
370
286
|
|
|
371
|
-
// React Native expects promise calls on main thread.
|
|
372
287
|
if (![NSThread isMainThread]) {
|
|
373
288
|
NSString *a = arg;
|
|
374
289
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -407,7 +322,6 @@ static void CallPromise1StringArg(id instance,
|
|
|
407
322
|
|
|
408
323
|
#pragma mark - Initialize / Clear
|
|
409
324
|
|
|
410
|
-
/// Calls Swift initializer selector on the main thread.
|
|
411
325
|
static void CallInitializeBySelector(id instance,
|
|
412
326
|
SEL sel,
|
|
413
327
|
NSDictionary *config,
|
|
@@ -449,7 +363,6 @@ static void CallInitializeBySelector(id instance,
|
|
|
449
363
|
func(instance, sel, safeCfg, resolve, reject);
|
|
450
364
|
}
|
|
451
365
|
|
|
452
|
-
/// Initializes Swift module with config.
|
|
453
366
|
static void CallInitialize(id instance,
|
|
454
367
|
NSDictionary *config,
|
|
455
368
|
RCTPromiseResolveBlock resolve,
|
|
@@ -470,7 +383,6 @@ static void CallInitialize(id instance,
|
|
|
470
383
|
CallInitializeBySelector(instance, sel, config, resolve, reject);
|
|
471
384
|
}
|
|
472
385
|
|
|
473
|
-
/// Clears SDK state in Swift module.
|
|
474
386
|
static void CallClear(id instance,
|
|
475
387
|
RCTPromiseResolveBlock resolve,
|
|
476
388
|
RCTPromiseRejectBlock reject) {
|
|
@@ -487,7 +399,6 @@ struct SdkIsStdOptional : std::false_type {};
|
|
|
487
399
|
template <typename T>
|
|
488
400
|
struct SdkIsStdOptional<std::optional<T>> : std::true_type {};
|
|
489
401
|
|
|
490
|
-
/// Converts NSString* / optional NSString* to NSString* or nil.
|
|
491
402
|
template <typename T>
|
|
492
403
|
static NSString *SdkGetStringOrNil(const T &v) {
|
|
493
404
|
using D = std::decay_t<T>;
|
|
@@ -500,7 +411,6 @@ static NSString *SdkGetStringOrNil(const T &v) {
|
|
|
500
411
|
}
|
|
501
412
|
}
|
|
502
413
|
|
|
503
|
-
/// Converts bool / optional bool to NSNumber* or nil.
|
|
504
414
|
template <typename T>
|
|
505
415
|
static NSNumber *SdkGetBoolNumberOrNil(const T &v) {
|
|
506
416
|
using D = std::decay_t<T>;
|
|
@@ -515,7 +425,6 @@ static NSNumber *SdkGetBoolNumberOrNil(const T &v) {
|
|
|
515
425
|
|
|
516
426
|
#import <limits.h>
|
|
517
427
|
|
|
518
|
-
/// Converts LazyVector<NSString*> to NSArray (capped to INT_MAX).
|
|
519
428
|
static NSArray *SdkLazyVectorToNSArray(const facebook::react::LazyVector<NSString *> &vec) {
|
|
520
429
|
const size_t n = vec.size();
|
|
521
430
|
const size_t capped = (n > (size_t)INT_MAX) ? (size_t)INT_MAX : n;
|
|
@@ -529,7 +438,6 @@ static NSArray *SdkLazyVectorToNSArray(const facebook::react::LazyVector<NSStrin
|
|
|
529
438
|
return arr;
|
|
530
439
|
}
|
|
531
440
|
|
|
532
|
-
/// Converts LazyVector / optional LazyVector to NSArray* or nil.
|
|
533
441
|
template <typename T>
|
|
534
442
|
static NSArray *SdkGetStringArrayOrNil(const T &v) {
|
|
535
443
|
using D = std::decay_t<T>;
|
|
@@ -542,7 +450,6 @@ static NSArray *SdkGetStringArrayOrNil(const T &v) {
|
|
|
542
450
|
}
|
|
543
451
|
}
|
|
544
452
|
|
|
545
|
-
/// Converts appInfo struct to NSDictionary* or nil.
|
|
546
453
|
template <typename T>
|
|
547
454
|
static NSDictionary *SdkGetAppInfoDictOrNil(const T &v) {
|
|
548
455
|
using D = std::decay_t<T>;
|
|
@@ -567,7 +474,6 @@ static NSDictionary *SdkGetAppInfoDictOrNil(const T &v) {
|
|
|
567
474
|
}
|
|
568
475
|
}
|
|
569
476
|
|
|
570
|
-
/// Converts typed RN config to NSDictionary for Swift module.
|
|
571
477
|
static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::AltcraftConfig &cfg) {
|
|
572
478
|
NSString *apiUrl = cfg.apiUrl();
|
|
573
479
|
NSString *rToken = SdkGetStringOrNil(cfg.rToken());
|
|
@@ -584,6 +490,35 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
584
490
|
return dict;
|
|
585
491
|
}
|
|
586
492
|
|
|
493
|
+
#pragma mark - UTM typed (New Arch) -> NSDictionary
|
|
494
|
+
|
|
495
|
+
static inline NSString *SdkNonEmptyOrNil(NSString *s) {
|
|
496
|
+
if (!s) return nil;
|
|
497
|
+
return (s.length > 0) ? s : nil;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
static NSDictionary * _Nullable SdkConvertUTMToNSDictionary(JS::NativeSdk::UTM &utm) {
|
|
501
|
+
NSString *campaign = SdkNonEmptyOrNil(utm.campaign());
|
|
502
|
+
NSString *content = SdkNonEmptyOrNil(utm.content());
|
|
503
|
+
NSString *keyword = SdkNonEmptyOrNil(utm.keyword());
|
|
504
|
+
NSString *medium = SdkNonEmptyOrNil(utm.medium());
|
|
505
|
+
NSString *source = SdkNonEmptyOrNil(utm.source());
|
|
506
|
+
NSString *temp = SdkNonEmptyOrNil(utm.temp());
|
|
507
|
+
|
|
508
|
+
if (!campaign && !content && !keyword && !medium && !source && !temp) {
|
|
509
|
+
return nil;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return @{
|
|
513
|
+
@"campaign": campaign ?: (id)kCFNull,
|
|
514
|
+
@"content": content ?: (id)kCFNull,
|
|
515
|
+
@"keyword": keyword ?: (id)kCFNull,
|
|
516
|
+
@"medium": medium ?: (id)kCFNull,
|
|
517
|
+
@"source": source ?: (id)kCFNull,
|
|
518
|
+
@"temp": temp ?: (id)kCFNull,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
|
|
587
522
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
588
523
|
|
|
589
524
|
#pragma mark - Module implementation
|
|
@@ -591,7 +526,6 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
591
526
|
@implementation Sdk
|
|
592
527
|
|
|
593
528
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
594
|
-
/// Returns TurboModule instance for New Architecture.
|
|
595
529
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
596
530
|
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
597
531
|
{
|
|
@@ -599,11 +533,9 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
599
533
|
}
|
|
600
534
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
601
535
|
|
|
602
|
-
/// React Native module name.
|
|
603
536
|
+ (NSString *)moduleName { return @"Sdk"; }
|
|
604
537
|
|
|
605
538
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
606
|
-
/// Initializes SDK using typed config (New Architecture).
|
|
607
539
|
- (void)initialize:(JS::NativeSdk::AltcraftConfig &)config
|
|
608
540
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
609
541
|
reject:(RCTPromiseRejectBlock)reject
|
|
@@ -616,15 +548,11 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
616
548
|
}
|
|
617
549
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
618
550
|
|
|
619
|
-
/// Required by RN event emitter API (no-op).
|
|
620
551
|
- (void)addListener:(NSString *)eventName { (void)eventName; }
|
|
621
|
-
|
|
622
|
-
/// Required by RN event emitter API (no-op).
|
|
623
552
|
- (void)removeListeners:(double)count { (void)count; }
|
|
624
553
|
|
|
625
|
-
#pragma mark - Events API (Swift
|
|
554
|
+
#pragma mark - Events API (Swift emits; ObjC++ only forwards method calls)
|
|
626
555
|
|
|
627
|
-
/// Subscribes to SDK events in Swift layer (idempotent).
|
|
628
556
|
- (void)subscribeToEvents
|
|
629
557
|
{
|
|
630
558
|
id module = SdkAppModuleSharedInstance();
|
|
@@ -640,7 +568,6 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
640
568
|
func(module, sel);
|
|
641
569
|
}
|
|
642
570
|
|
|
643
|
-
/// Unsubscribes from SDK events in Swift layer (idempotent).
|
|
644
571
|
- (void)unsubscribeFromEvent
|
|
645
572
|
{
|
|
646
573
|
id module = SdkAppModuleSharedInstance();
|
|
@@ -656,65 +583,8 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
656
583
|
func(module, sel);
|
|
657
584
|
}
|
|
658
585
|
|
|
659
|
-
#pragma mark - Common (JWT / AppGroup)
|
|
660
|
-
|
|
661
|
-
/// Sets JWT used by SDK requests.
|
|
662
|
-
- (void)setJwt:(NSString * _Nullable)token {
|
|
663
|
-
id module = SdkAppModuleSharedInstance();
|
|
664
|
-
CallSetToken(module, @"setJWT:", token);
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/// Sets App Group name for shared storage.
|
|
668
|
-
- (void)setAppGroup:(NSString * _Nullable)groupName
|
|
669
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
670
|
-
reject:(RCTPromiseRejectBlock)reject
|
|
671
|
-
{
|
|
672
|
-
id module = SdkAppModuleSharedInstance();
|
|
673
|
-
if (!module) {
|
|
674
|
-
NSError *err = [NSError errorWithDomain:@"Sdk" code:1 userInfo:@{NSLocalizedDescriptionKey:@"SdkAppModule not found"}];
|
|
675
|
-
reject(@"SWIFT_MODULE_NOT_FOUND", @"SdkAppModule class not found", err);
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
CallSetAppGroup(module, groupName);
|
|
680
|
-
resolve((id)kCFNull);
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
#pragma mark - Platform-specific tokens
|
|
684
|
-
|
|
685
|
-
/// Android-only API stub (no-op on iOS).
|
|
686
|
-
- (void)setAndroidFcmToken:(NSString * _Nullable)token { (void)token; }
|
|
687
|
-
|
|
688
|
-
/// Android-only API stub (no-op on iOS).
|
|
689
|
-
- (void)setAndroidHmsToken:(NSString * _Nullable)token { (void)token; }
|
|
690
|
-
|
|
691
|
-
/// Sets iOS FCM token in Swift module.
|
|
692
|
-
- (void)setIosFcmToken:(NSString * _Nullable)token {
|
|
693
|
-
id module = SdkAppModuleSharedInstance();
|
|
694
|
-
EnsureProvidersInstalled(module);
|
|
695
|
-
CallSetToken(module, @"setFCM:", token);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
/// Sets iOS HMS token in Swift module (if used).
|
|
699
|
-
- (void)setIosHmsToken:(NSString * _Nullable)token {
|
|
700
|
-
id module = SdkAppModuleSharedInstance();
|
|
701
|
-
EnsureProvidersInstalled(module);
|
|
702
|
-
CallSetToken(module, @"setHMS:", token);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
/// Sets APNs token in Swift module.
|
|
706
|
-
- (void)setApnsToken:(NSString * _Nullable)token {
|
|
707
|
-
id module = SdkAppModuleSharedInstance();
|
|
708
|
-
EnsureProvidersInstalled(module);
|
|
709
|
-
CallSetToken(module, @"setAPNS:", token);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
/// RuStore-only API stub (no-op on iOS).
|
|
713
|
-
- (void)setRustoreToken:(NSString * _Nullable)token { (void)token; }
|
|
714
|
-
|
|
715
586
|
#pragma mark - Subscription (void)
|
|
716
587
|
|
|
717
|
-
/// Subscribes device for push notifications.
|
|
718
588
|
- (void)pushSubscribe:(NSNumber *)sync
|
|
719
589
|
profileFields:(NSDictionary *)profileFields
|
|
720
590
|
customFields:(NSDictionary *)customFields
|
|
@@ -735,7 +605,6 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
735
605
|
(NSNumber *)SdkNilIfNSNull(skipTriggers));
|
|
736
606
|
}
|
|
737
607
|
|
|
738
|
-
/// Suspends push subscription.
|
|
739
608
|
- (void)pushSuspend:(NSNumber *)sync
|
|
740
609
|
profileFields:(NSDictionary *)profileFields
|
|
741
610
|
customFields:(NSDictionary *)customFields
|
|
@@ -756,7 +625,6 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
756
625
|
(NSNumber *)SdkNilIfNSNull(skipTriggers));
|
|
757
626
|
}
|
|
758
627
|
|
|
759
|
-
/// Unsubscribes device from push notifications.
|
|
760
628
|
- (void)pushUnSubscribe:(NSNumber *)sync
|
|
761
629
|
profileFields:(NSDictionary *)profileFields
|
|
762
630
|
customFields:(NSDictionary *)customFields
|
|
@@ -777,9 +645,39 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
777
645
|
(NSNumber *)SdkNilIfNSNull(skipTriggers));
|
|
778
646
|
}
|
|
779
647
|
|
|
780
|
-
#pragma mark - MobileEvent (void)
|
|
648
|
+
#pragma mark - MobileEvent (void) with subscription
|
|
649
|
+
|
|
650
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
651
|
+
|
|
652
|
+
- (void)mobileEvent:(NSString *)sid
|
|
653
|
+
eventName:(NSString *)eventName
|
|
654
|
+
sendMessageId:(NSString * _Nullable)sendMessageId
|
|
655
|
+
payload:(NSDictionary * _Nullable)payload
|
|
656
|
+
matching:(NSDictionary * _Nullable)matching
|
|
657
|
+
matchingType:(NSString * _Nullable)matchingType
|
|
658
|
+
profileFields:(NSDictionary * _Nullable)profileFields
|
|
659
|
+
subscription:(NSDictionary * _Nullable)subscription
|
|
660
|
+
utm:(JS::NativeSdk::UTM &)utm
|
|
661
|
+
{
|
|
662
|
+
id module = SdkAppModuleSharedInstance();
|
|
663
|
+
EnsureProvidersInstalled(module);
|
|
664
|
+
|
|
665
|
+
NSDictionary *utmDict = SdkConvertUTMToNSDictionary(utm);
|
|
666
|
+
|
|
667
|
+
CallMobileEvent(module,
|
|
668
|
+
(NSString *)SdkNilIfNSNull(sid),
|
|
669
|
+
(NSString *)SdkNilIfNSNull(eventName),
|
|
670
|
+
(NSString *)SdkNilIfNSNull(sendMessageId),
|
|
671
|
+
(NSDictionary *)SdkNilIfNSNull(payload),
|
|
672
|
+
(NSDictionary *)SdkNilIfNSNull(matching),
|
|
673
|
+
(NSString *)SdkNilIfNSNull(matchingType),
|
|
674
|
+
(NSDictionary *)SdkNilIfNSNull(profileFields),
|
|
675
|
+
(NSDictionary *)SdkNilIfNSNull(subscription),
|
|
676
|
+
(NSDictionary *)SdkNilIfNSNull(utmDict));
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
#else // OLD ARCH
|
|
781
680
|
|
|
782
|
-
/// Sends a custom mobile event to backend (now includes `utm`).
|
|
783
681
|
- (void)mobileEvent:(NSString *)sid
|
|
784
682
|
eventName:(NSString *)eventName
|
|
785
683
|
sendMessageId:(NSString * _Nullable)sendMessageId
|
|
@@ -787,6 +685,7 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
787
685
|
matching:(NSDictionary * _Nullable)matching
|
|
788
686
|
matchingType:(NSString * _Nullable)matchingType
|
|
789
687
|
profileFields:(NSDictionary * _Nullable)profileFields
|
|
688
|
+
subscription:(NSDictionary * _Nullable)subscription
|
|
790
689
|
utm:(NSDictionary * _Nullable)utm
|
|
791
690
|
{
|
|
792
691
|
id module = SdkAppModuleSharedInstance();
|
|
@@ -800,12 +699,14 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
800
699
|
(NSDictionary *)SdkNilIfNSNull(matching),
|
|
801
700
|
(NSString *)SdkNilIfNSNull(matchingType),
|
|
802
701
|
(NSDictionary *)SdkNilIfNSNull(profileFields),
|
|
702
|
+
(NSDictionary *)SdkNilIfNSNull(subscription),
|
|
803
703
|
(NSDictionary *)SdkNilIfNSNull(utm));
|
|
804
704
|
}
|
|
805
705
|
|
|
706
|
+
#endif
|
|
707
|
+
|
|
806
708
|
#pragma mark - Promises
|
|
807
709
|
|
|
808
|
-
/// Unsuspends current push subscription.
|
|
809
710
|
- (void)unSuspendPushSubscription:(RCTPromiseResolveBlock)resolve
|
|
810
711
|
reject:(RCTPromiseRejectBlock)reject
|
|
811
712
|
{
|
|
@@ -814,7 +715,6 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
814
715
|
CallPromise0Args(module, @"unSuspendPushSubscriptionWithResolver:rejecter:", resolve, reject);
|
|
815
716
|
}
|
|
816
717
|
|
|
817
|
-
/// Returns status of latest subscription attempt.
|
|
818
718
|
- (void)getStatusOfLatestSubscription:(RCTPromiseResolveBlock)resolve
|
|
819
719
|
reject:(RCTPromiseRejectBlock)reject
|
|
820
720
|
{
|
|
@@ -823,7 +723,6 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
823
723
|
CallPromise0Args(module, @"getStatusOfLatestSubscriptionWithResolver:rejecter:", resolve, reject);
|
|
824
724
|
}
|
|
825
725
|
|
|
826
|
-
/// Returns current subscription status.
|
|
827
726
|
- (void)getStatusForCurrentSubscription:(RCTPromiseResolveBlock)resolve
|
|
828
727
|
reject:(RCTPromiseRejectBlock)reject
|
|
829
728
|
{
|
|
@@ -832,7 +731,6 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
832
731
|
CallPromise0Args(module, @"getStatusForCurrentSubscriptionWithResolver:rejecter:", resolve, reject);
|
|
833
732
|
}
|
|
834
733
|
|
|
835
|
-
/// Returns status of latest subscription for a specific provider.
|
|
836
734
|
- (void)getStatusOfLatestSubscriptionForProvider:(NSString * _Nullable)provider
|
|
837
735
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
838
736
|
reject:(RCTPromiseRejectBlock)reject
|
|
@@ -847,7 +745,6 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
847
745
|
reject);
|
|
848
746
|
}
|
|
849
747
|
|
|
850
|
-
/// Clears SDK state (tokens, cached values, etc).
|
|
851
748
|
- (void)clear:(RCTPromiseResolveBlock)resolve
|
|
852
749
|
reject:(RCTPromiseRejectBlock)reject
|
|
853
750
|
{
|
|
@@ -856,7 +753,8 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
856
753
|
CallClear(module, resolve, reject);
|
|
857
754
|
}
|
|
858
755
|
|
|
859
|
-
|
|
756
|
+
#pragma mark - Push token API (ONLY getPushToken / setPushToken)
|
|
757
|
+
|
|
860
758
|
- (void)getPushToken:(RCTPromiseResolveBlock)resolve
|
|
861
759
|
reject:(RCTPromiseRejectBlock)reject
|
|
862
760
|
{
|
|
@@ -889,10 +787,10 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
889
787
|
});
|
|
890
788
|
}
|
|
891
789
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
790
|
+
- (void)setPushToken:(NSString *)provider
|
|
791
|
+
token:(NSString * _Nullable)token
|
|
792
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
793
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
896
794
|
{
|
|
897
795
|
id module = SdkAppModuleSharedInstance();
|
|
898
796
|
if (!module) {
|
|
@@ -903,152 +801,179 @@ static NSDictionary *SdkConvertAltcraftConfigToNSDictionary(JS::NativeSdk::Altcr
|
|
|
903
801
|
|
|
904
802
|
EnsureProvidersInstalled(module);
|
|
905
803
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
804
|
+
if (!provider || provider.length == 0) {
|
|
805
|
+
NSError *err = [NSError errorWithDomain:@"Sdk" code:4 userInfo:@{NSLocalizedDescriptionKey:@"Provider is empty"}];
|
|
806
|
+
reject(@"INVALID_PROVIDER", @"Provider is empty", err);
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
CallSetPushToken(module, provider, token);
|
|
811
|
+
resolve((id)kCFNull);
|
|
913
812
|
}
|
|
914
813
|
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
814
|
+
#pragma mark - UserDefaults
|
|
815
|
+
|
|
816
|
+
- (void)setUserDefaultsValue:(NSString * _Nullable)suiteName
|
|
817
|
+
key:(NSString *)key
|
|
818
|
+
value:(NSString * _Nullable)value
|
|
918
819
|
{
|
|
919
820
|
id module = SdkAppModuleSharedInstance();
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
821
|
+
EnsureProvidersInstalled(module);
|
|
822
|
+
|
|
823
|
+
NSString *sn = (NSString *)SdkNilIfNSNull(suiteName);
|
|
824
|
+
NSString *k = (NSString *)SdkNilIfNSNull(key);
|
|
825
|
+
id v = SdkNilIfNSNull(value);
|
|
826
|
+
|
|
827
|
+
if (!module) return;
|
|
828
|
+
if (!k || k.length == 0) return;
|
|
829
|
+
|
|
830
|
+
if (![NSThread isMainThread]) {
|
|
831
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
832
|
+
CallSetUserDefaultsValue(module, sn, k, v);
|
|
833
|
+
});
|
|
923
834
|
return;
|
|
924
835
|
}
|
|
925
836
|
|
|
837
|
+
CallSetUserDefaultsValue(module, sn, k, v);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
#pragma mark - Profile API
|
|
841
|
+
|
|
842
|
+
- (void)updateProfileFields:(NSDictionary * _Nullable)profileFields
|
|
843
|
+
skipTriggers:(NSNumber *)skipTriggers
|
|
844
|
+
{
|
|
845
|
+
id module = SdkAppModuleSharedInstance();
|
|
926
846
|
EnsureProvidersInstalled(module);
|
|
927
847
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
848
|
+
SEL sel = SdkSel(@"updateProfileFields:skipTriggers:");
|
|
849
|
+
if (!SdkResponds(module, sel)) return;
|
|
850
|
+
|
|
851
|
+
IMP imp = [module methodForSelector:sel];
|
|
852
|
+
if (!imp) return;
|
|
853
|
+
|
|
854
|
+
void (*func)(id, SEL, id, id) = (void (*)(id, SEL, id, id))imp;
|
|
855
|
+
func(module, sel, (NSDictionary *)SdkNilIfNSNull(profileFields), (NSNumber *)SdkNilIfNSNull(skipTriggers));
|
|
931
856
|
}
|
|
932
857
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
858
|
+
#pragma mark - Token management API
|
|
859
|
+
|
|
860
|
+
- (void)forcedTokenUpdate:(RCTPromiseResolveBlock)resolve
|
|
861
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
937
862
|
{
|
|
938
863
|
id module = SdkAppModuleSharedInstance();
|
|
939
|
-
if (!module) {
|
|
940
|
-
NSError *err = [NSError errorWithDomain:@"Sdk" code:1 userInfo:@{NSLocalizedDescriptionKey:@"SdkAppModule not found"}];
|
|
941
|
-
reject(@"SWIFT_MODULE_NOT_FOUND", @"SdkAppModule class not found", err);
|
|
942
|
-
return;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
864
|
EnsureProvidersInstalled(module);
|
|
865
|
+
CallPromise0Args(module, @"forcedTokenUpdateWithResolver:rejecter:", resolve, reject);
|
|
866
|
+
}
|
|
946
867
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
});
|
|
868
|
+
- (void)deleteDeviceToken:(NSString *)provider
|
|
869
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
870
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
871
|
+
{
|
|
872
|
+
id module = SdkAppModuleSharedInstance();
|
|
873
|
+
EnsureProvidersInstalled(module);
|
|
874
|
+
CallPromise1StringArg(module, @"deleteDeviceTokenWithProvider:resolver:rejecter:", provider, resolve, reject);
|
|
955
875
|
}
|
|
956
876
|
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
961
|
-
reject:(RCTPromiseRejectBlock)reject
|
|
877
|
+
- (void)changePushProviderPriorityList:(NSArray *)priorityList
|
|
878
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
879
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
962
880
|
{
|
|
963
881
|
id module = SdkAppModuleSharedInstance();
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
882
|
+
EnsureProvidersInstalled(module);
|
|
883
|
+
|
|
884
|
+
SEL sel = SdkSel(@"changePushProviderPriorityList:");
|
|
885
|
+
if (!SdkResponds(module, sel)) {
|
|
886
|
+
reject(@"ERR_METHOD_NOT_FOUND", @"changePushProviderPriorityList: not found", nil);
|
|
967
887
|
return;
|
|
968
888
|
}
|
|
969
889
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
NSError *err = [NSError errorWithDomain:@"Sdk" code:4 userInfo:@{NSLocalizedDescriptionKey:@"Provider is empty"}];
|
|
974
|
-
reject(@"INVALID_PROVIDER", @"Provider is empty", err);
|
|
890
|
+
IMP imp = [module methodForSelector:sel];
|
|
891
|
+
if (!imp) {
|
|
892
|
+
reject(@"ERR_METHOD_NOT_FOUND", @"changePushProviderPriorityList: not found", nil);
|
|
975
893
|
return;
|
|
976
894
|
}
|
|
977
895
|
|
|
978
|
-
|
|
896
|
+
void (*func)(id, SEL, id) = (void (*)(id, SEL, id))imp;
|
|
897
|
+
func(module, sel, priorityList ?: @[]);
|
|
979
898
|
resolve((id)kCFNull);
|
|
980
899
|
}
|
|
981
900
|
|
|
982
|
-
#pragma mark -
|
|
901
|
+
#pragma mark - PushReceiver helpers
|
|
983
902
|
|
|
984
|
-
|
|
985
|
-
/// so App Group logic is centralized in Swift and works consistently.
|
|
986
|
-
- (void)setUserDefaultsValue:(NSString * _Nullable)suiteName
|
|
987
|
-
key:(NSString *)key
|
|
988
|
-
value:(NSString * _Nullable)value
|
|
903
|
+
- (NSNumber *)isAltcraftPush:(NSDictionary * _Nullable)message
|
|
989
904
|
{
|
|
990
905
|
id module = SdkAppModuleSharedInstance();
|
|
991
|
-
|
|
906
|
+
if (!module) return @NO;
|
|
992
907
|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
id v = SdkNilIfNSNull(value); // value already NSString* or nil
|
|
908
|
+
SEL sel = SdkSel(@"isAltcraftPush:");
|
|
909
|
+
if (!SdkResponds(module, sel)) return @NO;
|
|
996
910
|
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
}
|
|
911
|
+
IMP imp = [module methodForSelector:sel];
|
|
912
|
+
if (!imp) return @NO;
|
|
1000
913
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
914
|
+
BOOL (*func)(id, SEL, id) = (BOOL (*)(id, SEL, id))imp;
|
|
915
|
+
BOOL result = func(module, sel, (NSDictionary *)SdkNilIfNSNull(message));
|
|
916
|
+
return [NSNumber numberWithBool:result];
|
|
917
|
+
}
|
|
1004
918
|
|
|
1005
|
-
|
|
1006
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
1007
|
-
CallSetUserDefaultsValue(module, sn, k, v);
|
|
1008
|
-
});
|
|
1009
|
-
return;
|
|
1010
|
-
}
|
|
919
|
+
#pragma mark - Session unlock
|
|
1011
920
|
|
|
1012
|
-
|
|
921
|
+
- (void)unlockInitialOperationsInThisSession
|
|
922
|
+
{
|
|
923
|
+
id module = SdkAppModuleSharedInstance();
|
|
924
|
+
if (!module) return;
|
|
925
|
+
|
|
926
|
+
SEL sel = SdkSel(@"unlockInitialOperationsInThisSession");
|
|
927
|
+
if (!SdkResponds(module, sel)) return;
|
|
928
|
+
|
|
929
|
+
IMP imp = [module methodForSelector:sel];
|
|
930
|
+
if (!imp) return;
|
|
931
|
+
|
|
932
|
+
void (*func)(id, SEL) = (void (*)(id, SEL))imp;
|
|
933
|
+
func(module, sel);
|
|
1013
934
|
}
|
|
1014
935
|
|
|
1015
|
-
#pragma mark -
|
|
936
|
+
#pragma mark - App Group
|
|
937
|
+
|
|
938
|
+
- (void)setAppGroup:(NSString * _Nullable)groupName
|
|
939
|
+
{
|
|
940
|
+
id module = SdkAppModuleSharedInstance();
|
|
941
|
+
if (!module) return;
|
|
942
|
+
|
|
943
|
+
SEL sel = SdkSel(@"setAppGroup:");
|
|
944
|
+
if (!SdkResponds(module, sel)) return;
|
|
945
|
+
|
|
946
|
+
IMP imp = [module methodForSelector:sel];
|
|
947
|
+
if (!imp) return;
|
|
948
|
+
|
|
949
|
+
void (*func)(id, SEL, id) = (void (*)(id, SEL, id))imp;
|
|
950
|
+
func(module, sel, (NSString *)SdkNilIfNSNull(groupName));
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
#pragma mark - iOS-only stubs (kept if present in spec / facade)
|
|
1016
954
|
|
|
1017
|
-
/// iOS stub: delivery tracking is handled by server/other platforms.
|
|
1018
955
|
- (void)deliveryEvent:(NSDictionary * _Nullable)message
|
|
1019
956
|
messageUID:(NSString * _Nullable)messageUID
|
|
1020
957
|
{
|
|
1021
958
|
(void)message;
|
|
1022
959
|
(void)messageUID;
|
|
1023
|
-
// Intentionally not implemented on iOS.
|
|
1024
960
|
}
|
|
1025
961
|
|
|
1026
|
-
/// iOS stub: open tracking is handled by OS / deep-link flow.
|
|
1027
962
|
- (void)openEvent:(NSDictionary * _Nullable)message
|
|
1028
963
|
messageUID:(NSString * _Nullable)messageUID
|
|
1029
964
|
{
|
|
1030
965
|
(void)message;
|
|
1031
966
|
(void)messageUID;
|
|
1032
|
-
// Intentionally not implemented on iOS.
|
|
1033
967
|
}
|
|
1034
968
|
|
|
1035
|
-
/// iOS stub: retry control is managed in Swift layer / system scheduling.
|
|
1036
|
-
- (void)unlockInitOperationsInThisSession
|
|
1037
|
-
{
|
|
1038
|
-
// Intentionally not implemented on iOS.
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
/// iOS stub: permission prompt should be initiated by the host app UI.
|
|
1042
969
|
- (void)requestNotificationPermission
|
|
1043
970
|
{
|
|
1044
|
-
// Intentionally not implemented on iOS.
|
|
1045
971
|
}
|
|
1046
972
|
|
|
1047
|
-
/// iOS stub: push handling is done via AppDelegate / UNUserNotificationCenter callbacks.
|
|
1048
973
|
- (void)takePush:(NSDictionary * _Nullable)message
|
|
1049
974
|
{
|
|
1050
975
|
(void)message;
|
|
1051
|
-
// Intentionally not implemented on iOS.
|
|
1052
976
|
}
|
|
1053
977
|
|
|
1054
978
|
@end
|
|
979
|
+
|