@adshift/react-native-plugin 3.0.0 → 3.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 (176) hide show
  1. package/AdShiftReactNativePlugin.podspec +20 -4
  2. package/CHANGELOG.md +30 -17
  3. package/README.md +55 -47
  4. package/android/build.gradle +2 -3
  5. package/android/consumer-rules.pro +2 -21
  6. package/android/src/main/AndroidManifest.xml +1 -1
  7. package/android/src/main/java/com/adshift/reactnativeplugin/ActivityIntents.kt +307 -0
  8. package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +83 -157
  9. package/android/src/test/java/com/adshift/reactnativeplugin/ConsentSnapshotTest.kt +0 -20
  10. package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +0 -4
  11. package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +37 -5
  12. package/android/src/test/java/com/adshift/reactnativeplugin/IntentLinkDedupTest.kt +0 -5
  13. package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +7 -26
  14. package/android/src/test/java/com/adshift/reactnativeplugin/LaunchLinkRecordTest.kt +420 -0
  15. package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +93 -34
  16. package/android/src/test/java/com/adshift/reactnativeplugin/StartVerdictTest.kt +0 -4
  17. package/ios/AdShiftReactNativePlugin.h +0 -12
  18. package/ios/AdShiftReactNativePlugin.mm +2 -14
  19. package/ios/AdShiftReactNativePluginHelper.swift +14 -73
  20. package/ios/Core/BridgeRules.swift +24 -29
  21. package/lib/commonjs/Adshift.js +78 -285
  22. package/lib/commonjs/Adshift.js.map +1 -1
  23. package/lib/commonjs/NativeAdShiftReactNativePlugin.js +2 -11
  24. package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -1
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/jest/index.js +4 -18
  27. package/lib/commonjs/jest/index.js.map +1 -1
  28. package/lib/commonjs/nativeSdkVersions.js +4 -6
  29. package/lib/commonjs/nativeSdkVersions.js.map +1 -1
  30. package/lib/commonjs/types/AdshiftAdRevenue.js +0 -24
  31. package/lib/commonjs/types/AdshiftAdRevenue.js.map +1 -1
  32. package/lib/commonjs/types/AdshiftConfig.js +3 -24
  33. package/lib/commonjs/types/AdshiftConfig.js.map +1 -1
  34. package/lib/commonjs/types/AdshiftConsent.js +9 -45
  35. package/lib/commonjs/types/AdshiftConsent.js.map +1 -1
  36. package/lib/commonjs/types/AdshiftConsentSnapshot.js +5 -24
  37. package/lib/commonjs/types/AdshiftConsentSnapshot.js.map +1 -1
  38. package/lib/commonjs/types/AdshiftDeepLink.js +3 -30
  39. package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -1
  40. package/lib/commonjs/types/AdshiftError.js +7 -27
  41. package/lib/commonjs/types/AdshiftError.js.map +1 -1
  42. package/lib/commonjs/types/AdshiftEventParam.js +4 -38
  43. package/lib/commonjs/types/AdshiftEventParam.js.map +1 -1
  44. package/lib/commonjs/types/AdshiftEventType.js +1 -39
  45. package/lib/commonjs/types/AdshiftEventType.js.map +1 -1
  46. package/lib/commonjs/types/AdshiftThirdPartySharing.js +7 -38
  47. package/lib/commonjs/types/AdshiftThirdPartySharing.js.map +1 -1
  48. package/lib/commonjs/version.js +1 -1
  49. package/lib/module/Adshift.js +78 -285
  50. package/lib/module/Adshift.js.map +1 -1
  51. package/lib/module/NativeAdShiftReactNativePlugin.js +2 -12
  52. package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
  53. package/lib/module/index.js +1 -46
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/jest/index.js +4 -18
  56. package/lib/module/jest/index.js.map +1 -1
  57. package/lib/module/nativeSdkVersions.js +4 -6
  58. package/lib/module/nativeSdkVersions.js.map +1 -1
  59. package/lib/module/types/AdshiftAdRevenue.js +0 -24
  60. package/lib/module/types/AdshiftAdRevenue.js.map +1 -1
  61. package/lib/module/types/AdshiftConfig.js +3 -24
  62. package/lib/module/types/AdshiftConfig.js.map +1 -1
  63. package/lib/module/types/AdshiftConsent.js +9 -45
  64. package/lib/module/types/AdshiftConsent.js.map +1 -1
  65. package/lib/module/types/AdshiftConsentSnapshot.js +5 -24
  66. package/lib/module/types/AdshiftConsentSnapshot.js.map +1 -1
  67. package/lib/module/types/AdshiftDeepLink.js +3 -31
  68. package/lib/module/types/AdshiftDeepLink.js.map +1 -1
  69. package/lib/module/types/AdshiftError.js +7 -28
  70. package/lib/module/types/AdshiftError.js.map +1 -1
  71. package/lib/module/types/AdshiftEventParam.js +4 -38
  72. package/lib/module/types/AdshiftEventParam.js.map +1 -1
  73. package/lib/module/types/AdshiftEventType.js +1 -39
  74. package/lib/module/types/AdshiftEventType.js.map +1 -1
  75. package/lib/module/types/AdshiftThirdPartySharing.js +7 -38
  76. package/lib/module/types/AdshiftThirdPartySharing.js.map +1 -1
  77. package/lib/module/version.js +1 -1
  78. package/lib/typescript/commonjs/src/Adshift.d.ts +61 -185
  79. package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +10 -36
  81. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/src/index.d.ts +0 -32
  83. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  84. package/lib/typescript/commonjs/src/jest/index.d.ts +6 -20
  85. package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +4 -6
  87. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts +0 -24
  89. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +10 -37
  91. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts +9 -49
  93. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts +10 -28
  95. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +6 -34
  97. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts +7 -26
  99. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts +3 -19
  101. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts.map +1 -1
  102. package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts +1 -23
  103. package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts +7 -38
  105. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/src/version.d.ts +1 -1
  107. package/lib/typescript/module/src/Adshift.d.ts +61 -185
  108. package/lib/typescript/module/src/Adshift.d.ts.map +1 -1
  109. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +10 -36
  110. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  111. package/lib/typescript/module/src/index.d.ts +0 -32
  112. package/lib/typescript/module/src/index.d.ts.map +1 -1
  113. package/lib/typescript/module/src/jest/index.d.ts +6 -20
  114. package/lib/typescript/module/src/jest/index.d.ts.map +1 -1
  115. package/lib/typescript/module/src/nativeSdkVersions.d.ts +4 -6
  116. package/lib/typescript/module/src/nativeSdkVersions.d.ts.map +1 -1
  117. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts +0 -24
  118. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts.map +1 -1
  119. package/lib/typescript/module/src/types/AdshiftConfig.d.ts +10 -37
  120. package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -1
  121. package/lib/typescript/module/src/types/AdshiftConsent.d.ts +9 -49
  122. package/lib/typescript/module/src/types/AdshiftConsent.d.ts.map +1 -1
  123. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts +10 -28
  124. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
  125. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +6 -34
  126. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -1
  127. package/lib/typescript/module/src/types/AdshiftError.d.ts +7 -26
  128. package/lib/typescript/module/src/types/AdshiftError.d.ts.map +1 -1
  129. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts +3 -19
  130. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts.map +1 -1
  131. package/lib/typescript/module/src/types/AdshiftEventType.d.ts +1 -23
  132. package/lib/typescript/module/src/types/AdshiftEventType.d.ts.map +1 -1
  133. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts +7 -38
  134. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
  135. package/lib/typescript/module/src/version.d.ts +1 -1
  136. package/package.json +11 -1
  137. package/src/Adshift.ts +82 -286
  138. package/src/NativeAdShiftReactNativePlugin.ts +10 -48
  139. package/src/index.tsx +1 -44
  140. package/src/jest/index.ts +6 -20
  141. package/src/nativeSdkVersions.ts +4 -6
  142. package/src/types/AdshiftAdRevenue.ts +0 -24
  143. package/src/types/AdshiftConfig.ts +11 -54
  144. package/src/types/AdshiftConsent.ts +9 -49
  145. package/src/types/AdshiftConsentSnapshot.ts +11 -38
  146. package/src/types/AdshiftDeepLink.ts +6 -34
  147. package/src/types/AdshiftError.ts +7 -26
  148. package/src/types/AdshiftEventParam.ts +4 -38
  149. package/src/types/AdshiftEventType.ts +1 -39
  150. package/src/types/AdshiftThirdPartySharing.ts +7 -38
  151. package/src/version.ts +1 -1
  152. package/vendor/ios/AdshiftSDK.files.json +30 -0
  153. package/vendor/ios/AdshiftSDK.xcframework/Info.plist +44 -0
  154. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/AdshiftSDK +0 -0
  155. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +315 -0
  156. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Info.plist +0 -0
  157. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.abi.json +18729 -0
  158. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +414 -0
  159. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  160. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftinterface +414 -0
  161. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/module.modulemap +4 -0
  162. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
  163. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/AdshiftSDK +0 -0
  164. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +626 -0
  165. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Info.plist +0 -0
  166. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +18729 -0
  167. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +414 -0
  168. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  169. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +414 -0
  170. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +18729 -0
  171. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +414 -0
  172. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  173. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +414 -0
  174. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/module.modulemap +4 -0
  175. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
  176. package/android/src/main/java/com/adshift/reactnativeplugin/RestoredIntents.kt +0 -64
@@ -30,26 +30,20 @@ import com.facebook.react.bridge.ReadableType
30
30
  import com.facebook.react.bridge.WritableMap
31
31
  import com.facebook.react.module.annotations.ReactModule
32
32
  import java.lang.ref.WeakReference
33
- import java.security.MessageDigest
34
33
  import java.util.Collections
35
34
  import java.util.WeakHashMap
36
35
  import java.util.concurrent.atomic.AtomicBoolean
37
36
  import org.json.JSONObject
38
37
 
39
38
  /**
40
- * AdShift TurboModule for Android.
41
- *
42
- * Bridges the JavaScript contract (`NativeAdShiftReactNativePlugin.ts`) to the
43
- * AdShift Android SDK. Deep link results are delivered exclusively through the
44
- * `onDeepLink` event; the SDK listener is registered once per process and
45
- * forwards to whichever module instance is current, so results keep flowing
46
- * across JavaScript reloads.
39
+ * Deep link results reach JavaScript only through `onDeepLink`. The SDK listener is registered
40
+ * once per process and forwards to the current module instance, so it survives JavaScript reloads.
47
41
  */
48
42
  @ReactModule(name = AdShiftReactNativePluginModule.NAME)
49
43
  class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationContext) :
50
44
  NativeAdShiftReactNativePluginSpec(reactContext), ActivityEventListener, LifecycleEventListener {
51
45
 
52
- /** Error codes surfaced to JavaScript as the rejection `code`. */
46
+ /** Must match `AdshiftErrorCode` in JavaScript. */
53
47
  private object ErrorCode {
54
48
  const val NOT_INITIALIZED = "NOT_INITIALIZED"
55
49
  const val NOT_STARTED = "NOT_STARTED"
@@ -60,35 +54,31 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
60
54
  const val UNKNOWN = "UNKNOWN"
61
55
  }
62
56
 
63
- /** Values passed to `AdShiftRequestListener.onError` (SDK `RequestError` codes). */
57
+ /** Codes `AdShiftRequestListener.onError` passes. */
64
58
  private object SdkErrorCode {
65
59
  const val STOP_TRACKING = 12
66
60
  const val NO_DEV_KEY = 41
67
61
  const val QUEUE_FULL = 51
68
62
  }
69
63
 
70
- /** An Intent received before `initialize`, kept until the SDK can process it. */
71
- private class StoredIntent(val intent: Intent, val fromLaunchPath: Boolean)
72
-
73
64
  companion object {
74
65
  const val NAME = "AdShiftReactNativePlugin"
75
66
 
76
67
  private const val TAG = "AdShiftRN"
77
68
  private const val AUTO_FORWARD_DEDUP_WINDOW_MS = 2_000L
78
- private const val META_APP_LINK_EXTRA = "al_applink_data"
79
69
 
80
- /** Deep link results kept while no JavaScript listener can receive them. */
70
+ /** Same value as on iOS. */
71
+ private const val WRAPPER = "react_native"
72
+
81
73
  private const val PENDING_DEEP_LINK_LIMIT = 20
82
74
 
83
- /** How deep to look for links inside JSON carried by Intent extras. */
84
75
  private const val EXTRAS_URL_SEARCH_DEPTH = 3
85
76
 
86
77
  private const val LAUNCH_URL_MEMORY_LIMIT = 20
87
78
 
88
- /** How long `start` waits for the SDK listener before answering optimistically. */
89
79
  private const val START_VERDICT_TIMEOUT_MS = 5_000L
90
80
 
91
- /** Keys the SDK sets itself when building the ad revenue event. */
81
+ /** Set from the required fields, so they are dropped from `additionalParameters`. */
92
82
  private val RESERVED_AD_REVENUE_KEYS = setOf(
93
83
  ASInAppEventParameterName.REVENUE,
94
84
  ASInAppEventParameterName.CURRENCY,
@@ -96,7 +86,7 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
96
86
  ASInAppEventParameterName.AD_REVENUE_NETWORK_NAME,
97
87
  )
98
88
 
99
- /** Single main-thread queue shared by `start` and `stop` so call order is preserved. */
89
+ /** One main-thread queue, so `start` and `stop` run in the order they were called. */
100
90
  private val mainHandler = Handler(Looper.getMainLooper())
101
91
 
102
92
  private val lock = Any()
@@ -104,34 +94,24 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
104
94
  @Volatile private var currentModule: WeakReference<AdShiftReactNativePluginModule>? = null
105
95
  @Volatile private var sdkInitialized = false
106
96
 
107
- /** Set once the SDK is initialised *and* the `initialize` options have been applied. */
108
97
  @Volatile private var readyForIntents = false
109
98
  @Volatile private var deepLinkListenerRegistered = false
110
99
  @Volatile private var autoHandleDeepLinks = true
111
100
  @Volatile private var collectOaidApplied = false
112
101
 
113
102
  // Guarded by [lock].
114
- private var pendingIntent: StoredIntent? = null
115
- private var lastLaunchIntentFingerprint: String? = null
103
+ private var pendingIntent: Intent? = null
116
104
  private val processedIntents: MutableSet<Intent> =
117
105
  Collections.newSetFromMap(WeakHashMap<Intent, Boolean>())
118
106
  private val autoForwardedUrls = HashMap<String, Long>()
119
107
 
120
- /**
121
- * URLs that opened this process, kept until it dies. Reloading JavaScript replays the
122
- * launch URL, and that replay can arrive long after the two second window has closed.
123
- * A new tap arrives as a new Intent, so it is unaffected.
124
- */
108
+ /** Kept until the process dies: a `fromLaunch` replay after a reload can come much later. */
125
109
  private val launchForwardedUrls = LinkedHashSet<String>()
126
110
 
127
111
  private val registeredPushPaths = HashSet<String>()
128
112
  private val pendingDeepLinks = ArrayDeque<DeepLinkResult>()
129
113
 
130
- /**
131
- * Forwards an SDK deep link result to the current module instance, keeping it for the
132
- * next one when JavaScript cannot receive it yet — a result is delivered once, and a
133
- * reload must not consume it.
134
- */
114
+ /** Keeps a result until JavaScript can receive it: each result is reported only once. */
135
115
  private fun dispatchDeepLink(result: DeepLinkResult) {
136
116
  if (currentModule?.get()?.emitDeepLink(result) == true) return
137
117
  synchronized(lock) {
@@ -159,16 +139,12 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
159
139
 
160
140
  @Volatile private var invalidated = false
161
141
 
162
- /**
163
- * The emitter callback of the generated base class is not volatile, and deep links arrive on an
164
- * SDK thread. This flag publishes the callback to that thread, so a result is buffered rather
165
- * than read against a stale null and lost.
166
- */
142
+ /** Publishes the non-volatile emitter callback to the thread deep link results arrive on. */
167
143
  @Volatile private var emitterAttached = false
168
144
 
169
145
  init {
170
146
  synchronized(lock) { currentModule = WeakReference(this) }
171
- RestoredIntents.register(reactContext)
147
+ ActivityIntents.register(reactContext)
172
148
  reactContext.addActivityEventListener(this)
173
149
  reactContext.addLifecycleEventListener(this)
174
150
  }
@@ -185,8 +161,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
185
161
  super.invalidate()
186
162
  }
187
163
 
188
- // ============ Lifecycle ============
189
-
190
164
  override fun initialize(config: ReadableMap) {
191
165
  val apiKey = optString(config, "apiKey")
192
166
  if (apiKey.isNullOrBlank()) {
@@ -215,6 +189,12 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
215
189
  logFailure("initialize", e)
216
190
  return
217
191
  }
192
+ // On its own: a failure here must not keep links and options from the SDK.
193
+ try {
194
+ AdShiftLib.setWrapper(WRAPPER)
195
+ } catch (e: Exception) {
196
+ logFailure("setWrapper", e)
197
+ }
218
198
 
219
199
  applyOptions(config)
220
200
  autoHandleDeepLinks = optBoolean(config, "autoHandleDeepLinks") ?: true
@@ -223,11 +203,10 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
223
203
 
224
204
  val stored = synchronized(lock) { pendingIntent.also { pendingIntent = null } }
225
205
  if (!autoHandleDeepLinks) return
226
- stored?.let { processIntent(it.intent, it.fromLaunchPath) }
227
- processIntent(reactContext.currentActivity?.intent, fromLaunchPath = true)
206
+ stored?.let(::processIntent)
207
+ processCurrentActivityIntent()
228
208
  }
229
209
 
230
- /** Applies the optional `initialize` keys; absent keys leave SDK defaults untouched. */
231
210
  private fun applyOptions(config: ReadableMap) {
232
211
  try {
233
212
  optBoolean(config, "isDebug")?.let { AdShiftLib.setDebugLog(it) }
@@ -254,10 +233,8 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
254
233
  }
255
234
 
256
235
  /**
257
- * Answers from the SDK listener rather than from the call returning, so a device that opted
258
- * out is reported as such instead of looking like a successful start. The listener answers on
259
- * the main thread, and [START_VERDICT_TIMEOUT_MS] bounds the promise in case the answer comes
260
- * later than the call.
236
+ * Resolves with the SDK's answer, so an opted-out device or a rejected key is reported. With no
237
+ * answer within [START_VERDICT_TIMEOUT_MS], it resolves as started with `pending`.
261
238
  */
262
239
  override fun start(promise: Promise) {
263
240
  if (!sdkInitialized) {
@@ -310,11 +287,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
310
287
  }
311
288
  }
312
289
 
313
- /**
314
- * The listener answers only once the SDK holds a usable key, so a success
315
- * callback is itself the verdict. Silence within the window below means the
316
- * answer is still outstanding, which is what `pending` reports.
317
- */
318
290
  private fun startSucceeded(apiKeyValidationStatus: String): WritableMap =
319
291
  Arguments.createMap().apply {
320
292
  putBoolean("success", true)
@@ -342,8 +314,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
342
314
  }
343
315
  }
344
316
 
345
- // ============ Configuration ============
346
-
347
317
  override fun setCustomerUserId(userId: String) {
348
318
  try {
349
319
  AdShiftLib.setCustomerUserId(userId)
@@ -392,8 +362,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
392
362
  }
393
363
  }
394
364
 
395
- // ============ Consent ============
396
-
397
365
  override fun setConsentData(consent: ReadableMap) {
398
366
  try {
399
367
  val subjectToGdpr = optBoolean(consent, "isUserSubjectToGDPR") ?: false
@@ -429,12 +397,8 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
429
397
  }
430
398
 
431
399
  /**
432
- * A missing or non-boolean `optOut` is dropped rather than defaulted.
433
- *
434
- * This axis has the opposite polarity to consent: `false` is the app
435
- * declaring that sharing is allowed, not the absence of an answer. Guessing
436
- * either way from a malformed call would record a declaration the user never
437
- * made, and the wrong guess cannot be undone for events already sent.
400
+ * A missing or non-boolean `optOut` is dropped, not defaulted: either default would declare
401
+ * something the app never said.
438
402
  */
439
403
  override fun setThirdPartySharing(sharing: ReadableMap) {
440
404
  try {
@@ -481,10 +445,8 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
481
445
  }
482
446
 
483
447
  /**
484
- * Whether consent lets the SDK use the advertising identifier.
485
- *
486
- * Storage and data usage both have to be allowed. Under GDPR an undecided
487
- * flag counts as a refusal; outside it, only an explicit denial does.
448
+ * The Android rule, which differs from the iOS one: under GDPR an undecided flag counts as a
449
+ * refusal; outside it, only an explicit denial does.
488
450
  */
489
451
  private fun adIdentifiersAllowed(snapshot: ConsentSnapshot): Boolean {
490
452
  val storage = snapshot.adStorageEnabled
@@ -496,8 +458,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
496
458
  }
497
459
  }
498
460
 
499
- // ============ Event Tracking ============
500
-
501
461
  override fun trackEvent(eventName: String, values: ReadableMap?, promise: Promise) {
502
462
  try {
503
463
  AdShiftLib.trackEvent(
@@ -584,8 +544,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
584
544
  }
585
545
  }
586
546
 
587
- // ============ Identity ============
588
-
589
547
  override fun getAdShiftDeviceId(promise: Promise) {
590
548
  try {
591
549
  promise.resolve(AdShiftLib.getAdShiftDeviceId())
@@ -594,8 +552,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
594
552
  }
595
553
  }
596
554
 
597
- // ============ Deep Links ============
598
-
599
555
  override fun handleDeepLink(url: String, fromLaunch: Boolean, promise: Promise) {
600
556
  val uri = Uri.parse(url)
601
557
  val scheme = uri.scheme
@@ -609,6 +565,21 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
609
565
  return
610
566
  }
611
567
 
568
+ // On the main thread: React Native emits `url` before this module sees the new Intent.
569
+ onMainThread {
570
+ try {
571
+ forwardLink(url, uri, fromLaunch, promise)
572
+ } catch (e: Exception) {
573
+ rejectWith(promise, e)
574
+ }
575
+ }
576
+ }
577
+
578
+ private fun onMainThread(block: () -> Unit) {
579
+ if (Looper.myLooper() == Looper.getMainLooper()) block() else mainHandler.post(block)
580
+ }
581
+
582
+ private fun forwardLink(url: String, uri: Uri, fromLaunch: Boolean, promise: Promise) {
612
583
  val now = System.currentTimeMillis()
613
584
  val alreadyForwarded = synchronized(lock) {
614
585
  pruneAutoForwarded(now)
@@ -620,18 +591,36 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
620
591
  promise.resolve(null)
621
592
  return
622
593
  }
594
+
595
+ val launch = launchCreationFor(url)
596
+ val launchKey = LaunchRecords.urlKey(url)
597
+ if (launch != null && launch.mayBeRestored && LaunchRecords.contains(launch, launchKey)) {
598
+ Log.d(TAG, "handleDeepLink: launch link of a re-created activity, already forwarded")
599
+ promise.resolve(null)
600
+ return
601
+ }
623
602
  if (fromLaunch) {
624
603
  synchronized(lock) { rememberLaunchUrls(setOf(url)) }
625
604
  }
626
605
 
627
606
  try {
628
607
  AdShiftLib.handleAppLinkIntent(Intent(Intent.ACTION_VIEW, uri))
608
+ launch?.let { LaunchRecords.add(it, launchKey) }
629
609
  promise.resolve(null)
630
610
  } catch (e: Exception) {
631
611
  rejectWith(promise, e)
632
612
  }
633
613
  }
634
614
 
615
+ private fun launchCreationFor(url: String): ActivityIntents.Creation? {
616
+ val activity = reactContext.currentActivity ?: return null
617
+ ActivityIntents.adopt(activity)
618
+ if (ActivityIntents.hasReceivedNewIntent(activity)) return null
619
+ val intent = activity.intent ?: return null
620
+ val creation = ActivityIntents.creationOf(intent) ?: return null
621
+ return creation.takeIf { intent.dataString == url }
622
+ }
623
+
635
624
  /** The clipboard lookup exists on iOS only. */
636
625
  override fun handlePastedDeepLink(url: String?) = Unit
637
626
 
@@ -644,7 +633,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
644
633
  registerPushPath(keys)
645
634
  }
646
635
 
647
- /** Registers a push payload key path once per process. */
648
636
  private fun registerPushPath(path: List<String>) {
649
637
  val id = path.joinToString("\u001F")
650
638
  synchronized(lock) {
@@ -666,9 +654,7 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
666
654
  }
667
655
  }
668
656
 
669
- /**
670
- * Returns false when JavaScript could not receive the result, so the caller can keep it.
671
- */
657
+ /** Returns false when JavaScript could not receive the result, so the caller can keep it. */
672
658
  private fun emitDeepLink(result: DeepLinkResult): Boolean {
673
659
  if (invalidated || !emitterAttached || mEventEmitterCallback == null) return false
674
660
  return try {
@@ -686,7 +672,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
686
672
  flushPendingDeepLinks()
687
673
  }
688
674
 
689
- /** Delivers results that arrived while no JavaScript listener was reachable, oldest first. */
690
675
  private fun flushPendingDeepLinks() {
691
676
  val pending = synchronized(lock) {
692
677
  if (pendingDeepLinks.isEmpty()) return
@@ -699,16 +684,16 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
699
684
  }
700
685
  }
701
686
 
702
- // ============ Intent forwarding ============
687
+ private fun processCurrentActivityIntent() {
688
+ val activity = reactContext.currentActivity ?: return
689
+ ActivityIntents.adopt(activity)
690
+ processIntent(activity.intent)
691
+ }
703
692
 
704
- /**
705
- * Forwards an Intent to the SDK once. Intents that arrive before `initialize`
706
- * are kept (newest wins) and processed when the SDK becomes available.
707
- */
708
- private fun processIntent(intent: Intent?, fromLaunchPath: Boolean) {
693
+ private fun processIntent(intent: Intent?) {
709
694
  if (intent == null) return
710
695
  if (!readyForIntents) {
711
- synchronized(lock) { pendingIntent = StoredIntent(intent, fromLaunchPath) }
696
+ synchronized(lock) { pendingIntent = intent }
712
697
  return
713
698
  }
714
699
  if (!autoHandleDeepLinks) return
@@ -716,26 +701,19 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
716
701
  Log.d(TAG, "intent skipped (history)")
717
702
  return
718
703
  }
719
- if (intent in RestoredIntents) {
720
- Log.d(TAG, "intent skipped (recreated)")
721
- return
722
- }
723
704
  val firstSeen = synchronized(lock) { processedIntents.add(intent) }
724
705
  if (!firstSeen) {
725
706
  Log.d(TAG, "intent skipped (duplicate)")
726
707
  return
727
708
  }
728
- if (fromLaunchPath) {
729
- val fingerprint = fingerprintOf(intent)
730
- val alreadySeen = synchronized(lock) {
731
- (lastLaunchIntentFingerprint == fingerprint).also { seen ->
732
- if (!seen) lastLaunchIntentFingerprint = fingerprint
733
- }
734
- }
735
- if (alreadySeen) {
736
- Log.d(TAG, "intent skipped (launch)")
737
- return
738
- }
709
+ // The key from creation: another library may have added extras to the Intent since.
710
+ val creation = ActivityIntents.creationOf(intent)
711
+ val key = creation?.intentKey
712
+ if (creation != null && key != null && creation.mayBeRestored &&
713
+ LaunchRecords.contains(creation, key)
714
+ ) {
715
+ Log.d(TAG, "intent skipped (recreated)")
716
+ return
739
717
  }
740
718
 
741
719
  try {
@@ -744,6 +722,7 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
744
722
  } catch (e: Exception) {
745
723
  Log.d(TAG, "intent processing failed: ${e.javaClass.simpleName}")
746
724
  }
725
+ if (creation != null && key != null) LaunchRecords.add(creation, key)
747
726
 
748
727
  val forwarded = linkedSetOf<String>()
749
728
  intent.dataString?.let { forwarded += it }
@@ -759,7 +738,7 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
759
738
  Log.d(TAG, "intent processed")
760
739
  }
761
740
 
762
- /** Guarded by [lock]. Keeps the newest entries so the set cannot grow without bound. */
741
+ /** Must be called with [lock] held. */
763
742
  private fun rememberLaunchUrls(urls: Set<String>) {
764
743
  for (url in urls) {
765
744
  launchForwardedUrls.remove(url)
@@ -772,51 +751,7 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
772
751
  }
773
752
  }
774
753
 
775
- /**
776
- * Identifies a single Intent delivery, so an Activity recreated with the same Intent is
777
- * recognised while a genuinely new delivery is not. Covers the data URI, the Meta App Link
778
- * payload and the extras, because notification taps carry no data URI and are told apart
779
- * only by their extras.
780
- */
781
- private fun fingerprintOf(intent: Intent): String {
782
- val data = intent.dataString ?: ""
783
- val appLink = runCatching {
784
- @Suppress("DEPRECATION")
785
- when (val extra = intent.extras?.get(META_APP_LINK_EXTRA)) {
786
- is String -> extra
787
- is android.os.Bundle -> extra.getString("target_url") ?: ""
788
- else -> ""
789
- }
790
- }.getOrDefault("")
791
- val payload = "$data|$appLink|${extrasFingerprint(intent)}"
792
- val digest = MessageDigest.getInstance("SHA-256").digest(payload.toByteArray())
793
- return digest.joinToString("") { "%02x".format(it) }
794
- }
795
-
796
- /**
797
- * Extras rendered in a stable order. Only values whose textual form survives re-parcelling
798
- * are included, so the digest stays equal for the same delivery.
799
- */
800
- private fun extrasFingerprint(intent: Intent): String = runCatching {
801
- val extras = intent.extras ?: return@runCatching ""
802
- extras.keySet()
803
- .filter { it != META_APP_LINK_EXTRA }
804
- .sorted()
805
- .mapNotNull { key ->
806
- @Suppress("DEPRECATION")
807
- when (val value = extras.get(key)) {
808
- is CharSequence, is Boolean, is Int, is Long, is Float, is Double -> "$key=$value"
809
- else -> null
810
- }
811
- }
812
- .joinToString("&")
813
- }.getOrDefault("")
814
-
815
- /**
816
- * URLs carried by the extras, including those nested in JSON payloads. A tapped notification
817
- * holds its link there, so recording them lets `handleDeepLink` recognise a link the SDK has
818
- * already received with the Intent.
819
- */
754
+ /** A tapped notification carries its link in the extras; `handleDeepLink` must recognise it. */
820
755
  private fun urlsIn(extras: Bundle?): Set<String> {
821
756
  if (extras == null) return emptySet()
822
757
  val found = linkedSetOf<String>()
@@ -853,12 +788,11 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
853
788
  }
854
789
  }
855
790
 
856
- // ============ ActivityEventListener / LifecycleEventListener ============
857
-
858
791
  override fun onNewIntent(intent: Intent) {
859
792
  if (invalidated) return
860
793
  try {
861
- processIntent(intent, fromLaunchPath = false)
794
+ reactContext.currentActivity?.let(ActivityIntents::noteNewIntent)
795
+ processIntent(intent)
862
796
  } catch (e: Exception) {
863
797
  Log.d(TAG, "onNewIntent failed: ${e.javaClass.simpleName}")
864
798
  }
@@ -869,7 +803,7 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
869
803
  override fun onHostResume() {
870
804
  if (invalidated) return
871
805
  try {
872
- processIntent(reactContext.currentActivity?.intent, fromLaunchPath = true)
806
+ processCurrentActivityIntent()
873
807
  } catch (e: Exception) {
874
808
  Log.d(TAG, "onHostResume failed: ${e.javaClass.simpleName}")
875
809
  }
@@ -879,8 +813,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
879
813
 
880
814
  override fun onHostDestroy() = Unit
881
815
 
882
- // ============ Error model ============
883
-
884
816
  private fun rejectWith(promise: Promise, code: String, message: String, throwable: Throwable?, nativeCode: Any?) {
885
817
  val userInfo = Arguments.createMap()
886
818
  when (nativeCode) {
@@ -905,8 +837,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
905
837
  }
906
838
  }
907
839
 
908
- // ============ Mappers ============
909
-
910
840
  private fun toWritableMap(result: DeepLinkResult): WritableMap = Arguments.createMap().apply {
911
841
  val query = result.queryParams ?: emptyMap()
912
842
 
@@ -942,8 +872,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
942
872
  result.error?.let { putString("errorMessage", it.name.lowercase().replace('_', ' ')) }
943
873
  }
944
874
 
945
- // ============ ReadableMap helpers ============
946
-
947
875
  private fun optString(map: ReadableMap, key: String): String? =
948
876
  if (map.hasKey(key) && map.getType(key) == ReadableType.String) map.getString(key) else null
949
877
 
@@ -980,8 +908,6 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
980
908
  return out
981
909
  }
982
910
 
983
- // ============ Logging ============
984
-
985
911
  private fun logFailure(method: String, e: Exception) {
986
912
  Log.e(TAG, "$method failed: ${e.javaClass.simpleName}: ${e.message}")
987
913
  }
@@ -23,12 +23,6 @@ import org.junit.runner.RunWith
23
23
  import org.robolectric.RobolectricTestRunner
24
24
  import org.robolectric.annotation.Config
25
25
 
26
- /**
27
- * The snapshot answers whether consent still lets the SDK use the advertising id.
28
- * The rule differs from the one iOS applies, so it is settled here rather than in
29
- * JavaScript: under GDPR an undecided flag counts as a refusal, and outside it
30
- * only an explicit denial does.
31
- */
32
26
  @RunWith(RobolectricTestRunner::class)
33
27
  @Config(sdk = [35])
34
28
  class ConsentSnapshotTest {
@@ -66,7 +60,6 @@ class ConsentSnapshotTest {
66
60
  assertTrue("allowed", allowed(gdprApplies = 1, storage = true, dataUsage = true))
67
61
  }
68
62
 
69
- /** The case a single "any flag granted" rule would get wrong. */
70
63
  @Test
71
64
  fun `withholds the advertising id when only one flag is granted under gdpr`() {
72
65
  assertFalse("allowed", allowed(gdprApplies = 1, storage = true, dataUsage = false))
@@ -103,12 +96,6 @@ class ConsentSnapshotTest {
103
96
  assertFalse("cmpDetected", snapshot.getBoolean("cmpDetected"))
104
97
  }
105
98
 
106
- /**
107
- * A CMP that has run but has not been answered is indistinguishable from no
108
- * CMP at all by every other field here, and the two are fixed by opposite
109
- * actions. Dropping this field on the way through the bridge would leave
110
- * JavaScript unable to tell them apart.
111
- */
112
99
  @Test
113
100
  fun `forwards that a cmp has run even with nothing decided`() {
114
101
  val snapshot = refreshConsent(
@@ -133,13 +120,6 @@ class ConsentSnapshotTest {
133
120
  verify { AdShiftLib.clearThirdPartySharing() }
134
121
  }
135
122
 
136
- /**
137
- * Nothing said on this axis means sharing is allowed, which is the opposite of
138
- * how consent reads an absent answer. So a malformed call must not be
139
- * defaulted: `allowed()` would record a declaration the app never made,
140
- * `optedOut()` would withhold data the user never asked to withhold, and
141
- * neither can be recalled for events already sent.
142
- */
143
123
  @Test
144
124
  fun `refuses to guess a malformed sharing answer`() {
145
125
  every { AdShiftLib.setThirdPartySharing(any()) } just Runs
@@ -26,10 +26,6 @@ import org.junit.runner.RunWith
26
26
  import org.robolectric.RobolectricTestRunner
27
27
  import org.robolectric.annotation.Config
28
28
 
29
- /**
30
- * Every deep link result reaches JavaScript exactly once: results that arrive while no listener
31
- * is reachable wait for the next one, in the order the SDK produced them.
32
- */
33
29
  @RunWith(RobolectricTestRunner::class)
34
30
  @Config(sdk = [35])
35
31
  class DeepLinkDeliveryTest {
@@ -3,22 +3,21 @@ package com.adshift.reactnativeplugin
3
3
  import android.content.Intent
4
4
  import android.net.Uri
5
5
  import android.os.Bundle
6
+ import android.os.Looper
6
7
  import com.adshift.sdk.core.AdShiftLib
7
8
  import io.mockk.every
8
9
  import io.mockk.mockkStatic
9
10
  import io.mockk.unmockkStatic
10
11
  import org.junit.After
12
+ import org.junit.Assert.assertFalse
11
13
  import org.junit.Assert.assertTrue
12
14
  import org.junit.Before
13
15
  import org.junit.Test
14
16
  import org.junit.runner.RunWith
15
17
  import org.robolectric.RobolectricTestRunner
18
+ import org.robolectric.Shadows.shadowOf
16
19
  import org.robolectric.annotation.Config
17
20
 
18
- /**
19
- * The `initialize` options reach the SDK before any Intent does, whatever moment the host
20
- * delivers that Intent.
21
- */
22
21
  @RunWith(RobolectricTestRunner::class)
23
22
  @Config(sdk = [35])
24
23
  class InitializeOrderingTest {
@@ -35,7 +34,13 @@ class InitializeOrderingTest {
35
34
  fun setUp() {
36
35
  ModuleState.reset()
37
36
  mockkStatic(AdShiftLib::class)
38
- every { AdShiftLib.initSdk(any(), any()) } answers { calls += "initSdk" }
37
+ every { AdShiftLib.initSdk(any(), any()) } answers { calls += INIT_SDK }
38
+ // As the SDK does: naming the plugin before initSdk throws.
39
+ every { AdShiftLib.setWrapper(any()) } answers {
40
+ if (INIT_SDK !in calls) throw IllegalArgumentException("SDK not initialized")
41
+ calls += SET_WRAPPER
42
+ }
43
+ every { AdShiftLib.start(any()) } answers { calls += START }
39
44
  every { AdShiftLib.setDebugLog(any()) } answers { calls += "setDebugLog" }
40
45
  every { AdShiftLib.setBrandedDomains(any()) } answers { calls += SET_BRANDED_DOMAINS }
41
46
  every { AdShiftLib.setTestMode(any()) } answers { calls += SET_TEST_MODE }
@@ -95,6 +100,30 @@ class InitializeOrderingTest {
95
100
  )
96
101
  }
97
102
 
103
+ @Test
104
+ fun `names the plugin right after the sdk is initialized and before start`() {
105
+ context.launchIntent = deepLinkIntent()
106
+
107
+ module.initialize(initializeConfig())
108
+ module.start(RecordingPromise())
109
+ shadowOf(Looper.getMainLooper()).idle()
110
+
111
+ val wrapper = calls.indexOf(SET_WRAPPER)
112
+ assertTrue("plugin not named: $calls", wrapper >= 0)
113
+ assertTrue("named before initSdk: $calls", calls.indexOf(INIT_SDK) in 0 until wrapper)
114
+ assertTrue("named after start: $calls", wrapper < calls.indexOf(START))
115
+ assertTrue("named after an intent was forwarded: $calls", wrapper < forwardIndex())
116
+ }
117
+
118
+ @Test
119
+ fun `does not name the plugin when the sdk could not be initialized`() {
120
+ every { AdShiftLib.initSdk(any(), any()) } throws IllegalStateException("no context")
121
+
122
+ module.initialize(initializeConfig())
123
+
124
+ assertFalse("named without an SDK: $calls", calls.contains(SET_WRAPPER))
125
+ }
126
+
98
127
  private fun assertOptionsPrecedeForwarding() {
99
128
  val forward = forwardIndex()
100
129
  assertTrue("no intent reached the SDK: $calls", forward >= 0)
@@ -116,6 +145,9 @@ class InitializeOrderingTest {
116
145
  Intent(Intent.ACTION_VIEW, Uri.parse("https://$BRANDED_DOMAIN/promo?id=42"))
117
146
 
118
147
  private companion object {
148
+ const val INIT_SDK = "initSdk"
149
+ const val SET_WRAPPER = "setWrapper"
150
+ const val START = "start"
119
151
  const val SET_BRANDED_DOMAINS = "setBrandedDomains"
120
152
  const val SET_TEST_MODE = "setTestMode"
121
153
  const val ADD_PUSH_PATH = "addPushNotificationDeepLinkPath"