@adshift/react-native-plugin 2.1.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.
- package/AdShiftReactNativePlugin.podspec +1 -1
- package/CHANGELOG.md +36 -0
- package/README.md +90 -41
- package/android/build.gradle +3 -1
- package/android/src/main/AndroidManifest.xml +14 -1
- package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +12 -1
- package/android/src/main/java/com/adshift/reactnativeplugin/RestoredIntents.kt +64 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +40 -3
- package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +14 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +30 -1
- package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +13 -0
- package/ios/AdShiftReactNativePlugin.mm +5 -0
- package/ios/AdShiftReactNativePluginHelper.swift +25 -1
- package/ios/Core/BridgeRules.swift +18 -1
- package/lib/commonjs/Adshift.js +25 -2
- package/lib/commonjs/Adshift.js.map +1 -1
- package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest/index.js +2 -0
- package/lib/commonjs/jest/index.js.map +1 -1
- package/lib/commonjs/nativeSdkVersions.js +2 -2
- package/lib/commonjs/types/AdshiftConfig.js +10 -1
- package/lib/commonjs/types/AdshiftConfig.js.map +1 -1
- package/lib/commonjs/types/AdshiftDeepLink.js +50 -6
- package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -1
- package/lib/commonjs/types/index.js +12 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/Adshift.js +26 -3
- package/lib/module/Adshift.js.map +1 -1
- package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +3 -1
- package/lib/module/jest/index.js.map +1 -1
- package/lib/module/nativeSdkVersions.js +2 -2
- package/lib/module/types/AdshiftConfig.js +9 -1
- package/lib/module/types/AdshiftConfig.js.map +1 -1
- package/lib/module/types/AdshiftDeepLink.js +50 -5
- package/lib/module/types/AdshiftDeepLink.js.map +1 -1
- package/lib/module/types/index.js +2 -2
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/commonjs/src/Adshift.d.ts +9 -1
- package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +13 -4
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/jest/index.d.ts +3 -1
- package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +2 -2
- package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +25 -2
- package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +55 -11
- package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/index.d.ts +3 -3
- package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/version.d.ts +1 -1
- package/lib/typescript/module/src/Adshift.d.ts +9 -1
- package/lib/typescript/module/src/Adshift.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +13 -4
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +2 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/jest/index.d.ts +3 -1
- package/lib/typescript/module/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeSdkVersions.d.ts +2 -2
- package/lib/typescript/module/src/types/AdshiftConfig.d.ts +25 -2
- package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +55 -11
- package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -1
- package/lib/typescript/module/src/types/index.d.ts +3 -3
- package/lib/typescript/module/src/types/index.d.ts.map +1 -1
- package/lib/typescript/module/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Adshift.ts +39 -2
- package/src/NativeAdShiftReactNativePlugin.ts +14 -4
- package/src/index.tsx +6 -2
- package/src/jest/index.ts +5 -0
- package/src/nativeSdkVersions.ts +2 -2
- package/src/types/AdshiftConfig.ts +38 -2
- package/src/types/AdshiftDeepLink.ts +87 -11
- package/src/types/index.ts +9 -2
- 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', '
|
|
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,46 @@ 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 |
|
|
12
13
|
| 2.1.0 | 3.2.0 | 2.4.0 |
|
|
13
14
|
| 2.0.0 | 3.1.0 | 2.2.0 |
|
|
14
15
|
| 1.0.0 | 2.0.3 | ~> 1.0 |
|
|
15
16
|
|
|
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
|
+
|
|
16
52
|
## [2.1.0] - 2026-10-07
|
|
17
53
|
|
|
18
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:
|
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,7 @@ 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` |
|
|
56
57
|
| 2.1.x | `com.adshift:android-sdk:3.2.0` | `AdshiftSDK 2.4.0` |
|
|
57
58
|
| 2.0.x | `com.adshift:android-sdk:3.1.0` | `AdshiftSDK 2.2.0` |
|
|
58
59
|
|
|
@@ -74,7 +75,7 @@ cd ios && pod install
|
|
|
74
75
|
|
|
75
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.
|
|
76
77
|
|
|
77
|
-
**Android** —
|
|
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.
|
|
78
79
|
|
|
79
80
|
---
|
|
80
81
|
|
|
@@ -126,7 +127,7 @@ subscription.remove();
|
|
|
126
127
|
|
|
127
128
|
### `Adshift.initialize(config)`
|
|
128
129
|
|
|
129
|
-
Configures the SDK. Call once; the first configuration is kept and later calls are ignored.
|
|
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.
|
|
130
131
|
|
|
131
132
|
See [`AdshiftConfig`](#adshiftconfig) for every option.
|
|
132
133
|
|
|
@@ -153,7 +154,7 @@ interface StartResult {
|
|
|
153
154
|
|
|
154
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.
|
|
155
156
|
|
|
156
|
-
|
|
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`.
|
|
157
158
|
|
|
158
159
|
### `Adshift.isStarted(): boolean`
|
|
159
160
|
|
|
@@ -166,7 +167,7 @@ The AdShift device identifier; `null` before `initialize()`.
|
|
|
166
167
|
### `Adshift.getInfo()`
|
|
167
168
|
|
|
168
169
|
```typescript
|
|
169
|
-
{ platform: 'ios' | 'android', version: '
|
|
170
|
+
{ platform: 'ios' | 'android', version: '3.0.0', nativeSdkVersions: { android: '4.1.0', ios: '3.0.0' } }
|
|
170
171
|
```
|
|
171
172
|
|
|
172
173
|
---
|
|
@@ -253,7 +254,7 @@ await Adshift.logAdRevenue({
|
|
|
253
254
|
});
|
|
254
255
|
```
|
|
255
256
|
|
|
256
|
-
`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
|
|
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.
|
|
257
258
|
|
|
258
259
|
---
|
|
259
260
|
|
|
@@ -261,8 +262,10 @@ await Adshift.logAdRevenue({
|
|
|
261
262
|
|
|
262
263
|
### The contract
|
|
263
264
|
|
|
264
|
-
- Every link that opens the app and reaches the SDK — direct, deferred (first launch after install) and push — produces
|
|
265
|
-
- `status === 'found'` means
|
|
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.
|
|
266
269
|
- Results are delivered only through `onDeepLink`. `handleDeepLink()` and `handlePushNotification()` resolve when the SDK has accepted the input.
|
|
267
270
|
|
|
268
271
|
### `Adshift.onDeepLink(callback): DeepLinkSubscription`
|
|
@@ -270,39 +273,54 @@ await Adshift.logAdRevenue({
|
|
|
270
273
|
```typescript
|
|
271
274
|
useEffect(() => {
|
|
272
275
|
const subscription = Adshift.onDeepLink((deepLink) => {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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;
|
|
276
288
|
}
|
|
277
289
|
});
|
|
278
290
|
return () => subscription.remove();
|
|
279
291
|
}, []);
|
|
280
292
|
```
|
|
281
293
|
|
|
282
|
-
- Safe before `initialize()`.
|
|
294
|
+
- Safe before `initialize()`. Results that arrive while no listener is registered wait and are delivered to the first listener.
|
|
283
295
|
- Listeners are called on the JS thread; an exception in one listener does not affect the others. `remove()` is idempotent.
|
|
284
296
|
|
|
285
297
|
```typescript
|
|
286
298
|
interface AdshiftDeepLink {
|
|
287
|
-
deepLink?: string; // the
|
|
299
|
+
deepLink?: string; // the link as opened, a short link expanded
|
|
288
300
|
deepLinkValue?: string; // deep_link_value for routing
|
|
289
|
-
params?: Record<string, string>; // query
|
|
301
|
+
params?: Record<string, string>; // query of a RightLink link, your own keys included
|
|
290
302
|
isDeferred: boolean; // first launch after install
|
|
291
|
-
isFirstSession?: boolean; //
|
|
303
|
+
isFirstSession?: boolean; // the first session after install
|
|
292
304
|
status: AdshiftDeepLinkStatus; // Found | NotFound | Error
|
|
293
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
|
|
294
309
|
deepLinkSub1?: string; /* … */ deepLinkSub5?: string;
|
|
295
310
|
}
|
|
296
311
|
```
|
|
297
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
|
+
|
|
298
316
|
### Automatic forwarding (default)
|
|
299
317
|
|
|
300
318
|
With `autoHandleDeepLinks: true` (the default) you write no linking code:
|
|
301
319
|
|
|
302
|
-
- **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).
|
|
303
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.
|
|
304
322
|
|
|
305
|
-
`start()`
|
|
323
|
+
`start()` hands the launch URL to the SDK first, so the first `app_open` carries the click parameters.
|
|
306
324
|
|
|
307
325
|
### Manual forwarding
|
|
308
326
|
|
|
@@ -312,11 +330,24 @@ Set `autoHandleDeepLinks: false` and forward URLs yourself:
|
|
|
312
330
|
await Adshift.handleDeepLink(url); // resolves once accepted; result arrives via onDeepLink
|
|
313
331
|
```
|
|
314
332
|
|
|
315
|
-
Rejects with `NOT_INITIALIZED` or `INVALID_ARGUMENT` (empty or malformed URL). If you keep an old `Linking → handleDeepLink` handler while automatic forwarding is on,
|
|
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.
|
|
316
334
|
|
|
317
335
|
### Deferred deep links
|
|
318
336
|
|
|
319
|
-
On the first launch after install the SDK
|
|
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.
|
|
320
351
|
|
|
321
352
|
---
|
|
322
353
|
|
|
@@ -347,7 +378,7 @@ notifee.onForegroundEvent(({ type, detail }) => {
|
|
|
347
378
|
});
|
|
348
379
|
```
|
|
349
380
|
|
|
350
|
-
`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.
|
|
351
382
|
|
|
352
383
|
---
|
|
353
384
|
|
|
@@ -457,13 +488,15 @@ not answered yet, which resolves itself once they do.
|
|
|
457
488
|
| `apiKey` | `string` | — | Required |
|
|
458
489
|
| `isDebug` | `boolean` | SDK default | Verbose native logging |
|
|
459
490
|
| `appOpenDebounceMs` | `number` | `10000` | Debounce for automatic `app_open` |
|
|
460
|
-
| `brandedDomains` | `string[]` | — |
|
|
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 |
|
|
461
493
|
| `metaAppId` | `string` | — | Meta App Links parsing (Android) |
|
|
462
494
|
| `pushDeepLinkPaths` | `string[][]` | `[['as_push_link']]` | Extra key paths in push payloads |
|
|
463
495
|
| `autoHandleDeepLinks` | `boolean` | `true` | Automatic URL forwarding |
|
|
464
496
|
| `disableSKAN` | `boolean` | `false` | iOS |
|
|
465
497
|
| `waitForATTBeforeStart` | `boolean` | `false` | iOS; only when **your app** shows the ATT prompt |
|
|
466
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) |
|
|
467
500
|
| `collectOaid` | `boolean` | `true` | Android; OAID on devices without Google Play services |
|
|
468
501
|
|
|
469
502
|
Only options you set are passed to the native SDK; everything else keeps the SDK default.
|
|
@@ -596,7 +629,7 @@ The native SDK ships its own privacy manifest; the plugin adds no tracked APIs.
|
|
|
596
629
|
|
|
597
630
|
**1. Requirements** — `minSdkVersion 24`, `compileSdkVersion 35+`.
|
|
598
631
|
|
|
599
|
-
**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.
|
|
600
633
|
|
|
601
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`:
|
|
602
635
|
|
|
@@ -610,6 +643,15 @@ Without that permission the advertising id is no longer read, and attribution co
|
|
|
610
643
|
|
|
611
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.
|
|
612
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
|
+
|
|
613
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.
|
|
614
656
|
|
|
615
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`.
|
|
@@ -643,9 +685,9 @@ Notes that decide several rows for you:
|
|
|
643
685
|
|
|
644
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.
|
|
645
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.
|
|
646
|
-
- **No location
|
|
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.
|
|
647
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.
|
|
648
|
-
- **
|
|
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.
|
|
649
691
|
- **Everything travels over HTTPS.**
|
|
650
692
|
|
|
651
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.
|
|
@@ -656,7 +698,7 @@ Whether your app's data counts as "shared" under Play's definition, and whether
|
|
|
656
698
|
|
|
657
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.
|
|
658
700
|
|
|
659
|
-
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.
|
|
660
702
|
|
|
661
703
|
- Autolinking and codegen pick the module up.
|
|
662
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.
|
|
@@ -690,9 +732,28 @@ The package ships both ES module and CommonJS builds, so the default `react-nati
|
|
|
690
732
|
|
|
691
733
|
---
|
|
692
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
|
+
|
|
693
754
|
## Upgrading from 1.x
|
|
694
755
|
|
|
695
|
-
2.x
|
|
756
|
+
2.x targeted Android SDK 3.2.0 and iOS SDK 2.4.0 and was a breaking release.
|
|
696
757
|
|
|
697
758
|
**Removed**
|
|
698
759
|
- `NativeAdShiftReactNativePlugin` and `AdShiftNativeSpec` exports — the native module is internal.
|
|
@@ -738,7 +799,9 @@ Replace `API_KEYS` in `example/src/App.tsx` with keys from the AdShift dashboard
|
|
|
738
799
|
|
|
739
800
|
**Links do not arrive on iOS while the app is running** — add the `RCTLinkingManager` methods to `AppDelegate.swift` ([Platform Setup → iOS](#ios)).
|
|
740
801
|
|
|
741
|
-
**
|
|
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()`.
|
|
742
805
|
|
|
743
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.
|
|
744
807
|
|
|
@@ -752,20 +815,6 @@ Replace `API_KEYS` in `example/src/App.tsx` with keys from the AdShift dashboard
|
|
|
752
815
|
|
|
753
816
|
---
|
|
754
817
|
|
|
755
|
-
## For Maintainers
|
|
756
|
-
|
|
757
|
-
**Release**
|
|
758
|
-
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`).
|
|
759
|
-
2. `yarn version <new version>` regenerates `src/version.ts`; commit.
|
|
760
|
-
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`.
|
|
761
|
-
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.
|
|
762
|
-
|
|
763
|
-
**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`.
|
|
764
|
-
|
|
765
|
-
**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.
|
|
766
|
-
|
|
767
|
-
---
|
|
768
|
-
|
|
769
818
|
## Support
|
|
770
819
|
|
|
771
820
|
- Documentation: https://dev.adshift.com/docs/react-native-plugin
|
package/android/build.gradle
CHANGED
|
@@ -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:
|
|
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>
|
package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt
CHANGED
|
@@ -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
|
+
}
|
|
@@ -5,6 +5,7 @@ import android.os.Bundle
|
|
|
5
5
|
import com.adshift.sdk.core.AdShiftLib
|
|
6
6
|
import com.adshift.sdk.core.deeplink.DeepLinkListener
|
|
7
7
|
import com.adshift.sdk.core.deeplink.DeepLinkResult
|
|
8
|
+
import com.adshift.sdk.core.deeplink.DeepLinkSource
|
|
8
9
|
import com.adshift.sdk.core.deeplink.DeepLinkStatus
|
|
9
10
|
import com.facebook.react.bridge.Arguments
|
|
10
11
|
import com.facebook.react.bridge.CxxCallbackImpl
|
|
@@ -34,6 +35,7 @@ import org.robolectric.annotation.Config
|
|
|
34
35
|
class DeepLinkDeliveryTest {
|
|
35
36
|
|
|
36
37
|
private val emitted = mutableListOf<String?>()
|
|
38
|
+
private val emittedPayloads = mutableListOf<ReadableMap>()
|
|
37
39
|
|
|
38
40
|
private lateinit var listener: DeepLinkListener
|
|
39
41
|
private lateinit var context: TestReactContext
|
|
@@ -112,20 +114,55 @@ class DeepLinkDeliveryTest {
|
|
|
112
114
|
assertEquals("results still waiting", 0, ModuleState.pendingDeepLinkCount())
|
|
113
115
|
}
|
|
114
116
|
|
|
117
|
+
@Test
|
|
118
|
+
fun `states the value, the source and the click of a result`() {
|
|
119
|
+
attachEventEmitter(module)
|
|
120
|
+
|
|
121
|
+
listener.onDeepLinking(
|
|
122
|
+
DeepLinkResult(
|
|
123
|
+
uri = Uri.parse(link(1)),
|
|
124
|
+
queryParams = mapOf("deep_link_value" to "from_query"),
|
|
125
|
+
isDeferred = false,
|
|
126
|
+
status = DeepLinkStatus.FOUND,
|
|
127
|
+
deepLinkValue = "promo",
|
|
128
|
+
source = DeepLinkSource.APP_LINK,
|
|
129
|
+
clickId = "click-1",
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
val payload = emittedPayloads.single()
|
|
134
|
+
assertEquals("promo", payload.getString("deepLinkValue"))
|
|
135
|
+
assertEquals("app_link", payload.getString("source"))
|
|
136
|
+
assertEquals("click-1", payload.getString("clickId"))
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@Test
|
|
140
|
+
fun `leaves out the source and the click when the SDK states none`() {
|
|
141
|
+
attachEventEmitter(module)
|
|
142
|
+
|
|
143
|
+
listener.onDeepLinking(deepLinkResult(link(1)))
|
|
144
|
+
|
|
145
|
+
val payload = emittedPayloads.single()
|
|
146
|
+
assertEquals(false, payload.hasKey("source"))
|
|
147
|
+
assertEquals(false, payload.hasKey("clickId"))
|
|
148
|
+
}
|
|
149
|
+
|
|
115
150
|
/** A module created the way a JavaScript reload creates one. */
|
|
116
151
|
private fun reloadedModule() = AdShiftReactNativePluginModule(context.reactContext)
|
|
117
152
|
|
|
118
153
|
private fun attachEventEmitter(target: AdShiftReactNativePluginModule) {
|
|
119
154
|
val callback = mockk<CxxCallbackImpl>(relaxed = true)
|
|
120
|
-
every { callback.invoke(*anyVararg()) } answers {
|
|
155
|
+
every { callback.invoke(*anyVararg()) } answers {
|
|
156
|
+
payloadOf(args)?.let { emittedPayloads += it }
|
|
157
|
+
emitted += payloadOf(args)?.getString("deepLink")
|
|
158
|
+
}
|
|
121
159
|
ATTACH_EMITTER.invoke(target, callback)
|
|
122
160
|
}
|
|
123
161
|
|
|
124
|
-
private fun
|
|
162
|
+
private fun payloadOf(args: List<Any?>): ReadableMap? = args
|
|
125
163
|
.flatMap { if (it is Array<*>) it.asList() else listOf(it) }
|
|
126
164
|
.filterIsInstance<ReadableMap>()
|
|
127
165
|
.firstOrNull()
|
|
128
|
-
?.getString("deepLink")
|
|
129
166
|
|
|
130
167
|
private fun deepLinkResult(url: String) = DeepLinkResult(
|
|
131
168
|
uri = Uri.parse(url),
|
|
@@ -38,6 +38,7 @@ class InitializeOrderingTest {
|
|
|
38
38
|
every { AdShiftLib.initSdk(any(), any()) } answers { calls += "initSdk" }
|
|
39
39
|
every { AdShiftLib.setDebugLog(any()) } answers { calls += "setDebugLog" }
|
|
40
40
|
every { AdShiftLib.setBrandedDomains(any()) } answers { calls += SET_BRANDED_DOMAINS }
|
|
41
|
+
every { AdShiftLib.setTestMode(any()) } answers { calls += SET_TEST_MODE }
|
|
41
42
|
every { AdShiftLib.addPushNotificationDeepLinkPath(*anyVararg()) } answers {
|
|
42
43
|
calls += ADD_PUSH_PATH
|
|
43
44
|
}
|
|
@@ -82,6 +83,18 @@ class InitializeOrderingTest {
|
|
|
82
83
|
assertOptionsPrecedeForwarding()
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
@Test
|
|
87
|
+
fun `turns test mode on before forwarding an intent`() {
|
|
88
|
+
context.launchIntent = deepLinkIntent()
|
|
89
|
+
|
|
90
|
+
module.initialize(initializeConfig().apply { putBoolean("testMode", true) })
|
|
91
|
+
|
|
92
|
+
assertTrue(
|
|
93
|
+
"test mode set after the intent: $calls",
|
|
94
|
+
calls.indexOf(SET_TEST_MODE) in 0 until forwardIndex(),
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
private fun assertOptionsPrecedeForwarding() {
|
|
86
99
|
val forward = forwardIndex()
|
|
87
100
|
assertTrue("no intent reached the SDK: $calls", forward >= 0)
|
|
@@ -104,6 +117,7 @@ class InitializeOrderingTest {
|
|
|
104
117
|
|
|
105
118
|
private companion object {
|
|
106
119
|
const val SET_BRANDED_DOMAINS = "setBrandedDomains"
|
|
120
|
+
const val SET_TEST_MODE = "setTestMode"
|
|
107
121
|
const val ADD_PUSH_PATH = "addPushNotificationDeepLinkPath"
|
|
108
122
|
const val HANDLE_APP_LINK = "handleAppLinkIntent"
|
|
109
123
|
const val HANDLE_PUSH = "handlePushNotification"
|