@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.
Files changed (180) hide show
  1. package/AdShiftReactNativePlugin.podspec +11 -7
  2. package/CHANGELOG.md +138 -0
  3. package/README.md +513 -542
  4. package/android/build.gradle +17 -3
  5. package/android/consumer-rules.pro +21 -0
  6. package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +786 -229
  7. package/android/src/test/java/com/adshift/reactnativeplugin/ConsentSnapshotTest.kt +180 -0
  8. package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +146 -0
  9. package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +111 -0
  10. package/android/src/test/java/com/adshift/reactnativeplugin/IntentLinkDedupTest.kt +168 -0
  11. package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +106 -0
  12. package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +167 -0
  13. package/android/src/test/java/com/adshift/reactnativeplugin/StartVerdictTest.kt +164 -0
  14. package/ios/AdShiftReactNativePlugin.h +7 -7
  15. package/ios/AdShiftReactNativePlugin.mm +200 -181
  16. package/ios/AdShiftReactNativePluginHelper.swift +584 -286
  17. package/ios/Core/BridgeRules.swift +82 -0
  18. package/lib/commonjs/Adshift.js +1138 -0
  19. package/lib/commonjs/Adshift.js.map +1 -0
  20. package/lib/commonjs/NativeAdShiftReactNativePlugin.js +22 -0
  21. package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -0
  22. package/lib/commonjs/index.js +94 -0
  23. package/lib/commonjs/index.js.map +1 -0
  24. package/lib/commonjs/jest/index.js +164 -0
  25. package/lib/commonjs/jest/index.js.map +1 -0
  26. package/lib/commonjs/nativeSdkVersions.js +17 -0
  27. package/lib/commonjs/nativeSdkVersions.js.map +1 -0
  28. package/lib/commonjs/package.json +1 -0
  29. package/lib/commonjs/types/AdshiftAdRevenue.js +47 -0
  30. package/lib/commonjs/types/AdshiftAdRevenue.js.map +1 -0
  31. package/lib/commonjs/types/AdshiftConfig.js +45 -0
  32. package/lib/commonjs/types/AdshiftConfig.js.map +1 -0
  33. package/lib/commonjs/types/AdshiftConsent.js +113 -0
  34. package/lib/commonjs/types/AdshiftConsent.js.map +1 -0
  35. package/lib/commonjs/types/AdshiftConsentSnapshot.js +69 -0
  36. package/lib/commonjs/types/AdshiftConsentSnapshot.js.map +1 -0
  37. package/lib/commonjs/types/AdshiftDeepLink.js +154 -0
  38. package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -0
  39. package/lib/commonjs/types/AdshiftError.js +91 -0
  40. package/lib/commonjs/types/AdshiftError.js.map +1 -0
  41. package/lib/commonjs/types/AdshiftEventParam.js +140 -0
  42. package/lib/commonjs/types/AdshiftEventParam.js.map +1 -0
  43. package/lib/commonjs/types/AdshiftEventType.js +88 -0
  44. package/lib/commonjs/types/AdshiftEventType.js.map +1 -0
  45. package/lib/commonjs/types/AdshiftThirdPartySharing.js +70 -0
  46. package/lib/commonjs/types/AdshiftThirdPartySharing.js.map +1 -0
  47. package/lib/commonjs/types/index.js +123 -0
  48. package/lib/commonjs/types/index.js.map +1 -0
  49. package/lib/commonjs/version.js +9 -0
  50. package/lib/commonjs/version.js.map +1 -0
  51. package/lib/module/Adshift.js +962 -296
  52. package/lib/module/Adshift.js.map +1 -1
  53. package/lib/module/NativeAdShiftReactNativePlugin.js +10 -7
  54. package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
  55. package/lib/module/index.js +26 -25
  56. package/lib/module/index.js.map +1 -1
  57. package/lib/module/jest/index.js +144 -0
  58. package/lib/module/jest/index.js.map +1 -0
  59. package/lib/module/nativeSdkVersions.js +13 -0
  60. package/lib/module/nativeSdkVersions.js.map +1 -0
  61. package/lib/module/types/AdshiftAdRevenue.js +43 -0
  62. package/lib/module/types/AdshiftAdRevenue.js.map +1 -0
  63. package/lib/module/types/AdshiftConfig.js +23 -26
  64. package/lib/module/types/AdshiftConfig.js.map +1 -1
  65. package/lib/module/types/AdshiftConsent.js +57 -50
  66. package/lib/module/types/AdshiftConsent.js.map +1 -1
  67. package/lib/module/types/AdshiftConsentSnapshot.js +65 -0
  68. package/lib/module/types/AdshiftConsentSnapshot.js.map +1 -0
  69. package/lib/module/types/AdshiftDeepLink.js +97 -67
  70. package/lib/module/types/AdshiftDeepLink.js.map +1 -1
  71. package/lib/module/types/AdshiftError.js +87 -0
  72. package/lib/module/types/AdshiftError.js.map +1 -0
  73. package/lib/module/types/AdshiftEventParam.js +135 -0
  74. package/lib/module/types/AdshiftEventParam.js.map +1 -0
  75. package/lib/module/types/AdshiftEventType.js +11 -36
  76. package/lib/module/types/AdshiftEventType.js.map +1 -1
  77. package/lib/module/types/AdshiftThirdPartySharing.js +65 -0
  78. package/lib/module/types/AdshiftThirdPartySharing.js.map +1 -0
  79. package/lib/module/types/index.js +9 -7
  80. package/lib/module/types/index.js.map +1 -1
  81. package/lib/module/version.js +5 -0
  82. package/lib/module/version.js.map +1 -0
  83. package/lib/typescript/commonjs/package.json +1 -0
  84. package/lib/typescript/commonjs/src/Adshift.d.ts +314 -0
  85. package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +102 -0
  87. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/src/index.d.ts +51 -0
  89. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/jest/index.d.ts +103 -0
  91. package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +11 -0
  93. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts +56 -0
  95. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +104 -0
  97. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts +76 -0
  99. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts +56 -0
  101. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +89 -0
  103. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts +57 -0
  105. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts +111 -0
  107. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts.map +1 -0
  108. package/lib/typescript/{src → commonjs/src}/types/AdshiftEventType.d.ts +12 -35
  109. package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts +53 -0
  111. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts.map +1 -0
  112. package/lib/typescript/commonjs/src/types/index.d.ts +17 -0
  113. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -0
  114. package/lib/typescript/commonjs/src/version.d.ts +2 -0
  115. package/lib/typescript/commonjs/src/version.d.ts.map +1 -0
  116. package/lib/typescript/module/src/Adshift.d.ts +314 -0
  117. package/lib/typescript/module/src/Adshift.d.ts.map +1 -0
  118. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +102 -0
  119. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -0
  120. package/lib/typescript/module/src/index.d.ts +51 -0
  121. package/lib/typescript/module/src/index.d.ts.map +1 -0
  122. package/lib/typescript/module/src/jest/index.d.ts +103 -0
  123. package/lib/typescript/module/src/jest/index.d.ts.map +1 -0
  124. package/lib/typescript/module/src/nativeSdkVersions.d.ts +11 -0
  125. package/lib/typescript/module/src/nativeSdkVersions.d.ts.map +1 -0
  126. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts +56 -0
  127. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts.map +1 -0
  128. package/lib/typescript/module/src/types/AdshiftConfig.d.ts +104 -0
  129. package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -0
  130. package/lib/typescript/module/src/types/AdshiftConsent.d.ts +76 -0
  131. package/lib/typescript/module/src/types/AdshiftConsent.d.ts.map +1 -0
  132. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts +56 -0
  133. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts.map +1 -0
  134. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +89 -0
  135. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -0
  136. package/lib/typescript/module/src/types/AdshiftError.d.ts +57 -0
  137. package/lib/typescript/module/src/types/AdshiftError.d.ts.map +1 -0
  138. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts +111 -0
  139. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts.map +1 -0
  140. package/lib/typescript/module/src/types/AdshiftEventType.d.ts +64 -0
  141. package/lib/typescript/module/src/types/AdshiftEventType.d.ts.map +1 -0
  142. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts +53 -0
  143. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts.map +1 -0
  144. package/lib/typescript/module/src/types/index.d.ts +17 -0
  145. package/lib/typescript/module/src/types/index.d.ts.map +1 -0
  146. package/lib/typescript/module/src/version.d.ts +2 -0
  147. package/lib/typescript/module/src/version.d.ts.map +1 -0
  148. package/package.json +50 -11
  149. package/src/Adshift.ts +1276 -342
  150. package/src/NativeAdShiftReactNativePlugin.ts +81 -115
  151. package/src/index.tsx +40 -25
  152. package/src/jest/index.ts +224 -0
  153. package/src/nativeSdkVersions.ts +10 -0
  154. package/src/types/AdshiftAdRevenue.ts +58 -0
  155. package/src/types/AdshiftConfig.ts +101 -53
  156. package/src/types/AdshiftConsent.ts +75 -72
  157. package/src/types/AdshiftConsentSnapshot.ts +103 -0
  158. package/src/types/AdshiftDeepLink.ts +123 -102
  159. package/src/types/AdshiftError.ts +107 -0
  160. package/src/types/AdshiftEventParam.ts +216 -0
  161. package/src/types/AdshiftEventType.ts +13 -35
  162. package/src/types/AdshiftThirdPartySharing.ts +63 -0
  163. package/src/types/index.ts +38 -6
  164. package/src/version.ts +2 -0
  165. package/lib/typescript/src/Adshift.d.ts +0 -335
  166. package/lib/typescript/src/Adshift.d.ts.map +0 -1
  167. package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts +0 -143
  168. package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts.map +0 -1
  169. package/lib/typescript/src/index.d.ts +0 -47
  170. package/lib/typescript/src/index.d.ts.map +0 -1
  171. package/lib/typescript/src/types/AdshiftConfig.d.ts +0 -74
  172. package/lib/typescript/src/types/AdshiftConfig.d.ts.map +0 -1
  173. package/lib/typescript/src/types/AdshiftConsent.d.ts +0 -88
  174. package/lib/typescript/src/types/AdshiftConsent.d.ts.map +0 -1
  175. package/lib/typescript/src/types/AdshiftDeepLink.d.ts +0 -93
  176. package/lib/typescript/src/types/AdshiftDeepLink.d.ts.map +0 -1
  177. package/lib/typescript/src/types/AdshiftEventType.d.ts.map +0 -1
  178. package/lib/typescript/src/types/index.d.ts +0 -5
  179. package/lib/typescript/src/types/index.d.ts.map +0 -1
  180. /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
- // Bridges React Native JS to Swift SDK via AdShiftReactNativePluginHelper.
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
- // Fallback for development builds
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
- BOOL _hasListeners;
50
+ BOOL _invalidated;
26
51
  }
27
52
 
28
53
  RCT_EXPORT_MODULE(AdShiftReactNativePlugin)
29
54
 
30
- // MARK: - Module Setup
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
- return std::make_shared<facebook::react::NativeAdShiftReactNativePluginSpecJSI>(params);
77
+ (const facebook::react::ObjCTurboModule::InitParams &)params
78
+ {
79
+ return std::make_shared<facebook::react::NativeAdShiftReactNativePluginSpecJSI>(params);
35
80
  }
36
81
 
37
- // MARK: - Event Emitter Support
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
- - (NSArray<NSString *> *)supportedEvents {
40
- return @[@"onDeepLink"];
97
+ - (void)initialize:(NSDictionary *)config
98
+ {
99
+ [[AdShiftReactNativePluginHelper shared] initializeWithConfig:config];
41
100
  }
42
101
 
43
- - (void)startObserving {
44
- _hasListeners = YES;
45
-
46
- // Register deep link callback with Swift helper
47
- if (@available(iOS 15.0, *)) {
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)stopObserving {
57
- _hasListeners = NO;
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
- // MARK: - Lifecycle Methods
114
+ #pragma mark - Configuration
65
115
 
66
- - (void)initialize:(NSDictionary *)config {
67
- RCTLogInfo(@"[AdShift] Initializing SDK with config");
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)start:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
77
- RCTLogInfo(@"[AdShift] Starting SDK");
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)stop {
93
- RCTLogInfo(@"[AdShift] Stopping SDK");
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
- - (NSNumber *)isStarted {
101
- if (@available(iOS 15.0, *)) {
102
- BOOL started = [[AdShiftReactNativePluginHelper shared] isStarted];
103
- return @(started);
104
- }
105
- return @NO;
131
+ - (void)setBrandedDomains:(NSArray *)domains
132
+ {
133
+ [[AdShiftReactNativePluginHelper shared] setBrandedDomains:domains];
106
134
  }
107
135
 
108
- // MARK: - Configuration Methods
136
+ - (void)setMetaAppId:(NSString *)appId
137
+ {
138
+ [[AdShiftReactNativePluginHelper shared] setMetaAppId:appId];
139
+ }
109
140
 
110
- - (void)setCustomerUserId:(NSString *)userId {
111
- RCTLogInfo(@"[AdShift] Setting customer user ID");
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
- - (void)setDebugEnabled:(BOOL)enabled {
119
- RCTLogInfo(@"[AdShift] Setting debug enabled: %@", enabled ? @"YES" : @"NO");
120
-
121
- if (@available(iOS 15.0, *)) {
122
- [[AdShiftReactNativePluginHelper shared] setDebugEnabled:enabled];
123
- }
146
+ #pragma mark - Consent
147
+
148
+ - (void)setConsentData:(NSDictionary *)consent
149
+ {
150
+ [[AdShiftReactNativePluginHelper shared] setConsentData:consent];
124
151
  }
125
152
 
126
- - (void)setAppOpenDebounceMs:(double)ms {
127
- RCTLogInfo(@"[AdShift] Setting app open debounce: %.0fms", ms);
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
- // MARK: - Consent Methods
158
+ - (void)enableGPPDataCollection:(BOOL)enabled
159
+ {
160
+ [[AdShiftReactNativePluginHelper shared] enableGPPDataCollection:enabled];
161
+ }
135
162
 
136
- - (void)setConsentData:(NSDictionary *)consent {
137
- RCTLogInfo(@"[AdShift] Setting consent data");
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)enableTCFDataCollection:(BOOL)enabled {
145
- RCTLogInfo(@"[AdShift] Setting TCF data collection: %@", enabled ? @"YES" : @"NO");
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
- RCTLogInfo(@"[AdShift] Refreshing consent");
154
-
155
- if (@available(iOS 15.0, *)) {
156
- [[AdShiftReactNativePluginHelper shared] refreshConsentWithCompletion:^(NSDictionary *result, NSError *error) {
157
- if (error) {
158
- reject(@"CONSENT_ERROR", error.localizedDescription, error);
159
- } else {
160
- resolve(result ?: @{});
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
- // MARK: - Event Tracking Methods
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
- RCTLogInfo(@"[AdShift] Tracking event: %@", eventName);
175
-
176
- if (@available(iOS 15.0, *)) {
177
- [[AdShiftReactNativePluginHelper shared] trackEvent:eventName
178
- values:values
179
- completion:^(NSDictionary *result, NSError *error) {
180
- if (error) {
181
- reject(@"TRACK_ERROR", error.localizedDescription, error);
182
- } else {
183
- resolve(nil);
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
- RCTLogInfo(@"[AdShift] Tracking purchase: %@", productId);
198
-
199
- if (@available(iOS 15.0, *)) {
200
- [[AdShiftReactNativePluginHelper shared] trackPurchaseWithProductId:productId
201
- price:price
202
- currency:currency
203
- token:token
204
- completion:^(NSDictionary *result, NSError *error) {
205
- if (error) {
206
- reject(@"TRACK_ERROR", error.localizedDescription, error);
207
- } else {
208
- resolve(nil);
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
- // MARK: - Deep Link Methods
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
- RCTLogInfo(@"[AdShift] Handling deep link: %@", url);
222
-
223
- if (@available(iOS 15.0, *)) {
224
- [[AdShiftReactNativePluginHelper shared] handleDeepLink:url
225
- completion:^(NSDictionary *result, NSError *error) {
226
- if (error) {
227
- // Return error as result, not reject (consistent with TypeScript API)
228
- resolve(@{
229
- @"status": @"error",
230
- @"errorMessage": error.localizedDescription,
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
- // MARK: - Event Emitter Required Methods
247
-
248
- - (void)addListener:(NSString *)eventType {
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)removeListeners:(double)count {
254
- // Required by NativeEventEmitter
255
- // Actual cleanup done in stopObserving
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