@adshift/react-native-plugin 2.0.0 → 3.0.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 (86) hide show
  1. package/AdShiftReactNativePlugin.podspec +1 -1
  2. package/CHANGELOG.md +53 -1
  3. package/README.md +106 -50
  4. package/android/build.gradle +3 -1
  5. package/android/src/main/AndroidManifest.xml +14 -1
  6. package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +12 -1
  7. package/android/src/main/java/com/adshift/reactnativeplugin/RestoredIntents.kt +64 -0
  8. package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +40 -3
  9. package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +14 -0
  10. package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +30 -1
  11. package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +13 -0
  12. package/ios/AdShiftReactNativePlugin.mm +5 -0
  13. package/ios/AdShiftReactNativePluginHelper.swift +25 -1
  14. package/ios/Core/BridgeRules.swift +18 -1
  15. package/lib/commonjs/Adshift.js +31 -5
  16. package/lib/commonjs/Adshift.js.map +1 -1
  17. package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -1
  18. package/lib/commonjs/index.js +6 -0
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/jest/index.js +2 -0
  21. package/lib/commonjs/jest/index.js.map +1 -1
  22. package/lib/commonjs/nativeSdkVersions.js +2 -2
  23. package/lib/commonjs/types/AdshiftConfig.js +10 -1
  24. package/lib/commonjs/types/AdshiftConfig.js.map +1 -1
  25. package/lib/commonjs/types/AdshiftDeepLink.js +50 -6
  26. package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -1
  27. package/lib/commonjs/types/index.js +12 -0
  28. package/lib/commonjs/types/index.js.map +1 -1
  29. package/lib/commonjs/version.js +1 -1
  30. package/lib/module/Adshift.js +32 -6
  31. package/lib/module/Adshift.js.map +1 -1
  32. package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
  33. package/lib/module/index.js +1 -1
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/module/jest/index.js +3 -1
  36. package/lib/module/jest/index.js.map +1 -1
  37. package/lib/module/nativeSdkVersions.js +2 -2
  38. package/lib/module/types/AdshiftConfig.js +9 -1
  39. package/lib/module/types/AdshiftConfig.js.map +1 -1
  40. package/lib/module/types/AdshiftDeepLink.js +50 -5
  41. package/lib/module/types/AdshiftDeepLink.js.map +1 -1
  42. package/lib/module/types/index.js +2 -2
  43. package/lib/module/types/index.js.map +1 -1
  44. package/lib/module/version.js +1 -1
  45. package/lib/typescript/commonjs/src/Adshift.d.ts +18 -7
  46. package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +13 -4
  48. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  49. package/lib/typescript/commonjs/src/index.d.ts +2 -2
  50. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  51. package/lib/typescript/commonjs/src/jest/index.d.ts +3 -1
  52. package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  53. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +2 -2
  54. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +25 -2
  55. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +55 -11
  57. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/src/types/index.d.ts +3 -3
  59. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/src/version.d.ts +1 -1
  61. package/lib/typescript/module/src/Adshift.d.ts +18 -7
  62. package/lib/typescript/module/src/Adshift.d.ts.map +1 -1
  63. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +13 -4
  64. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  65. package/lib/typescript/module/src/index.d.ts +2 -2
  66. package/lib/typescript/module/src/index.d.ts.map +1 -1
  67. package/lib/typescript/module/src/jest/index.d.ts +3 -1
  68. package/lib/typescript/module/src/jest/index.d.ts.map +1 -1
  69. package/lib/typescript/module/src/nativeSdkVersions.d.ts +2 -2
  70. package/lib/typescript/module/src/types/AdshiftConfig.d.ts +25 -2
  71. package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -1
  72. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +55 -11
  73. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -1
  74. package/lib/typescript/module/src/types/index.d.ts +3 -3
  75. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  76. package/lib/typescript/module/src/version.d.ts +1 -1
  77. package/package.json +2 -2
  78. package/src/Adshift.ts +48 -8
  79. package/src/NativeAdShiftReactNativePlugin.ts +14 -4
  80. package/src/index.tsx +6 -2
  81. package/src/jest/index.ts +5 -0
  82. package/src/nativeSdkVersions.ts +2 -2
  83. package/src/types/AdshiftConfig.ts +38 -2
  84. package/src/types/AdshiftDeepLink.ts +87 -11
  85. package/src/types/index.ts +9 -2
  86. package/src/version.ts +1 -1
@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
21
21
  s.exclude_files = ["ios/Package.swift", "ios/Tests/**/*", "ios/.build/**/*"]
22
22
 
23
23
  # Native AdShift iOS SDK (binary xcframework; exact pin, bumped with each plugin release)
24
- s.dependency 'AdshiftSDK', '2.2.0'
24
+ s.dependency 'AdshiftSDK', '3.0.0'
25
25
  s.static_framework = true
26
26
 
27
27
  s.pod_target_xcconfig = {
package/CHANGELOG.md CHANGED
@@ -9,10 +9,62 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  | Plugin | Android SDK | iOS SDK |
11
11
  |---|---|---|
12
+ | 3.0.0 | 4.1.0 | 3.0.0 |
13
+ | 2.1.0 | 3.2.0 | 2.4.0 |
12
14
  | 2.0.0 | 3.1.0 | 2.2.0 |
13
15
  | 1.0.0 | 2.0.3 | ~> 1.0 |
14
16
 
15
- ## [2.0.0] - Unreleased
17
+ ## [3.0.0] - 2026-11-12
18
+
19
+ Breaking release targeting Android SDK 4.1.0 and iOS SDK 3.0.0: RightLink deep linking. Nothing in the API was removed or renamed; most changes are in what `onDeepLink` delivers, without a build error. See "Upgrading from 2.x" in the README.
20
+
21
+ ### Added
22
+ - `AdshiftDeepLink.source` (`AdshiftDeepLinkSource`) and `clickId`: how the link reached the app and the click the open was attributed to. `isFirstSession` is now reported on iOS too.
23
+ - iOS: `AdshiftDeepLink.matchGuaranteed`. It is `false` for a deferred result matched without a clipboard token or an advertising identifier: route the user, but do not sign them in or grant a reward because of it.
24
+ - `AdshiftConfig.testMode`: marks every click and event as test traffic, which is kept out of reports, postbacks and billing.
25
+ - iOS: deferred deep link from the clipboard, for RightLink templates with the clipboard option — `AdshiftConfig.deferredDeepLinkClipboard` (`'disabled'` by default, `'prompt'`, `'pasteControl'`) and `Adshift.handlePastedDeepLink(url)`.
26
+ - RightLink links inside your app's scheme: `yourapp://rightlink?as_rl=<the link, percent-encoded>` is read as the link it wraps.
27
+ - Android: an Activity the system re-created (a rotation, a return after the process was killed) no longer counts the link that first opened it as a new tap.
28
+ - Android: the setup now asks `MainActivity` to keep each new Intent (`setIntent(intent)` in `onNewIntent`), so a link tapped while Android is re-creating the app is not lost.
29
+
30
+ ### Changed
31
+ - **Navigate only on `found`.** `found` now means a RightLink link — your `*.rightlink.me` host or a domain in `brandedDomains` — or a deferred deep link with a value. Any other URL, your app's own scheme included, comes back `notFound` with the URL in `deepLink`, no `params` and no click. 2.x answered `found` for every URL.
32
+ - A short link that cannot be resolved yet comes as `error`. The SDK tries again for an hour after the tap and delivers `found` when the link resolves; a deleted link is `notFound`. The tap is counted when it happens, also without a network.
33
+ - The deferred deep link answers within 5 seconds of `start()`: the link, `notFound` or `error`.
34
+ - iOS: a deferred result has no `deepLink`; its link is in `deepLinkValue` and `deepLinkSub1`…`deepLinkSub5`.
35
+ - The same link handed over twice counts once, for example a notification tapped twice.
36
+ - Only attribution parameters of a link leave the device: `pid`, `c` or `campaign`, `is_retargeting`, `as_*`, `utm_*`, `deep_link_value`, `deep_link_sub1`…`5` and click ids. Any other key stays in `params` for your app.
37
+ - An open by a link is one `app_open` that carries the link's click.
38
+ - After `stop()` links still reach `onDeepLink`; nothing is sent.
39
+ - Android: `initialize()` makes no network call. The API key is checked at the first `start()`, and a link's click is sent after it with the consent of that moment.
40
+ - Android: every RightLink link counts as a click, also without `pid` and `c`.
41
+ - iOS: the 10 USD cap on the ad revenue of one impression applies after currency conversion, so a small amount in a currency with many units per dollar now counts. Android still compares the amount as given.
42
+ - iOS: SKAN revenue comes from `AdshiftEventParam.Revenue` with `AdshiftEventParam.Currency`, else from plain `revenue` with `currency`, never from `value`.
43
+ - iOS: the SDK's privacy manifest now also declares Coarse Location and Other Diagnostic Data.
44
+ - Android: the native SDK no longer brings AppCompat and Material into your app, and no longer needs Huawei's `ads-installreferrer`.
45
+
46
+ ### Fixed
47
+ - iOS: a link passed after `start()` goes on the open's `app_open`.
48
+ - Android: `isFirstSession` is correct for a link handed over before `start()`.
49
+ - The development warning about ad revenue above 10 no longer fires on iOS for an amount in another currency.
50
+ - See the native changelogs for the full list.
51
+
52
+ ## [2.1.0] - 2026-10-07
53
+
54
+ Native SDK update targeting Android SDK 3.2.0 and iOS SDK 2.4.0. No plugin API changes; what the native SDKs changed underneath:
55
+
56
+ ### Changed
57
+ - iOS: `start()` resolves after the local set-up and no longer waits for the ATT decision, the install or the SKAdNetwork configuration. `waitForATTBeforeStart` holds event delivery, not `start()`, until the decision or `attTimeoutMs`.
58
+ - iOS: Google on-device conversion measurement is on when the app ships Google's `GoogleAdsOnDeviceConversion` library or Firebase Analytics 11.14 or later. The plugin has no switch for it yet; set `GOOGLE_ADS_ON_DEVICE_CONVERSION_EVENT_DATA_ENABLED` to `NO` in `Info.plist` to turn it off.
59
+ - Android: Google's App Set ID is sent when the app includes `com.google.android.gms:play-services-appset`. The plugin has no switch for it yet; update the Data safety form ("Device or other IDs") before shipping with that library.
60
+ - Android: excluding `play-services-ads-identifier` no longer breaks the build; to stop collecting the advertising id, remove the `AD_ID` permission instead.
61
+
62
+ ### Fixed
63
+ - Events no longer reach AdShift before the install on a first launch, and on iOS an event tracked right after `start()` is no longer lost. See the native changelogs for the full list.
64
+ - README: the Apple postback endpoint is `https://adshift.com`; `adshift-skadnetwork.com` was never a valid host. The iOS setup now also lists the two AdAttributionKit keys.
65
+ - Docs: when `INVALID_API_KEY` is reported. `onError` fires when `start()` returns `apiKeyValidationStatus: 'invalid'`; on iOS the verdict usually arrives after `start()` resolved and is reported by the next `start()`, on Android `start()` waits up to 5 s for it.
66
+
67
+ ## [2.0.0] - 2026-09-15
16
68
 
17
69
  Breaking release targeting Android SDK 3.1.0 and iOS SDK 2.2.0. See "Upgrading from 1.x" in the README.
18
70
 
package/README.md CHANGED
@@ -27,10 +27,10 @@ Official AdShift SDK for React Native. The plugin wraps the native [iOS SDK](htt
27
27
  - [Expo](#expo)
28
28
  - [Testing](#testing)
29
29
  - [Development Notes](#development-notes)
30
+ - [Upgrading from 2.x](#upgrading-from-2x)
30
31
  - [Upgrading from 1.x](#upgrading-from-1x)
31
32
  - [Example App](#example-app)
32
33
  - [Troubleshooting](#troubleshooting)
33
- - [For Maintainers](#for-maintainers)
34
34
  - [Support](#support)
35
35
 
36
36
  ---
@@ -53,6 +53,8 @@ Each plugin release pins exact native SDK versions. Do not override them in your
53
53
 
54
54
  | Plugin | Android SDK | iOS SDK |
55
55
  |---|---|---|
56
+ | 3.0.x | `com.adshift:android-sdk:4.1.0` | `AdshiftSDK 3.0.0` |
57
+ | 2.1.x | `com.adshift:android-sdk:3.2.0` | `AdshiftSDK 2.4.0` |
56
58
  | 2.0.x | `com.adshift:android-sdk:3.1.0` | `AdshiftSDK 2.2.0` |
57
59
 
58
60
  ---
@@ -73,7 +75,7 @@ cd ios && pod install
73
75
 
74
76
  Then add the two `RCTLinkingManager` handlers to `AppDelegate.swift` (see [Platform Setup → iOS](#ios)); the plugin relies on them to receive links while the app is running.
75
77
 
76
- **Android** — nothing else to do; the module autolinks. See [Platform Setup → Android](#android) for backup rules and the `AD_ID` permission.
78
+ **Android** — the module autolinks. See [Platform Setup → Android](#android) for backup rules, the `AD_ID` permission and the one `MainActivity` override deep links need.
77
79
 
78
80
  ---
79
81
 
@@ -125,7 +127,7 @@ subscription.remove();
125
127
 
126
128
  ### `Adshift.initialize(config)`
127
129
 
128
- Configures the SDK. Call once; the first configuration is kept and later calls are ignored. Throws `AdshiftError` with `INVALID_ARGUMENT` when `apiKey` is missing or an option is malformed.
130
+ Configures the SDK. Call once; the first configuration is kept and later calls are ignored. It never throws: a missing `apiKey` or a malformed option is reported through `config.onError` as `INVALID_ARGUMENT` and leaves the SDK uninitialized.
129
131
 
130
132
  See [`AdshiftConfig`](#adshiftconfig) for every option.
131
133
 
@@ -142,9 +144,9 @@ interface StartResult {
142
144
  }
143
145
  ```
144
146
 
145
- - The API key is verified with the AdShift backend in the background, so `apiKeyValidationStatus` reports `valid` or `invalid` once the answer is in, and `pending` while it is not. A key the backend rejects after `start()` resolved is reported through `config.onError` as `INVALID_API_KEY`, and events stay buffered by the native SDK.
147
+ - The API key is verified with the AdShift backend in the background. `apiKeyValidationStatus` is the verdict at the moment `start()` resolved: `valid`, `invalid`, or `pending` while the answer is not in. `config.onError` reports `INVALID_API_KEY` when `start()` itself returns `invalid`. On iOS the verdict usually arrives after `start()` resolved, so a rejected key is reported by the next `start()`; on Android `start()` waits up to 5 s for it. Events tracked meanwhile stay queued on the device by the native SDK.
146
148
  - A device excluded from tracking resolves `{ success: false, errorCode: 'OPTED_OUT' }`.
147
- - On iOS `start()` may take a few seconds on the first launch (SKAdNetwork configuration) and, if you enabled `waitForATTBeforeStart`, waits for the ATT decision up to `attTimeoutMs`.
149
+ - On iOS `start()` resolves after the local set-up and does not wait for the ATT decision or the SKAdNetwork configuration. With `waitForATTBeforeStart` the native SDK records events as usual and holds their delivery until the ATT decision, up to `attTimeoutMs`.
148
150
  - Calling `start()` again while started resolves `{ success: true }` immediately. Calling it before `initialize()` resolves `{ success: false, errorCode: 'NOT_INITIALIZED' }`.
149
151
  - Everything queued with `trackEvent`, `trackPurchase` and `logAdRevenue` between `initialize()` and a successful `start()` is dispatched in order when `start()` succeeds. If the start failed for a reason retrying cannot fix — `INVALID_API_KEY`, `OPTED_OUT`, `NOT_INITIALIZED` — the queued promises reject with that code. If it failed for any other reason, they keep waiting for the next `start()`, so the data survives a start that failed while the device was offline. Queued promises stay pending until some `start()` finishes, which is why `start()` belongs on every launch path.
150
152
 
@@ -152,7 +154,7 @@ interface StartResult {
152
154
 
153
155
  Pauses delivery. Tracking calls reject with `NOT_STARTED` until the next successful `start()`. This is not an opt-out; opt-out is configured on the AdShift side.
154
156
 
155
- Deep link forwarding keeps working after `stop()`: a link that opens the app still reaches the SDK, so attribution of that click is not lost, and the SDK decides what to do with it while delivery is paused. Configuration setters and `refreshConsent()` also keep working, so consent changes apply while delivery is paused. Calls queued before the interrupted `start()` reject with `NOT_STARTED`.
157
+ Links keep reaching `onDeepLink` after `stop()`, so your app can still route; nothing is sent while the SDK is stopped. Configuration setters and `refreshConsent()` also keep working, so consent changes apply while delivery is paused. Calls queued before the interrupted `start()` reject with `NOT_STARTED`.
156
158
 
157
159
  ### `Adshift.isStarted(): boolean`
158
160
 
@@ -165,7 +167,7 @@ The AdShift device identifier; `null` before `initialize()`.
165
167
  ### `Adshift.getInfo()`
166
168
 
167
169
  ```typescript
168
- { platform: 'ios' | 'android', version: '2.0.0', nativeSdkVersions: { android: '3.1.0', ios: '2.2.0' } }
170
+ { platform: 'ios' | 'android', version: '3.0.0', nativeSdkVersions: { android: '4.1.0', ios: '3.0.0' } }
169
171
  ```
170
172
 
171
173
  ---
@@ -252,7 +254,7 @@ await Adshift.logAdRevenue({
252
254
  });
253
255
  ```
254
256
 
255
- `mediationNetwork` must be an `AdshiftMediationNetwork` value (`AppLovinMAX`, `GoogleAdMob`, `IronSource`, `Chartboost`, `TopOn`, `TradPlus`, `AdMost`, `Appodeal`, `Fyber`, `Unity`, `Yandex`, `CustomMediation`, `DirectMonetization`, `Other`). `revenue` is the value of one impression and must be positive; the native SDKs drop implausibly large per-impression amounts (above 10 in the given currency unit, regardless of currency).
257
+ `mediationNetwork` must be an `AdshiftMediationNetwork` value (`AppLovinMAX`, `GoogleAdMob`, `IronSource`, `Chartboost`, `TopOn`, `TradPlus`, `AdMost`, `Appodeal`, `Fyber`, `Unity`, `Yandex`, `CustomMediation`, `DirectMonetization`, `Other`). `revenue` is the value of one impression and must be positive. The native SDKs drop an impression above 10 USD: iOS converts the amount to USD first, Android compares the amount as given, whatever the currency.
256
258
 
257
259
  ---
258
260
 
@@ -260,8 +262,10 @@ await Adshift.logAdRevenue({
260
262
 
261
263
  ### The contract
262
264
 
263
- - Every link that opens the app and reaches the SDK — direct, deferred (first launch after install) and push — produces exactly one `onDeepLink` result.
264
- - `status === 'found'` means the link was delivered; it does **not** mean it is an attribution link. Route on `deepLinkValue`, `params` or the URL and ignore links you do not care about.
265
+ - Every link that opens the app and reaches the SDK — direct, deferred (first launch after install) and push — produces an `onDeepLink` result, and each result is delivered once.
266
+ - **Navigate only on `status === 'found'`.** `found` means a RightLink link — your `*.rightlink.me` host, a domain in `brandedDomains`, or your app's scheme wrapping one (`yourapp://rightlink?as_rl=<the link, percent-encoded>`) — or a deferred deep link with a value. Validate `deepLinkValue` before you use it: anyone can write a link.
267
+ - Any other URL, your app's own links included, comes back `notFound` with the URL in `deepLink` and no `params`. Route your own links from there.
268
+ - `error` means "not yet": a short link that could not be resolved, for example without a network. The tap is already counted; the SDK tries again for an hour and delivers `found` when the link resolves.
265
269
  - Results are delivered only through `onDeepLink`. `handleDeepLink()` and `handlePushNotification()` resolve when the SDK has accepted the input.
266
270
 
267
271
  ### `Adshift.onDeepLink(callback): DeepLinkSubscription`
@@ -269,39 +273,54 @@ await Adshift.logAdRevenue({
269
273
  ```typescript
270
274
  useEffect(() => {
271
275
  const subscription = Adshift.onDeepLink((deepLink) => {
272
- if (deepLink.status !== AdshiftDeepLinkStatus.Found) return;
273
- if (deepLink.deepLinkValue === 'product') {
274
- navigate('Product', { id: deepLink.params?.product_id });
276
+ switch (deepLink.status) {
277
+ case AdshiftDeepLinkStatus.Found:
278
+ if (deepLink.deepLinkValue === 'product') {
279
+ navigate('Product', { id: deepLink.params?.product_id });
280
+ }
281
+ break;
282
+ case AdshiftDeepLinkStatus.NotFound:
283
+ // your own links: route on deepLink.deepLink
284
+ break;
285
+ case AdshiftDeepLinkStatus.Error:
286
+ // carry on without a deep link; `found` can still follow
287
+ break;
275
288
  }
276
289
  });
277
290
  return () => subscription.remove();
278
291
  }, []);
279
292
  ```
280
293
 
281
- - Safe before `initialize()`. Up to 20 results that arrive while no listener is registered are buffered and replayed to the first listener. When the buffer is full a direct result is dropped before a deferred one, because a deferred result cannot be produced again.
294
+ - Safe before `initialize()`. Results that arrive while no listener is registered wait and are delivered to the first listener.
282
295
  - Listeners are called on the JS thread; an exception in one listener does not affect the others. `remove()` is idempotent.
283
296
 
284
297
  ```typescript
285
298
  interface AdshiftDeepLink {
286
- deepLink?: string; // the URL
299
+ deepLink?: string; // the link as opened, a short link expanded
287
300
  deepLinkValue?: string; // deep_link_value for routing
288
- params?: Record<string, string>; // query parameters
301
+ params?: Record<string, string>; // query of a RightLink link, your own keys included
289
302
  isDeferred: boolean; // first launch after install
290
- isFirstSession?: boolean; // Android only, on every result
303
+ isFirstSession?: boolean; // the first session after install
291
304
  status: AdshiftDeepLinkStatus; // Found | NotFound | Error
292
305
  errorMessage?: string; // with Error; wording differs per platform
306
+ source?: AdshiftDeepLinkSource; // how the link reached the app
307
+ clickId?: string; // the click this open was attributed to
308
+ matchGuaranteed?: boolean; // iOS, see below
293
309
  deepLinkSub1?: string; /* … */ deepLinkSub5?: string;
294
310
  }
295
311
  ```
296
312
 
313
+ - `source` is `ul` on iOS and `app_link` on Android for a Universal Link or App Link (or a link you passed in yourself), `scheme`, `cta` (the open-in-app button of a RightLink page), `push`, `deferred` or `foreign` (a web link that is not a RightLink link); iOS adds `aak` (an AdAttributionKit re-engagement open) and Android `meta_applink`.
314
+ - `matchGuaranteed` is `false` for a deferred result matched without a clipboard token or an advertising identifier: route the user, but do not sign them in or grant a reward because of it.
315
+
297
316
  ### Automatic forwarding (default)
298
317
 
299
318
  With `autoHandleDeepLinks: true` (the default) you write no linking code:
300
319
 
301
- - **Android** — the plugin reads the launch Intent and every new Intent (App Links, custom schemes, push taps that carry `as_push_link`). Relaunches from Recents and the launcher are not re-processed.
320
+ - **Android** — the plugin reads the launch Intent and every new Intent (App Links, custom schemes, push taps that carry `as_push_link`). Relaunches from Recents and the launcher are not re-processed, and neither is an Activity the system re-created (a rotation, a return after the process was killed).
302
321
  - **iOS** — the plugin uses React Native's `Linking` (`getInitialURL` and the `url` event). Your `AppDelegate.swift` must forward URLs to `RCTLinkingManager` (see [Platform Setup → iOS](#ios)); without it links opened while the app is running never reach JavaScript.
303
322
 
304
- `start()` waits (up to 3 s) for the launch URL to be handed to the SDK, so the first `app_open` carries the click parameters.
323
+ `start()` hands the launch URL to the SDK first, so the first `app_open` carries the click parameters.
305
324
 
306
325
  ### Manual forwarding
307
326
 
@@ -311,11 +330,24 @@ Set `autoHandleDeepLinks: false` and forward URLs yourself:
311
330
  await Adshift.handleDeepLink(url); // resolves once accepted; result arrives via onDeepLink
312
331
  ```
313
332
 
314
- Rejects with `NOT_INITIALIZED` or `INVALID_ARGUMENT` (empty or malformed URL). If you keep an old `Linking → handleDeepLink` handler while automatic forwarding is on, the plugin ignores a URL it forwarded itself within the previous two seconds, so nothing is counted twice.
333
+ Rejects with `NOT_INITIALIZED` or `INVALID_ARGUMENT` (empty or malformed URL). If you keep an old `Linking → handleDeepLink` handler while automatic forwarding is on, nothing is counted twice: the same link handed over twice counts once.
315
334
 
316
335
  ### Deferred deep links
317
336
 
318
- On the first launch after install the SDK resolves the deferred deep link (if the user clicked an AdShift link before installing) and delivers it through `onDeepLink` with `isDeferred: true`. Nothing to configure.
337
+ On the first launch after install the SDK looks up the deferred deep link and answers through `onDeepLink` with `isDeferred: true` within 5 seconds of `start()`: the link, `notFound` or `error`. With `waitForATTBeforeStart` on iOS the 5 seconds count from the ATT answer. Nothing to configure.
338
+
339
+ On iOS a deferred result has no `deepLink`: route on `deepLinkValue` and `deepLinkSub1`…`deepLinkSub5`. There is no lookup when the user denied ad storage or ad user data in your consent.
340
+
341
+ **Clipboard (iOS)** — for RightLink templates with the clipboard option, the install finds its link without an advertising identifier. Set `deferredDeepLinkClipboard` in `initialize()`:
342
+
343
+ - `'prompt'` — the SDK reads the clipboard once per install; iOS asks the user to allow the paste.
344
+ - `'pasteControl'` — your onboarding shows `UIPasteControl`, which pastes without asking, and you pass on what was pasted:
345
+
346
+ ```typescript
347
+ Adshift.handlePastedDeepLink(pastedUrl); // null when the user skipped
348
+ ```
349
+
350
+ Call it on every way out of onboarding: the first launch's deferred deep link waits for it. `UIPasteControl` is a native view you add to your app yourself; the plugin ships none.
319
351
 
320
352
  ---
321
353
 
@@ -346,7 +378,7 @@ notifee.onForegroundEvent(({ type, detail }) => {
346
378
  });
347
379
  ```
348
380
 
349
- `handlePushNotification` resolves `true` when the payload carried an AdShift link (the result arrives through `onDeepLink`). Only taps should be forwarded, not deliveries. Call it before `start()` when the payload is known at launch, so the first `app_open` carries the push parameters.
381
+ `handlePushNotification` resolves `true` when the payload carried an AdShift link (the result arrives through `onDeepLink`). The link must be a RightLink link with `pid` and `c` (or `campaign`), or a RightLink short link. Only taps should be forwarded, not deliveries. Call it before `start()` when the payload is known at launch, so the first `app_open` carries the push parameters.
350
382
 
351
383
  ---
352
384
 
@@ -456,13 +488,15 @@ not answered yet, which resolves itself once they do.
456
488
  | `apiKey` | `string` | — | Required |
457
489
  | `isDebug` | `boolean` | SDK default | Verbose native logging |
458
490
  | `appOpenDebounceMs` | `number` | `10000` | Debounce for automatic `app_open` |
459
- | `brandedDomains` | `string[]` | — | Custom attribution domains |
491
+ | `brandedDomains` | `string[]` | — | Your own link domains; without it their links are `notFound` |
492
+ | `testMode` | `boolean` | `false` | Marks every click and event as test traffic, kept out of reports, postbacks and billing |
460
493
  | `metaAppId` | `string` | — | Meta App Links parsing (Android) |
461
494
  | `pushDeepLinkPaths` | `string[][]` | `[['as_push_link']]` | Extra key paths in push payloads |
462
495
  | `autoHandleDeepLinks` | `boolean` | `true` | Automatic URL forwarding |
463
496
  | `disableSKAN` | `boolean` | `false` | iOS |
464
497
  | `waitForATTBeforeStart` | `boolean` | `false` | iOS; only when **your app** shows the ATT prompt |
465
498
  | `attTimeoutMs` | `number` | `30000` | iOS; clamped to 5 000–120 000 |
499
+ | `deferredDeepLinkClipboard` | `'disabled' \| 'prompt' \| 'pasteControl'` | `'disabled'` | iOS; see [Deferred deep links](#deferred-deep-links) |
466
500
  | `collectOaid` | `boolean` | `true` | Android; OAID on devices without Google Play services |
467
501
 
468
502
  Only options you set are passed to the native SDK; everything else keeps the SDK default.
@@ -572,15 +606,21 @@ func application(
572
606
 
573
607
  **3. Universal Links and custom schemes** — add the Associated Domains capability (`applinks:yourapp.rightlink.me` or your branded domain) and, for custom schemes, `CFBundleURLTypes` in `Info.plist`.
574
608
 
575
- **4. App Tracking Transparency** — if your app shows the ATT prompt, add `NSUserTrackingUsageDescription` to `Info.plist` and set `waitForATTBeforeStart: true`; `start()` then waits for the decision up to `attTimeoutMs`. If your app does not prompt, leave the option off.
609
+ **4. App Tracking Transparency** — if your app shows the ATT prompt, add `NSUserTrackingUsageDescription` to `Info.plist` and set `waitForATTBeforeStart: true`; event delivery then waits for the decision up to `attTimeoutMs`, while `start()` resolves right away. If your app does not prompt, leave the option off.
576
610
 
577
- **5. SKAdNetwork postbacks** — add to `Info.plist`:
611
+ **5. SKAdNetwork and AdAttributionKit postbacks** — add to `Info.plist`:
578
612
 
579
613
  ```xml
580
614
  <key>NSAdvertisingAttributionReportEndpoint</key>
581
- <string>https://adshift-skadnetwork.com</string>
615
+ <string>https://adshift.com</string>
616
+ <key>AttributionCopyEndpoint</key>
617
+ <string>https://adshift.com</string>
618
+ <key>EligibleForAdAttributionKitReengagementPostbackCopies</key>
619
+ <true/>
582
620
  ```
583
621
 
622
+ `NSAdvertisingAttributionReportEndpoint` sends AdShift copies of the SKAdNetwork postbacks, `AttributionCopyEndpoint` copies of the AdAttributionKit install postbacks (iOS 17.4 and later), and the boolean adds the re-engagement copies.
623
+
584
624
  The native SDK ships its own privacy manifest; the plugin adds no tracked APIs. For what to put in App Store Connect, see [Store Privacy Declarations](#store-privacy-declarations).
585
625
 
586
626
  **6. Pod linkage** — the plugin is built in all three CocoaPods linkage modes: the React Native default, where pods are static libraries, plus `use_frameworks! :linkage => :static` and `use_frameworks! :linkage => :dynamic`. Nothing extra is needed on your side for any of them.
@@ -589,7 +629,7 @@ The native SDK ships its own privacy manifest; the plugin adds no tracked APIs.
589
629
 
590
630
  **1. Requirements** — `minSdkVersion 24`, `compileSdkVersion 35+`.
591
631
 
592
- **2. Dependencies brought by the native SDK** — `okhttp 4.12`, `retrofit 2.9`, `gson 2.10`, `installreferrer 2.2`, `play-services-ads-identifier 18.0.1`, `androidx.lifecycle:lifecycle-process`. Gradle resolves conflicts to the highest version; if you pin `okhttp` lower than 4.12 in your app, raise it.
632
+ **2. Dependencies brought by the native SDK** — `okhttp 4.12`, `retrofit 2.9`, `gson 2.10`, `installreferrer 2.2`, `play-services-ads-identifier 18.0.1`, `androidx.lifecycle:lifecycle-process`, `androidx.startup:startup-runtime`. Gradle resolves conflicts to the highest version; if you pin `okhttp` lower than 4.12 in your app, raise it.
593
633
 
594
634
  **3. Permissions** — the SDK manifest declares `INTERNET`, `ACCESS_NETWORK_STATE` and `com.google.android.gms.permission.AD_ID`, plus two permissions and a set of `<queries>` entries used to read the OAID on devices without Google Play services. All of them merge into your app. Apps in the Families program, and any app directed to children under COPPA, must remove `AD_ID`:
595
635
 
@@ -603,6 +643,15 @@ Without that permission the advertising id is no longer read, and attribution co
603
643
 
604
644
  **5. App Links** — add the intent filters for your branded domain / custom scheme to `MainActivity`; `launchMode="singleTask"` (the template default) is recommended. No JavaScript code is needed.
605
645
 
646
+ Keep each new Intent in `MainActivity`. React Native drops an Intent that arrives before JavaScript is ready, so without this a link tapped while Android is re-creating your app (after it killed the process in the background) is lost:
647
+
648
+ ```kotlin
649
+ override fun onNewIntent(intent: Intent) {
650
+ super.onNewIntent(intent)
651
+ setIntent(intent)
652
+ }
653
+ ```
654
+
606
655
  **6. Code shrinking** — the native SDK ships consumer ProGuard rules, so `minifyEnabled true` needs no keep rules of your own, and release builds with shrinking enabled are part of our build checks. Those rules keep the SDK's public API and its wire models and leave the rest to R8, so SDK frames in crash reports arrive obfuscated; upload your release `mapping.txt`. Do not add `-keep class com.adshift.sdk.** { *; }` — it is not needed and forces the whole native SDK into the APK unshrunk.
607
656
 
608
657
  **7. Devices without Google Play services** — the SDK reads the OAID itself when `collectOaid` is on (the default). If your app already obtains it, pass it with `Adshift.setOaidData(oaid)` and set `collectOaid: false`.
@@ -636,9 +685,9 @@ Notes that decide several rows for you:
636
685
 
637
686
  - **The advertising id is optional in practice.** On Android it is read only while the `AD_ID` permission is present (see [Platform Setup → Android](#android)); on iOS only after the user allows tracking through ATT. Removing the permission, or never showing the ATT prompt, keeps the identifier out of your declaration — attribution continues on the SDK's own install identifier, which is still collected.
638
687
  - **Consent gates it too.** When you report a refusal through the consent API, the advertising id is withheld; `Adshift.refreshConsent()` returns `adIdentifiersAllowed` so you can see the current answer.
639
- - **No location is collected.** No location permission or API is used. The country reported by the SDK comes from the device's region setting.
688
+ - **No location permission or API is used.** The country reported by the SDK comes from the device's region setting. AdShift also derives the country and city from the IP address of each request, which is why the iOS SDK's privacy manifest declares Coarse Location; check your App Privacy answers against the privacy report Xcode generates.
640
689
  - **Custom event parameters are yours.** Whatever you pass to `trackEvent` is sent as you wrote it, so anything personal in there belongs in your declaration.
641
- - **Opening URLs are forwarded whole**, including links that have nothing to do with a campaign, for as long as `autoHandleDeepLinks` is on. If your links can carry personal data in their parameters, either keep it out of them or turn the option off and pass only the links you choose with `Adshift.handleDeepLink(url)`.
690
+ - **Only a RightLink link is sent, and only its attribution parameters.** Of its query the SDK sends `pid`, `c` or `campaign`, `is_retargeting`, `as_*`, `utm_*`, `deep_link_value`, `deep_link_sub1`…`5` and click ids; any other key stays on the device, in `params`. A URL that is not a RightLink link is not sent at all.
642
691
  - **Everything travels over HTTPS.**
643
692
 
644
693
  Whether your app's data counts as "shared" under Play's definition, and whether the identifiers are used for tracking under Apple's definition, depends on your agreement with AdShift rather than on the SDK — settle those two with us before you submit.
@@ -649,11 +698,11 @@ Whether your app's data counts as "shared" under Play's definition, and whether
649
698
 
650
699
  The plugin contains native code, so it works with **development builds / prebuild** (`expo run:ios`, `expo run:android`, EAS Build) and not with Expo Go.
651
700
 
652
- No config plugin is needed, and neither is any native edit:
701
+ No config plugin is needed, and neither is any native edit, with one exception: the `onNewIntent` override in step 5 of the [Android setup](#android) needs a config plugin of your own.
653
702
 
654
703
  - Autolinking and codegen pick the module up.
655
704
  - Expo forwards opened URLs and universal links to React Native's `Linking` itself, so skip step 2 of the [iOS setup](#ios) — the generated `AppDelegate.swift` is regenerated by `expo prebuild` anyway.
656
- - Everything else belongs in `app.json`: `ios.associatedDomains` for universal links, `ios.infoPlist` for `NSUserTrackingUsageDescription` and `NSAdvertisingAttributionReportEndpoint`, `android.intentFilters` for App Links, and `scheme` for a custom scheme.
705
+ - Everything else belongs in `app.json`: `ios.associatedDomains` for universal links, `ios.infoPlist` for `NSUserTrackingUsageDescription` and the three postback keys from step 5, `android.intentFilters` for App Links, and `scheme` for a custom scheme.
657
706
 
658
707
  An OTA update via Expo Updates reloads JavaScript — see [Development Notes](#development-notes).
659
708
 
@@ -683,9 +732,28 @@ The package ships both ES module and CommonJS builds, so the default `react-nati
683
732
 
684
733
  ---
685
734
 
735
+ ## Upgrading from 2.x
736
+
737
+ 3.x targets Android SDK 4.1.0 and iOS SDK 3.0.0 (see [Native SDK versions](#native-sdk-versions)) and is a breaking release. Nothing in the API was removed or renamed; what changes is what `onDeepLink` delivers.
738
+
739
+ - **Route only on `status === 'found'`.** 2.x answered `found` for every URL. Now a URL that is not a RightLink link, your app's own scheme included, comes back `notFound`: route your own links from `deepLink` there.
740
+ - **Declare every branded link domain in `brandedDomains`**, or its links come back `notFound` and are not counted.
741
+ - **Treat `error` as "not yet".** The same link can still arrive as `found`.
742
+ - **On iOS a deferred result has no `deepLink`.** Route on `deepLinkValue` and `deepLinkSub1`…`deepLinkSub5`.
743
+ - **Register `onDeepLink` once, early.** Each result is delivered once.
744
+ - **With a CMP, call `start()` after `setConsentData()`**, so the link that opened the app is recorded under that consent.
745
+ - **iOS: review your App Privacy answers.** The SDK's privacy manifest now also declares Coarse Location and Other Diagnostic Data.
746
+ - **iOS: the SDK removes its 2.x keys from `UserDefaults`** — `click_id`, `click_time`, `deep_link_params` and `raw_link_url`, once, the first time 3.x runs. If your native code keeps its own data under these names, move it first.
747
+ - **Android: keep each new Intent in `MainActivity`** — the `onNewIntent` override in step 5 of the [Android setup](#android).
748
+ - **Android: declare AppCompat or Material yourself** if your app used either without declaring it; the native SDK no longer brings them. Huawei's `ads-installreferrer` is no longer needed.
749
+
750
+ New in 3.x: `AdshiftDeepLink.source`, `clickId` and `matchGuaranteed`, `AdshiftConfig.testMode`, and on iOS `deferredDeepLinkClipboard` with `Adshift.handlePastedDeepLink()`.
751
+
752
+ ---
753
+
686
754
  ## Upgrading from 1.x
687
755
 
688
- 2.0.0 targets Android SDK 3.1.0 and iOS SDK 2.2.0 and is a breaking release.
756
+ 2.x targeted Android SDK 3.2.0 and iOS SDK 2.4.0 and was a breaking release.
689
757
 
690
758
  **Removed**
691
759
  - `NativeAdShiftReactNativePlugin` and `AdShiftNativeSpec` exports — the native module is internal.
@@ -731,9 +799,11 @@ Replace `API_KEYS` in `example/src/App.tsx` with keys from the AdShift dashboard
731
799
 
732
800
  **Links do not arrive on iOS while the app is running** — add the `RCTLinkingManager` methods to `AppDelegate.swift` ([Platform Setup → iOS](#ios)).
733
801
 
734
- **A link is delivered twice on iOS** — you forward URLs manually from `Linking` while `autoHandleDeepLinks` is on and the second call arrives more than two seconds after the first. Remove your handler or set `autoHandleDeepLinks: false`.
802
+ **My own links stopped arriving as `found`** — only RightLink links are `found`. Route your own links on `notFound`, from `deepLink` ([Deep Linking](#deep-linking)).
803
+
804
+ **A link on my own domain comes back `notFound`** — add the domain to `brandedDomains` in `initialize()`.
735
805
 
736
- **`start()` takes long on iOS** — `waitForATTBeforeStart: true` without an ATT prompt waits for `attTimeoutMs`. Set the option only when your app actually prompts.
806
+ **The first events on iOS arrive late** — `waitForATTBeforeStart: true` without an ATT prompt holds their delivery for `attTimeoutMs`. Set the option only when your app actually prompts.
737
807
 
738
808
  **Manifest merger conflict on `fullBackupContent` / `dataExtractionRules`** — see [Android backup rules](#android).
739
809
 
@@ -741,27 +811,13 @@ Replace `API_KEYS` in `example/src/App.tsx` with keys from the AdShift dashboard
741
811
 
742
812
  **Jest fails at import** — register the mock from [Testing](#testing).
743
813
 
744
- **Events are not sent** — check `start()` resolved with `success: true`, enable `isDebug` and read the native logs; a rejected API key shows up through `config.onError` as `INVALID_API_KEY`.
745
-
746
- ---
747
-
748
- ## For Maintainers
749
-
750
- **Release**
751
- 1. Update `CHANGELOG.md` (including the native SDK matrix row) and the pins (`android/build.gradle`, `AdShiftReactNativePlugin.podspec`, `NATIVE_SDK_VERSIONS` in `src/Adshift.ts`).
752
- 2. `yarn version <new version>` regenerates `src/version.ts`; commit.
753
- 3. Push a tag: `v2.0.0-rc.1` publishes to the `next` dist-tag, `v2.0.0` to `latest`. The workflow fails if the tag does not match `package.json`.
754
- 4. Publishing uses npm **trusted publishing** (OIDC) from `.github/workflows/publish.yml`; no npm token is stored in the repository. The package's trusted publisher on npmjs.com must point at this repository and workflow file.
755
-
756
- **Verification before GA** — an RC must run through the manual device test plan in a fresh RN 0.82+ app and at least one real application on `@adshift/react-native-plugin@next`.
757
-
758
- **Rollback** — never `npm unpublish`. Deprecate the faulty version (`npm deprecate @adshift/react-native-plugin@x.y.z "…"`) and publish a fixed patch. A defect in a native SDK is fixed by a plugin patch release with a bumped pin.
814
+ **Events are not sent** — check `start()` resolved with `success: true`, enable `isDebug` and read the native logs; a rejected API key shows up as `apiKeyValidationStatus: 'invalid'` and through `config.onError` as `INVALID_API_KEY`, on iOS usually from the next `start()`.
759
815
 
760
816
  ---
761
817
 
762
818
  ## Support
763
819
 
764
- - Documentation: https://dev.adshift.com/docs/react-native-sdk
820
+ - Documentation: https://dev.adshift.com/docs/react-native-plugin
765
821
  - Issues: https://github.com/AdShift/react_native_plugin/issues
766
822
  - Email: support@adshift.com
767
823
 
@@ -84,7 +84,9 @@ dependencies {
84
84
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
85
85
 
86
86
  // AdShift Android SDK from Maven Central (exact pin; bumped with each plugin release)
87
- implementation "com.adshift:android-sdk:3.1.0"
87
+ implementation "com.adshift:android-sdk:4.1.0"
88
+ // Already in the app through the SDK; declared for RestoredIntentsInitializer.
89
+ implementation "androidx.startup:startup-runtime:1.1.1"
88
90
 
89
91
  testImplementation "junit:junit:4.13.2"
90
92
  testImplementation "androidx.test:core:1.6.1"
@@ -1,2 +1,15 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ xmlns:tools="http://schemas.android.com/tools">
3
+
4
+ <application>
5
+ <provider
6
+ android:name="androidx.startup.InitializationProvider"
7
+ android:authorities="${applicationId}.androidx-startup"
8
+ android:exported="false"
9
+ tools:node="merge">
10
+ <meta-data
11
+ android:name="com.adshift.reactnativeplugin.RestoredIntentsInitializer"
12
+ android:value="androidx.startup" />
13
+ </provider>
14
+ </application>
2
15
  </manifest>
@@ -168,6 +168,7 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
168
168
 
169
169
  init {
170
170
  synchronized(lock) { currentModule = WeakReference(this) }
171
+ RestoredIntents.register(reactContext)
171
172
  reactContext.addActivityEventListener(this)
172
173
  reactContext.addLifecycleEventListener(this)
173
174
  }
@@ -238,6 +239,7 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
238
239
  }
239
240
  }
240
241
  optArray(config, "brandedDomains")?.let { AdShiftLib.setBrandedDomains(stringList(it)) }
242
+ optBoolean(config, "testMode")?.let { AdShiftLib.setTestMode(it) }
241
243
  optString(config, "metaAppId")?.takeIf { it.isNotBlank() }?.let { AdShiftLib.setMetaAppId(it) }
242
244
  optArray(config, "pushDeepLinkPaths")?.let { paths ->
243
245
  for (i in 0 until paths.size()) {
@@ -630,6 +632,9 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
630
632
  }
631
633
  }
632
634
 
635
+ /** The clipboard lookup exists on iOS only. */
636
+ override fun handlePastedDeepLink(url: String?) = Unit
637
+
633
638
  override fun addPushNotificationDeepLinkPath(path: ReadableArray) {
634
639
  val keys = stringList(path)
635
640
  if (keys.isEmpty()) {
@@ -711,6 +716,10 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
711
716
  Log.d(TAG, "intent skipped (history)")
712
717
  return
713
718
  }
719
+ if (intent in RestoredIntents) {
720
+ Log.d(TAG, "intent skipped (recreated)")
721
+ return
722
+ }
714
723
  val firstSeen = synchronized(lock) { processedIntents.add(intent) }
715
724
  if (!firstSeen) {
716
725
  Log.d(TAG, "intent skipped (duplicate)")
@@ -902,7 +911,9 @@ class AdShiftReactNativePluginModule(private val reactContext: ReactApplicationC
902
911
  val query = result.queryParams ?: emptyMap()
903
912
 
904
913
  result.uri?.toString()?.let { putString("deepLink", it) }
905
- query["deep_link_value"]?.let { putString("deepLinkValue", it) }
914
+ (result.deepLinkValue ?: query["deep_link_value"])?.let { putString("deepLinkValue", it) }
915
+ result.source?.let { putString("source", it.name.lowercase()) }
916
+ result.clickId?.let { putString("clickId", it) }
906
917
  result.sub1?.let { putString("deepLinkSub1", it) }
907
918
  result.sub2?.let { putString("deepLinkSub2", it) }
908
919
  result.sub3?.let { putString("deepLinkSub3", it) }
@@ -0,0 +1,64 @@
1
+ package com.adshift.reactnativeplugin
2
+
3
+ import android.app.Activity
4
+ import android.app.Application
5
+ import android.content.Context
6
+ import android.content.Intent
7
+ import android.os.Bundle
8
+ import androidx.startup.Initializer
9
+ import java.util.Collections
10
+ import java.util.WeakHashMap
11
+
12
+ /**
13
+ * The Intents held by Activities the system re-created from saved state (a
14
+ * rotation, a return after the process was killed). Such an Intent opened the
15
+ * Activity the first time, so forwarding it again would count an old tap as a
16
+ * new one.
17
+ */
18
+ internal object RestoredIntents : Application.ActivityLifecycleCallbacks {
19
+
20
+ private val intents: MutableSet<Intent> =
21
+ Collections.synchronizedSet(Collections.newSetFromMap(WeakHashMap<Intent, Boolean>()))
22
+
23
+ private var application: Application? = null
24
+
25
+ @Synchronized
26
+ fun register(context: Context) {
27
+ val app = context.applicationContext as? Application ?: return
28
+ if (application === app) return
29
+ application = app
30
+ app.registerActivityLifecycleCallbacks(this)
31
+ }
32
+
33
+ operator fun contains(intent: Intent): Boolean = intent in intents
34
+
35
+ private fun remember(activity: Activity, savedInstanceState: Bundle?) {
36
+ if (savedInstanceState != null) activity.intent?.let { intents += it }
37
+ }
38
+
39
+ // Gets the state the system saved even when the Activity passes null to
40
+ // super.onCreate; below API 29 only onActivityCreated exists.
41
+ override fun onActivityPreCreated(activity: Activity, savedInstanceState: Bundle?) =
42
+ remember(activity, savedInstanceState)
43
+
44
+ override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) =
45
+ remember(activity, savedInstanceState)
46
+
47
+ override fun onActivityStarted(activity: Activity) = Unit
48
+ override fun onActivityResumed(activity: Activity) = Unit
49
+ override fun onActivityPaused(activity: Activity) = Unit
50
+ override fun onActivityStopped(activity: Activity) = Unit
51
+ override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) = Unit
52
+ override fun onActivityDestroyed(activity: Activity) = Unit
53
+ }
54
+
55
+ /**
56
+ * Registers [RestoredIntents] at process start, before the first Activity is
57
+ * created. An app that removes the entry is covered from the moment the module
58
+ * loads.
59
+ */
60
+ internal class RestoredIntentsInitializer : Initializer<Unit> {
61
+ override fun create(context: Context) = RestoredIntents.register(context)
62
+
63
+ override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
64
+ }