@adshift/react-native-plugin 1.0.0 → 2.1.0
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/AdShiftReactNativePlugin.podspec +11 -7
- package/CHANGELOG.md +138 -0
- package/README.md +513 -542
- package/android/build.gradle +17 -3
- package/android/consumer-rules.pro +21 -0
- package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +786 -229
- package/android/src/test/java/com/adshift/reactnativeplugin/ConsentSnapshotTest.kt +180 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +146 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +111 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/IntentLinkDedupTest.kt +168 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +106 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +167 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/StartVerdictTest.kt +164 -0
- package/ios/AdShiftReactNativePlugin.h +7 -7
- package/ios/AdShiftReactNativePlugin.mm +200 -181
- package/ios/AdShiftReactNativePluginHelper.swift +584 -286
- package/ios/Core/BridgeRules.swift +82 -0
- package/lib/commonjs/Adshift.js +1138 -0
- package/lib/commonjs/Adshift.js.map +1 -0
- package/lib/commonjs/NativeAdShiftReactNativePlugin.js +22 -0
- package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -0
- package/lib/commonjs/index.js +94 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/jest/index.js +164 -0
- package/lib/commonjs/jest/index.js.map +1 -0
- package/lib/commonjs/nativeSdkVersions.js +17 -0
- package/lib/commonjs/nativeSdkVersions.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types/AdshiftAdRevenue.js +47 -0
- package/lib/commonjs/types/AdshiftAdRevenue.js.map +1 -0
- package/lib/commonjs/types/AdshiftConfig.js +45 -0
- package/lib/commonjs/types/AdshiftConfig.js.map +1 -0
- package/lib/commonjs/types/AdshiftConsent.js +113 -0
- package/lib/commonjs/types/AdshiftConsent.js.map +1 -0
- package/lib/commonjs/types/AdshiftConsentSnapshot.js +69 -0
- package/lib/commonjs/types/AdshiftConsentSnapshot.js.map +1 -0
- package/lib/commonjs/types/AdshiftDeepLink.js +154 -0
- package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -0
- package/lib/commonjs/types/AdshiftError.js +91 -0
- package/lib/commonjs/types/AdshiftError.js.map +1 -0
- package/lib/commonjs/types/AdshiftEventParam.js +140 -0
- package/lib/commonjs/types/AdshiftEventParam.js.map +1 -0
- package/lib/commonjs/types/AdshiftEventType.js +88 -0
- package/lib/commonjs/types/AdshiftEventType.js.map +1 -0
- package/lib/commonjs/types/AdshiftThirdPartySharing.js +70 -0
- package/lib/commonjs/types/AdshiftThirdPartySharing.js.map +1 -0
- package/lib/commonjs/types/index.js +123 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/version.js +9 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/Adshift.js +962 -296
- package/lib/module/Adshift.js.map +1 -1
- package/lib/module/NativeAdShiftReactNativePlugin.js +10 -7
- package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
- package/lib/module/index.js +26 -25
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +144 -0
- package/lib/module/jest/index.js.map +1 -0
- package/lib/module/nativeSdkVersions.js +13 -0
- package/lib/module/nativeSdkVersions.js.map +1 -0
- package/lib/module/types/AdshiftAdRevenue.js +43 -0
- package/lib/module/types/AdshiftAdRevenue.js.map +1 -0
- package/lib/module/types/AdshiftConfig.js +23 -26
- package/lib/module/types/AdshiftConfig.js.map +1 -1
- package/lib/module/types/AdshiftConsent.js +57 -50
- package/lib/module/types/AdshiftConsent.js.map +1 -1
- package/lib/module/types/AdshiftConsentSnapshot.js +65 -0
- package/lib/module/types/AdshiftConsentSnapshot.js.map +1 -0
- package/lib/module/types/AdshiftDeepLink.js +97 -67
- package/lib/module/types/AdshiftDeepLink.js.map +1 -1
- package/lib/module/types/AdshiftError.js +87 -0
- package/lib/module/types/AdshiftError.js.map +1 -0
- package/lib/module/types/AdshiftEventParam.js +135 -0
- package/lib/module/types/AdshiftEventParam.js.map +1 -0
- package/lib/module/types/AdshiftEventType.js +11 -36
- package/lib/module/types/AdshiftEventType.js.map +1 -1
- package/lib/module/types/AdshiftThirdPartySharing.js +65 -0
- package/lib/module/types/AdshiftThirdPartySharing.js.map +1 -0
- package/lib/module/types/index.js +9 -7
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/version.js +5 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/Adshift.d.ts +314 -0
- package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +102 -0
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +51 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/jest/index.d.ts +103 -0
- package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +11 -0
- package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts +56 -0
- package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +104 -0
- package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts +76 -0
- package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts +56 -0
- package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +89 -0
- package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdshiftError.d.ts +57 -0
- package/lib/typescript/commonjs/src/types/AdshiftError.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts +111 -0
- package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts.map +1 -0
- package/lib/typescript/{src → commonjs/src}/types/AdshiftEventType.d.ts +12 -35
- package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts +53 -0
- package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/index.d.ts +17 -0
- package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/version.d.ts +2 -0
- package/lib/typescript/commonjs/src/version.d.ts.map +1 -0
- package/lib/typescript/module/src/Adshift.d.ts +314 -0
- package/lib/typescript/module/src/Adshift.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +102 -0
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +51 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/jest/index.d.ts +103 -0
- package/lib/typescript/module/src/jest/index.d.ts.map +1 -0
- package/lib/typescript/module/src/nativeSdkVersions.d.ts +11 -0
- package/lib/typescript/module/src/nativeSdkVersions.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts +56 -0
- package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdshiftConfig.d.ts +104 -0
- package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdshiftConsent.d.ts +76 -0
- package/lib/typescript/module/src/types/AdshiftConsent.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts +56 -0
- package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +89 -0
- package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdshiftError.d.ts +57 -0
- package/lib/typescript/module/src/types/AdshiftError.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdshiftEventParam.d.ts +111 -0
- package/lib/typescript/module/src/types/AdshiftEventParam.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdshiftEventType.d.ts +64 -0
- package/lib/typescript/module/src/types/AdshiftEventType.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts +53 -0
- package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts.map +1 -0
- package/lib/typescript/module/src/types/index.d.ts +17 -0
- package/lib/typescript/module/src/types/index.d.ts.map +1 -0
- package/lib/typescript/module/src/version.d.ts +2 -0
- package/lib/typescript/module/src/version.d.ts.map +1 -0
- package/package.json +50 -11
- package/src/Adshift.ts +1276 -342
- package/src/NativeAdShiftReactNativePlugin.ts +81 -115
- package/src/index.tsx +40 -25
- package/src/jest/index.ts +224 -0
- package/src/nativeSdkVersions.ts +10 -0
- package/src/types/AdshiftAdRevenue.ts +58 -0
- package/src/types/AdshiftConfig.ts +101 -53
- package/src/types/AdshiftConsent.ts +75 -72
- package/src/types/AdshiftConsentSnapshot.ts +103 -0
- package/src/types/AdshiftDeepLink.ts +123 -102
- package/src/types/AdshiftError.ts +107 -0
- package/src/types/AdshiftEventParam.ts +216 -0
- package/src/types/AdshiftEventType.ts +13 -35
- package/src/types/AdshiftThirdPartySharing.ts +63 -0
- package/src/types/index.ts +38 -6
- package/src/version.ts +2 -0
- package/lib/typescript/src/Adshift.d.ts +0 -335
- package/lib/typescript/src/Adshift.d.ts.map +0 -1
- package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts +0 -143
- package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -47
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/types/AdshiftConfig.d.ts +0 -74
- package/lib/typescript/src/types/AdshiftConfig.d.ts.map +0 -1
- package/lib/typescript/src/types/AdshiftConsent.d.ts +0 -88
- package/lib/typescript/src/types/AdshiftConsent.d.ts.map +0 -1
- package/lib/typescript/src/types/AdshiftDeepLink.d.ts +0 -93
- package/lib/typescript/src/types/AdshiftDeepLink.d.ts.map +0 -1
- package/lib/typescript/src/types/AdshiftEventType.d.ts.map +0 -1
- package/lib/typescript/src/types/index.d.ts +0 -5
- package/lib/typescript/src/types/index.d.ts.map +0 -1
- /package/lib/typescript/{package.json → module/package.json} +0 -0
|
@@ -3,189 +3,201 @@
|
|
|
3
3
|
// AdShiftReactNativePlugin
|
|
4
4
|
//
|
|
5
5
|
// Objective-C++ implementation of the Turbo Module.
|
|
6
|
-
//
|
|
6
|
+
// Forwards JavaScript calls to the Swift helper and emits deep link events.
|
|
7
7
|
//
|
|
8
8
|
// Copyright © 2025 AdShift. All rights reserved.
|
|
9
9
|
//
|
|
10
10
|
|
|
11
11
|
#import "AdShiftReactNativePlugin.h"
|
|
12
|
-
#import <React/RCTLog.h>
|
|
13
12
|
|
|
14
|
-
// Import Swift module (generated by Xcode)
|
|
15
13
|
#if __has_include(<AdShiftReactNativePlugin/AdShiftReactNativePlugin-Swift.h>)
|
|
16
14
|
#import <AdShiftReactNativePlugin/AdShiftReactNativePlugin-Swift.h>
|
|
17
|
-
#elif __has_include("AdShiftReactNativePlugin-Swift.h")
|
|
18
|
-
#import "AdShiftReactNativePlugin-Swift.h"
|
|
19
15
|
#else
|
|
20
|
-
|
|
21
|
-
@class AdShiftReactNativePluginHelper;
|
|
16
|
+
#import "AdShiftReactNativePlugin-Swift.h"
|
|
22
17
|
#endif
|
|
23
18
|
|
|
19
|
+
static NSString *const kAdShiftBridgeErrorDomain = @"com.adshift.reactnativeplugin";
|
|
20
|
+
|
|
21
|
+
/// Rejects a promise with the bridge error code carried in `error.userInfo[@"code"]`.
|
|
22
|
+
///
|
|
23
|
+
/// JavaScript receives `error.code` (bridge code) and
|
|
24
|
+
/// `error.userInfo.nativeCode` / `error.userInfo.nativeDomain` when available.
|
|
25
|
+
static void RejectWithError(RCTPromiseRejectBlock reject, NSError *error)
|
|
26
|
+
{
|
|
27
|
+
NSString *code = error.userInfo[@"code"];
|
|
28
|
+
if (![code isKindOfClass:[NSString class]] || code.length == 0) {
|
|
29
|
+
code = @"UNKNOWN";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
NSMutableDictionary<NSString *, id> *userInfo = [NSMutableDictionary dictionary];
|
|
33
|
+
id nativeCode = error.userInfo[@"nativeCode"];
|
|
34
|
+
if (nativeCode != nil) {
|
|
35
|
+
userInfo[@"nativeCode"] = nativeCode;
|
|
36
|
+
}
|
|
37
|
+
id nativeDomain = error.userInfo[@"nativeDomain"];
|
|
38
|
+
if (nativeDomain != nil) {
|
|
39
|
+
userInfo[@"nativeDomain"] = nativeDomain;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
NSError *bridgeError = [NSError errorWithDomain:kAdShiftBridgeErrorDomain code:error.code userInfo:userInfo];
|
|
43
|
+
reject(code, error.localizedDescription, bridgeError);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@interface AdShiftReactNativePlugin () <AdShiftDeepLinkEmitting>
|
|
47
|
+
@end
|
|
48
|
+
|
|
24
49
|
@implementation AdShiftReactNativePlugin {
|
|
25
|
-
|
|
50
|
+
BOOL _invalidated;
|
|
26
51
|
}
|
|
27
52
|
|
|
28
53
|
RCT_EXPORT_MODULE(AdShiftReactNativePlugin)
|
|
29
54
|
|
|
30
|
-
|
|
55
|
+
- (instancetype)init
|
|
56
|
+
{
|
|
57
|
+
if (self = [super init]) {
|
|
58
|
+
[[AdShiftReactNativePluginHelper shared] setModule:self];
|
|
59
|
+
}
|
|
60
|
+
return self;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)invalidate
|
|
64
|
+
{
|
|
65
|
+
_invalidated = YES;
|
|
66
|
+
[[AdShiftReactNativePluginHelper shared] clearModule:self];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
|
70
|
+
{
|
|
71
|
+
[super setEventEmitterCallback:eventEmitterCallbackWrapper];
|
|
72
|
+
// Registering again delivers deep links that arrived before this module could emit.
|
|
73
|
+
[[AdShiftReactNativePluginHelper shared] setModule:self];
|
|
74
|
+
}
|
|
31
75
|
|
|
32
76
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
33
|
-
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
34
|
-
|
|
77
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
78
|
+
{
|
|
79
|
+
return std::make_shared<facebook::react::NativeAdShiftReactNativePluginSpecJSI>(params);
|
|
35
80
|
}
|
|
36
81
|
|
|
37
|
-
|
|
82
|
+
#pragma mark - AdShiftDeepLinkEmitting
|
|
83
|
+
|
|
84
|
+
/// Returns NO when JavaScript cannot receive the event, so the caller can keep the payload.
|
|
85
|
+
/// The emitter callback is absent before the module is installed and after it is torn down.
|
|
86
|
+
- (BOOL)emitDeepLink:(NSDictionary<NSString *, id> *)payload
|
|
87
|
+
{
|
|
88
|
+
if (_invalidated || !_eventEmitterCallback) {
|
|
89
|
+
return NO;
|
|
90
|
+
}
|
|
91
|
+
[self emitOnDeepLink:payload];
|
|
92
|
+
return YES;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#pragma mark - Lifecycle
|
|
38
96
|
|
|
39
|
-
- (
|
|
40
|
-
|
|
97
|
+
- (void)initialize:(NSDictionary *)config
|
|
98
|
+
{
|
|
99
|
+
[[AdShiftReactNativePluginHelper shared] initializeWithConfig:config];
|
|
41
100
|
}
|
|
42
101
|
|
|
43
|
-
- (void)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[[AdShiftReactNativePluginHelper shared] setDeepLinkEventCallback:^(NSDictionary<NSString *, id> *event) {
|
|
49
|
-
if (self->_hasListeners) {
|
|
50
|
-
[self sendEventWithName:@"onDeepLink" body:event];
|
|
51
|
-
}
|
|
52
|
-
}];
|
|
53
|
-
}
|
|
102
|
+
- (void)start:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
103
|
+
{
|
|
104
|
+
[[AdShiftReactNativePluginHelper shared] startWithCompletion:^(NSDictionary<NSString *, id> *result) {
|
|
105
|
+
resolve(result);
|
|
106
|
+
}];
|
|
54
107
|
}
|
|
55
108
|
|
|
56
|
-
- (void)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (@available(iOS 15.0, *)) {
|
|
60
|
-
[[AdShiftReactNativePluginHelper shared] clearDeepLinkEventCallback];
|
|
61
|
-
}
|
|
109
|
+
- (void)stop
|
|
110
|
+
{
|
|
111
|
+
[[AdShiftReactNativePluginHelper shared] stop];
|
|
62
112
|
}
|
|
63
113
|
|
|
64
|
-
|
|
114
|
+
#pragma mark - Configuration
|
|
65
115
|
|
|
66
|
-
- (void)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (@available(iOS 15.0, *)) {
|
|
70
|
-
[[AdShiftReactNativePluginHelper shared] initializeWithConfig:config];
|
|
71
|
-
} else {
|
|
72
|
-
RCTLogWarn(@"[AdShift] iOS 15.0+ required");
|
|
73
|
-
}
|
|
116
|
+
- (void)setCustomerUserId:(NSString *)userId
|
|
117
|
+
{
|
|
118
|
+
[[AdShiftReactNativePluginHelper shared] setCustomerUserId:userId];
|
|
74
119
|
}
|
|
75
120
|
|
|
76
|
-
- (void)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (@available(iOS 15.0, *)) {
|
|
80
|
-
[[AdShiftReactNativePluginHelper shared] startWithCompletion:^(NSDictionary *result, NSError *error) {
|
|
81
|
-
if (error) {
|
|
82
|
-
reject(@"START_ERROR", error.localizedDescription, error);
|
|
83
|
-
} else {
|
|
84
|
-
resolve(result ?: @{@"success": @YES});
|
|
85
|
-
}
|
|
86
|
-
}];
|
|
87
|
-
} else {
|
|
88
|
-
reject(@"UNSUPPORTED", @"iOS 15.0+ required", nil);
|
|
89
|
-
}
|
|
121
|
+
- (void)setDebugEnabled:(BOOL)enabled
|
|
122
|
+
{
|
|
123
|
+
[[AdShiftReactNativePluginHelper shared] setDebugEnabled:enabled];
|
|
90
124
|
}
|
|
91
125
|
|
|
92
|
-
- (void)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (@available(iOS 15.0, *)) {
|
|
96
|
-
[[AdShiftReactNativePluginHelper shared] stop];
|
|
97
|
-
}
|
|
126
|
+
- (void)setAppOpenDebounceMs:(double)ms
|
|
127
|
+
{
|
|
128
|
+
[[AdShiftReactNativePluginHelper shared] setAppOpenDebounceMs:ms];
|
|
98
129
|
}
|
|
99
130
|
|
|
100
|
-
- (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return @(started);
|
|
104
|
-
}
|
|
105
|
-
return @NO;
|
|
131
|
+
- (void)setBrandedDomains:(NSArray *)domains
|
|
132
|
+
{
|
|
133
|
+
[[AdShiftReactNativePluginHelper shared] setBrandedDomains:domains];
|
|
106
134
|
}
|
|
107
135
|
|
|
108
|
-
|
|
136
|
+
- (void)setMetaAppId:(NSString *)appId
|
|
137
|
+
{
|
|
138
|
+
[[AdShiftReactNativePluginHelper shared] setMetaAppId:appId];
|
|
139
|
+
}
|
|
109
140
|
|
|
110
|
-
- (void)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (@available(iOS 15.0, *)) {
|
|
114
|
-
[[AdShiftReactNativePluginHelper shared] setCustomerUserId:userId];
|
|
115
|
-
}
|
|
141
|
+
- (void)setOaidData:(NSString *)oaid
|
|
142
|
+
{
|
|
143
|
+
[[AdShiftReactNativePluginHelper shared] setOaidData:oaid];
|
|
116
144
|
}
|
|
117
145
|
|
|
118
|
-
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
146
|
+
#pragma mark - Consent
|
|
147
|
+
|
|
148
|
+
- (void)setConsentData:(NSDictionary *)consent
|
|
149
|
+
{
|
|
150
|
+
[[AdShiftReactNativePluginHelper shared] setConsentData:consent];
|
|
124
151
|
}
|
|
125
152
|
|
|
126
|
-
- (void)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (@available(iOS 15.0, *)) {
|
|
130
|
-
[[AdShiftReactNativePluginHelper shared] setAppOpenDebounceMs:(NSInteger)ms];
|
|
131
|
-
}
|
|
153
|
+
- (void)enableTCFDataCollection:(BOOL)enabled
|
|
154
|
+
{
|
|
155
|
+
[[AdShiftReactNativePluginHelper shared] enableTCFDataCollection:enabled];
|
|
132
156
|
}
|
|
133
157
|
|
|
134
|
-
|
|
158
|
+
- (void)enableGPPDataCollection:(BOOL)enabled
|
|
159
|
+
{
|
|
160
|
+
[[AdShiftReactNativePluginHelper shared] enableGPPDataCollection:enabled];
|
|
161
|
+
}
|
|
135
162
|
|
|
136
|
-
- (void)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (@available(iOS 15.0, *)) {
|
|
140
|
-
[[AdShiftReactNativePluginHelper shared] setConsentData:consent];
|
|
141
|
-
}
|
|
163
|
+
- (void)setThirdPartySharing:(NSDictionary *)sharing
|
|
164
|
+
{
|
|
165
|
+
[[AdShiftReactNativePluginHelper shared] setThirdPartySharing:sharing];
|
|
142
166
|
}
|
|
143
167
|
|
|
144
|
-
- (void)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (@available(iOS 15.0, *)) {
|
|
148
|
-
[[AdShiftReactNativePluginHelper shared] enableTCFDataCollection:enabled];
|
|
149
|
-
}
|
|
168
|
+
- (void)clearThirdPartySharing
|
|
169
|
+
{
|
|
170
|
+
[[AdShiftReactNativePluginHelper shared] clearThirdPartySharing];
|
|
150
171
|
}
|
|
151
172
|
|
|
152
|
-
- (void)refreshConsent:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}];
|
|
163
|
-
} else {
|
|
164
|
-
reject(@"UNSUPPORTED", @"iOS 15.0+ required", nil);
|
|
165
|
-
}
|
|
173
|
+
- (void)refreshConsent:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
174
|
+
{
|
|
175
|
+
[[AdShiftReactNativePluginHelper shared]
|
|
176
|
+
refreshConsentWithCompletion:^(NSDictionary<NSString *, id> *_Nullable result, NSError *_Nullable error) {
|
|
177
|
+
if (error != nil) {
|
|
178
|
+
RejectWithError(reject, error);
|
|
179
|
+
} else {
|
|
180
|
+
resolve(result ?: @{});
|
|
181
|
+
}
|
|
182
|
+
}];
|
|
166
183
|
}
|
|
167
184
|
|
|
168
|
-
|
|
185
|
+
#pragma mark - Event tracking
|
|
169
186
|
|
|
170
187
|
- (void)trackEvent:(NSString *)eventName
|
|
171
|
-
values:(NSDictionary *)values
|
|
188
|
+
values:(NSDictionary *_Nullable)values
|
|
172
189
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
173
|
-
reject:(RCTPromiseRejectBlock)reject
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
}];
|
|
186
|
-
} else {
|
|
187
|
-
reject(@"UNSUPPORTED", @"iOS 15.0+ required", nil);
|
|
188
|
-
}
|
|
190
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
191
|
+
{
|
|
192
|
+
[[AdShiftReactNativePluginHelper shared] trackEvent:eventName
|
|
193
|
+
values:values
|
|
194
|
+
completion:^(NSError *_Nullable error) {
|
|
195
|
+
if (error != nil) {
|
|
196
|
+
RejectWithError(reject, error);
|
|
197
|
+
} else {
|
|
198
|
+
resolve(nil);
|
|
199
|
+
}
|
|
200
|
+
}];
|
|
189
201
|
}
|
|
190
202
|
|
|
191
203
|
- (void)trackPurchase:(NSString *)productId
|
|
@@ -193,66 +205,73 @@ RCT_EXPORT_MODULE(AdShiftReactNativePlugin)
|
|
|
193
205
|
currency:(NSString *)currency
|
|
194
206
|
token:(NSString *)token
|
|
195
207
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
196
|
-
reject:(RCTPromiseRejectBlock)reject
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
}];
|
|
211
|
-
} else {
|
|
212
|
-
reject(@"UNSUPPORTED", @"iOS 15.0+ required", nil);
|
|
213
|
-
}
|
|
208
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
209
|
+
{
|
|
210
|
+
[[AdShiftReactNativePluginHelper shared] trackPurchaseWithProductId:productId
|
|
211
|
+
price:price
|
|
212
|
+
currency:currency
|
|
213
|
+
token:token
|
|
214
|
+
completion:^(NSError *_Nullable error) {
|
|
215
|
+
if (error != nil) {
|
|
216
|
+
RejectWithError(reject, error);
|
|
217
|
+
} else {
|
|
218
|
+
resolve(nil);
|
|
219
|
+
}
|
|
220
|
+
}];
|
|
214
221
|
}
|
|
215
222
|
|
|
216
|
-
|
|
223
|
+
- (void)logAdRevenue:(NSDictionary *)data resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
224
|
+
{
|
|
225
|
+
[[AdShiftReactNativePluginHelper shared] logAdRevenue:data
|
|
226
|
+
completion:^(NSError *_Nullable error) {
|
|
227
|
+
if (error != nil) {
|
|
228
|
+
RejectWithError(reject, error);
|
|
229
|
+
} else {
|
|
230
|
+
resolve(nil);
|
|
231
|
+
}
|
|
232
|
+
}];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
#pragma mark - Identity
|
|
236
|
+
|
|
237
|
+
- (void)getAdShiftDeviceId:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
238
|
+
{
|
|
239
|
+
[[AdShiftReactNativePluginHelper shared] getAdShiftDeviceIdWithCompletion:^(NSString *_Nullable deviceId) {
|
|
240
|
+
resolve(deviceId ?: [NSNull null]);
|
|
241
|
+
}];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
#pragma mark - Deep links
|
|
217
245
|
|
|
218
246
|
- (void)handleDeepLink:(NSString *)url
|
|
247
|
+
fromLaunch:(BOOL)fromLaunch
|
|
219
248
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
220
|
-
reject:(RCTPromiseRejectBlock)reject
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
@"isDeferred": @NO
|
|
232
|
-
});
|
|
233
|
-
} else {
|
|
234
|
-
resolve(result ?: @{@"status": @"notFound", @"isDeferred": @NO});
|
|
235
|
-
}
|
|
236
|
-
}];
|
|
237
|
-
} else {
|
|
238
|
-
resolve(@{
|
|
239
|
-
@"status": @"error",
|
|
240
|
-
@"errorMessage": @"iOS 15.0+ required",
|
|
241
|
-
@"isDeferred": @NO
|
|
242
|
-
});
|
|
243
|
-
}
|
|
249
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
250
|
+
{
|
|
251
|
+
[[AdShiftReactNativePluginHelper shared] handleDeepLink:url
|
|
252
|
+
fromLaunch:fromLaunch
|
|
253
|
+
completion:^(NSError *_Nullable error) {
|
|
254
|
+
if (error != nil) {
|
|
255
|
+
RejectWithError(reject, error);
|
|
256
|
+
} else {
|
|
257
|
+
resolve(nil);
|
|
258
|
+
}
|
|
259
|
+
}];
|
|
244
260
|
}
|
|
245
261
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
// Required by NativeEventEmitter
|
|
250
|
-
// Actual setup done in startObserving
|
|
262
|
+
- (void)addPushNotificationDeepLinkPath:(NSArray *)path
|
|
263
|
+
{
|
|
264
|
+
[[AdShiftReactNativePluginHelper shared] addPushNotificationDeepLinkPath:path];
|
|
251
265
|
}
|
|
252
266
|
|
|
253
|
-
- (void)
|
|
254
|
-
|
|
255
|
-
|
|
267
|
+
- (void)handlePushNotification:(NSDictionary *)payload
|
|
268
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
269
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
270
|
+
{
|
|
271
|
+
[[AdShiftReactNativePluginHelper shared] handlePushNotification:payload
|
|
272
|
+
completion:^(BOOL handled) {
|
|
273
|
+
resolve(@(handled));
|
|
274
|
+
}];
|
|
256
275
|
}
|
|
257
276
|
|
|
258
277
|
@end
|