@adshift/react-native-plugin 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdShiftReactNativePlugin.podspec +20 -4
- package/CHANGELOG.md +30 -17
- package/README.md +55 -47
- package/android/build.gradle +2 -3
- package/android/consumer-rules.pro +2 -21
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/adshift/reactnativeplugin/ActivityIntents.kt +307 -0
- package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +83 -157
- package/android/src/test/java/com/adshift/reactnativeplugin/ConsentSnapshotTest.kt +0 -20
- package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +0 -4
- package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +37 -5
- package/android/src/test/java/com/adshift/reactnativeplugin/IntentLinkDedupTest.kt +0 -5
- package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +7 -26
- package/android/src/test/java/com/adshift/reactnativeplugin/LaunchLinkRecordTest.kt +420 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +93 -34
- package/android/src/test/java/com/adshift/reactnativeplugin/StartVerdictTest.kt +0 -4
- package/ios/AdShiftReactNativePlugin.h +0 -12
- package/ios/AdShiftReactNativePlugin.mm +2 -14
- package/ios/AdShiftReactNativePluginHelper.swift +14 -73
- package/ios/Core/BridgeRules.swift +24 -29
- package/lib/commonjs/Adshift.js +78 -285
- package/lib/commonjs/Adshift.js.map +1 -1
- package/lib/commonjs/NativeAdShiftReactNativePlugin.js +2 -11
- package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest/index.js +4 -18
- package/lib/commonjs/jest/index.js.map +1 -1
- package/lib/commonjs/nativeSdkVersions.js +4 -6
- package/lib/commonjs/nativeSdkVersions.js.map +1 -1
- package/lib/commonjs/types/AdshiftAdRevenue.js +0 -24
- package/lib/commonjs/types/AdshiftAdRevenue.js.map +1 -1
- package/lib/commonjs/types/AdshiftConfig.js +3 -24
- package/lib/commonjs/types/AdshiftConfig.js.map +1 -1
- package/lib/commonjs/types/AdshiftConsent.js +9 -45
- package/lib/commonjs/types/AdshiftConsent.js.map +1 -1
- package/lib/commonjs/types/AdshiftConsentSnapshot.js +5 -24
- package/lib/commonjs/types/AdshiftConsentSnapshot.js.map +1 -1
- package/lib/commonjs/types/AdshiftDeepLink.js +3 -30
- package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -1
- package/lib/commonjs/types/AdshiftError.js +7 -27
- package/lib/commonjs/types/AdshiftError.js.map +1 -1
- package/lib/commonjs/types/AdshiftEventParam.js +4 -38
- package/lib/commonjs/types/AdshiftEventParam.js.map +1 -1
- package/lib/commonjs/types/AdshiftEventType.js +1 -39
- package/lib/commonjs/types/AdshiftEventType.js.map +1 -1
- package/lib/commonjs/types/AdshiftThirdPartySharing.js +7 -38
- package/lib/commonjs/types/AdshiftThirdPartySharing.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/Adshift.js +78 -285
- package/lib/module/Adshift.js.map +1 -1
- package/lib/module/NativeAdShiftReactNativePlugin.js +2 -12
- package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
- package/lib/module/index.js +1 -46
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +4 -18
- package/lib/module/jest/index.js.map +1 -1
- package/lib/module/nativeSdkVersions.js +4 -6
- package/lib/module/nativeSdkVersions.js.map +1 -1
- package/lib/module/types/AdshiftAdRevenue.js +0 -24
- package/lib/module/types/AdshiftAdRevenue.js.map +1 -1
- package/lib/module/types/AdshiftConfig.js +3 -24
- package/lib/module/types/AdshiftConfig.js.map +1 -1
- package/lib/module/types/AdshiftConsent.js +9 -45
- package/lib/module/types/AdshiftConsent.js.map +1 -1
- package/lib/module/types/AdshiftConsentSnapshot.js +5 -24
- package/lib/module/types/AdshiftConsentSnapshot.js.map +1 -1
- package/lib/module/types/AdshiftDeepLink.js +3 -31
- package/lib/module/types/AdshiftDeepLink.js.map +1 -1
- package/lib/module/types/AdshiftError.js +7 -28
- package/lib/module/types/AdshiftError.js.map +1 -1
- package/lib/module/types/AdshiftEventParam.js +4 -38
- package/lib/module/types/AdshiftEventParam.js.map +1 -1
- package/lib/module/types/AdshiftEventType.js +1 -39
- package/lib/module/types/AdshiftEventType.js.map +1 -1
- package/lib/module/types/AdshiftThirdPartySharing.js +7 -38
- package/lib/module/types/AdshiftThirdPartySharing.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/commonjs/src/Adshift.d.ts +61 -185
- package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +10 -36
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +0 -32
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/jest/index.d.ts +6 -20
- package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +4 -6
- package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts +0 -24
- package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +10 -37
- package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts +9 -49
- package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts +10 -28
- package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +6 -34
- package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftError.d.ts +7 -26
- package/lib/typescript/commonjs/src/types/AdshiftError.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts +3 -19
- package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts +1 -23
- package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts +7 -38
- package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/version.d.ts +1 -1
- package/lib/typescript/module/src/Adshift.d.ts +61 -185
- package/lib/typescript/module/src/Adshift.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +10 -36
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +0 -32
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/jest/index.d.ts +6 -20
- package/lib/typescript/module/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeSdkVersions.d.ts +4 -6
- package/lib/typescript/module/src/nativeSdkVersions.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts +0 -24
- package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftConfig.d.ts +10 -37
- package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftConsent.d.ts +9 -49
- package/lib/typescript/module/src/types/AdshiftConsent.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts +10 -28
- package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +6 -34
- package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftError.d.ts +7 -26
- package/lib/typescript/module/src/types/AdshiftError.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftEventParam.d.ts +3 -19
- package/lib/typescript/module/src/types/AdshiftEventParam.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftEventType.d.ts +1 -23
- package/lib/typescript/module/src/types/AdshiftEventType.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts +7 -38
- package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
- package/lib/typescript/module/src/version.d.ts +1 -1
- package/package.json +11 -1
- package/src/Adshift.ts +82 -286
- package/src/NativeAdShiftReactNativePlugin.ts +10 -48
- package/src/index.tsx +1 -44
- package/src/jest/index.ts +6 -20
- package/src/nativeSdkVersions.ts +4 -6
- package/src/types/AdshiftAdRevenue.ts +0 -24
- package/src/types/AdshiftConfig.ts +11 -54
- package/src/types/AdshiftConsent.ts +9 -49
- package/src/types/AdshiftConsentSnapshot.ts +11 -38
- package/src/types/AdshiftDeepLink.ts +6 -34
- package/src/types/AdshiftError.ts +7 -26
- package/src/types/AdshiftEventParam.ts +4 -38
- package/src/types/AdshiftEventType.ts +1 -39
- package/src/types/AdshiftThirdPartySharing.ts +7 -38
- package/src/version.ts +1 -1
- package/vendor/ios/AdshiftSDK.files.json +30 -0
- package/vendor/ios/AdshiftSDK.xcframework/Info.plist +44 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/AdshiftSDK +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +315 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Info.plist +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.abi.json +18729 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/module.modulemap +4 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/AdshiftSDK +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +626 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Info.plist +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +18729 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +18729 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/module.modulemap +4 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
- package/android/src/main/java/com/adshift/reactnativeplugin/RestoredIntents.kt +0 -64
|
@@ -3,7 +3,9 @@ package com.adshift.reactnativeplugin
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import android.content.Intent
|
|
6
|
+
import android.os.Build
|
|
6
7
|
import android.os.Bundle
|
|
8
|
+
import android.provider.Settings
|
|
7
9
|
import androidx.test.core.app.ApplicationProvider
|
|
8
10
|
import com.facebook.react.bridge.JavaOnlyArray
|
|
9
11
|
import com.facebook.react.bridge.JavaOnlyMap
|
|
@@ -14,15 +16,19 @@ import com.facebook.soloader.nativeloader.NativeLoader
|
|
|
14
16
|
import com.facebook.soloader.nativeloader.NativeLoaderDelegate
|
|
15
17
|
import io.mockk.every
|
|
16
18
|
import io.mockk.mockk
|
|
19
|
+
import java.io.File
|
|
20
|
+
import java.lang.reflect.Field
|
|
17
21
|
|
|
18
|
-
/**
|
|
19
|
-
* The module keeps its Intent bookkeeping in the companion object, so it survives module
|
|
20
|
-
* instances the way it survives JavaScript reloads. Each test starts from a freshly launched
|
|
21
|
-
* process, which this helper restores through reflection.
|
|
22
|
-
*/
|
|
22
|
+
/** The module's state lives in its companion object and outlives instances; tests reset it here. */
|
|
23
23
|
internal object ModuleState {
|
|
24
24
|
|
|
25
25
|
fun reset() {
|
|
26
|
+
killProcess()
|
|
27
|
+
LaunchRecordsState.deleteFile()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** As when Android kills the process: memory goes, the app's files stay. */
|
|
31
|
+
fun killProcess() {
|
|
26
32
|
set("currentModule", null)
|
|
27
33
|
set("sdkInitialized", false)
|
|
28
34
|
set("readyForIntents", false)
|
|
@@ -30,22 +36,24 @@ internal object ModuleState {
|
|
|
30
36
|
set("autoHandleDeepLinks", true)
|
|
31
37
|
set("collectOaidApplied", false)
|
|
32
38
|
set("pendingIntent", null)
|
|
33
|
-
set("lastLaunchIntentFingerprint", null)
|
|
34
39
|
clear("processedIntents")
|
|
35
40
|
clear("autoForwardedUrls")
|
|
36
41
|
clear("launchForwardedUrls")
|
|
37
42
|
clear("registeredPushPaths")
|
|
38
43
|
clear("pendingDeepLinks")
|
|
39
|
-
(
|
|
44
|
+
for (name in listOf("byActivity", "byIntent", "newIntentReceived")) {
|
|
45
|
+
when (val value = objectField(ActivityIntents::class.java, name).get(null)) {
|
|
46
|
+
is MutableMap<*, *> -> value.clear()
|
|
47
|
+
is MutableCollection<*> -> value.clear()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
objectField(ActivityIntents::class.java, "application").set(null, null)
|
|
51
|
+
LaunchRecordsState.forgetMemory()
|
|
40
52
|
}
|
|
41
53
|
|
|
42
|
-
/** Deep link results still waiting for a JavaScript listener. */
|
|
43
54
|
fun pendingDeepLinkCount(): Int = (field("pendingDeepLinks").get(null) as Collection<*>).size
|
|
44
55
|
|
|
45
|
-
/**
|
|
46
|
-
* Simulates the short dedup window having passed, so what remains is the memory that lasts
|
|
47
|
-
* as long as the process. A reload can happen minutes after the app was opened.
|
|
48
|
-
*/
|
|
56
|
+
/** Stands in for the two-second window passing; what lasts for the process remains. */
|
|
49
57
|
fun expireAutoForwardWindow() = clear("autoForwardedUrls")
|
|
50
58
|
|
|
51
59
|
private fun set(name: String, value: Any?) = field(name).set(null, value)
|
|
@@ -57,36 +65,90 @@ internal object ModuleState {
|
|
|
57
65
|
}
|
|
58
66
|
}
|
|
59
67
|
|
|
60
|
-
private fun field(name: String) = AdShiftReactNativePluginModule::class.java
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
private fun field(name: String) = objectField(AdShiftReactNativePluginModule::class.java, name)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
internal object LaunchRecordsState {
|
|
72
|
+
|
|
73
|
+
private val app: Context get() = ApplicationProvider.getApplicationContext()
|
|
74
|
+
|
|
75
|
+
val file: File get() = File(app.noBackupFilesDir, "adshift_rn_launch_links.json")
|
|
63
76
|
|
|
64
|
-
|
|
65
|
-
.
|
|
66
|
-
.
|
|
77
|
+
fun deleteFile() {
|
|
78
|
+
file.delete()
|
|
79
|
+
File(file.path + ".bak").delete()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Drops what the process read, so the next use reads the file again. */
|
|
83
|
+
fun forgetMemory() {
|
|
84
|
+
objectField(LaunchRecords::class.java, "file").set(null, null)
|
|
85
|
+
objectField(LaunchRecords::class.java, "entries").set(null, null)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A new boot of the phone, as the next process reads it. */
|
|
89
|
+
fun restartPhone(bootCount: Int) {
|
|
90
|
+
Settings.Global.putInt(app.contentResolver, Settings.Global.BOOT_COUNT, bootCount)
|
|
91
|
+
forgetMemory()
|
|
92
|
+
}
|
|
67
93
|
}
|
|
68
94
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
95
|
+
internal fun objectField(type: Class<*>, name: String): Field =
|
|
96
|
+
type.getDeclaredField(name).apply { isAccessible = true }
|
|
97
|
+
|
|
98
|
+
internal const val TASK_ID = 38
|
|
99
|
+
|
|
100
|
+
internal class FakeActivity(var intent: Intent?, val taskId: Int = TASK_ID) {
|
|
101
|
+
|
|
102
|
+
var finishing = false
|
|
103
|
+
|
|
104
|
+
val activity: Activity = mockk<Activity>(relaxed = true).also {
|
|
105
|
+
every { it.intent } answers { intent }
|
|
106
|
+
every { it.taskId } answers { taskId }
|
|
107
|
+
every { it.isFinishing } answers { finishing }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** From API 29 the state the system kept, then what the app passes to `super.onCreate`. */
|
|
111
|
+
fun create(savedState: Bundle?, appPassesState: Boolean = true): FakeActivity {
|
|
112
|
+
if (Build.VERSION.SDK_INT >= 29) ActivityIntents.onActivityPreCreated(activity, savedState)
|
|
113
|
+
ActivityIntents.onActivityCreated(activity, if (appPassesState) savedState else null)
|
|
114
|
+
return this
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** `super.onNewIntent` and `setIntent`, the step the setup asks of `MainActivity`. */
|
|
118
|
+
fun keepNewIntent(newIntent: Intent) {
|
|
119
|
+
intent = newIntent
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Closed for good, for example with Back. */
|
|
123
|
+
fun finish() {
|
|
124
|
+
finishing = true
|
|
125
|
+
ActivityIntents.onActivityDestroyed(activity)
|
|
126
|
+
}
|
|
74
127
|
}
|
|
75
128
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*/
|
|
129
|
+
internal fun recreateActivityHolding(intent: Intent): FakeActivity =
|
|
130
|
+
FakeActivity(intent).create(Bundle())
|
|
131
|
+
|
|
132
|
+
/** Setting [launchIntent] hands the current Activity a new Intent, as `setIntent` does. */
|
|
80
133
|
internal class TestReactContext {
|
|
81
134
|
|
|
82
|
-
var
|
|
135
|
+
var activity: FakeActivity? = null
|
|
136
|
+
|
|
137
|
+
var launchIntent: Intent?
|
|
138
|
+
get() = activity?.intent
|
|
139
|
+
set(value) {
|
|
140
|
+
val current = activity
|
|
141
|
+
when {
|
|
142
|
+
value == null -> activity = null
|
|
143
|
+
current == null -> activity = FakeActivity(value)
|
|
144
|
+
else -> current.keepNewIntent(value)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
83
147
|
|
|
84
148
|
val reactContext: ReactApplicationContext = mockk(relaxed = true)
|
|
85
149
|
|
|
86
150
|
init {
|
|
87
|
-
|
|
88
|
-
every { activity.intent } answers { launchIntent }
|
|
89
|
-
every { reactContext.currentActivity } answers { launchIntent?.let { activity } }
|
|
151
|
+
every { reactContext.currentActivity } answers { activity?.activity }
|
|
90
152
|
every { reactContext.applicationContext } returns
|
|
91
153
|
ApplicationProvider.getApplicationContext<Context>()
|
|
92
154
|
}
|
|
@@ -96,7 +158,6 @@ internal const val API_KEY = "test-api-key"
|
|
|
96
158
|
internal const val BRANDED_DOMAIN = "links.example.com"
|
|
97
159
|
internal const val PUSH_LINK_KEY = "as_push_link"
|
|
98
160
|
|
|
99
|
-
/** Config as the JavaScript layer sends it: branded domains, a push path and the debug flag. */
|
|
100
161
|
internal fun initializeConfig(): JavaOnlyMap = JavaOnlyMap().apply {
|
|
101
162
|
putString("apiKey", API_KEY)
|
|
102
163
|
putBoolean("isDebug", true)
|
|
@@ -104,7 +165,6 @@ internal fun initializeConfig(): JavaOnlyMap = JavaOnlyMap().apply {
|
|
|
104
165
|
putArray("pushDeepLinkPaths", JavaOnlyArray.of(JavaOnlyArray.of(PUSH_LINK_KEY)))
|
|
105
166
|
}
|
|
106
167
|
|
|
107
|
-
/** A plain launcher start: no data URI and no extras. */
|
|
108
168
|
internal fun launcherIntent(): Intent = Intent(Intent.ACTION_MAIN).apply {
|
|
109
169
|
addCategory(Intent.CATEGORY_LAUNCHER)
|
|
110
170
|
}
|
|
@@ -115,7 +175,6 @@ internal fun notificationIntent(link: String, messageId: String): Intent = launc
|
|
|
115
175
|
putExtra("google.message_id", messageId)
|
|
116
176
|
}
|
|
117
177
|
|
|
118
|
-
/** Records what the module answered, in place of the JavaScript promise. */
|
|
119
178
|
internal class RecordingPromise : Promise {
|
|
120
179
|
|
|
121
180
|
var resolved = false
|
|
@@ -25,10 +25,6 @@ import org.robolectric.RobolectricTestRunner
|
|
|
25
25
|
import org.robolectric.Shadows.shadowOf
|
|
26
26
|
import org.robolectric.annotation.Config
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* `start` answers with what the SDK reported, so a device that opted out or a key the backend
|
|
30
|
-
* refused is visible to JavaScript instead of only reaching the log.
|
|
31
|
-
*/
|
|
32
28
|
@RunWith(RobolectricTestRunner::class)
|
|
33
29
|
@Config(sdk = [35])
|
|
34
30
|
class StartVerdictTest {
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
// AdShiftReactNativePlugin.h
|
|
3
|
-
// AdShiftReactNativePlugin
|
|
4
|
-
//
|
|
5
|
-
// Turbo Module header for the AdShift React Native Plugin.
|
|
6
|
-
//
|
|
7
1
|
// Copyright © 2025 AdShift. All rights reserved.
|
|
8
|
-
//
|
|
9
2
|
|
|
10
3
|
#import <React/RCTInvalidating.h>
|
|
11
4
|
#import <AdShiftReactNativePluginSpec/AdShiftReactNativePluginSpec.h>
|
|
12
5
|
|
|
13
6
|
NS_ASSUME_NONNULL_BEGIN
|
|
14
7
|
|
|
15
|
-
/// AdShift Turbo Module.
|
|
16
|
-
///
|
|
17
|
-
/// Implements the Codegen-generated `NativeAdShiftReactNativePluginSpec` and
|
|
18
|
-
/// forwards every call to the Swift helper, which talks to the AdShift iOS SDK.
|
|
19
|
-
/// Deep link results reach JavaScript through the `onDeepLink` event.
|
|
20
8
|
@interface AdShiftReactNativePlugin : NativeAdShiftReactNativePluginSpecBase <NativeAdShiftReactNativePluginSpec, RCTInvalidating>
|
|
21
9
|
|
|
22
10
|
@end
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// AdShiftReactNativePlugin.mm
|
|
3
|
-
// AdShiftReactNativePlugin
|
|
4
|
-
//
|
|
5
|
-
// Objective-C++ implementation of the Turbo Module.
|
|
6
|
-
// Forwards JavaScript calls to the Swift helper and emits deep link events.
|
|
7
|
-
//
|
|
8
1
|
// Copyright © 2025 AdShift. All rights reserved.
|
|
9
|
-
//
|
|
10
2
|
|
|
11
3
|
#import "AdShiftReactNativePlugin.h"
|
|
12
4
|
|
|
@@ -18,10 +10,8 @@
|
|
|
18
10
|
|
|
19
11
|
static NSString *const kAdShiftBridgeErrorDomain = @"com.adshift.reactnativeplugin";
|
|
20
12
|
|
|
21
|
-
///
|
|
22
|
-
///
|
|
23
|
-
/// JavaScript receives `error.code` (bridge code) and
|
|
24
|
-
/// `error.userInfo.nativeCode` / `error.userInfo.nativeDomain` when available.
|
|
13
|
+
/// JavaScript reads the bridge code as `error.code` and the SDK's code and domain
|
|
14
|
+
/// as `error.userInfo.nativeCode` and `error.userInfo.nativeDomain`.
|
|
25
15
|
static void RejectWithError(RCTPromiseRejectBlock reject, NSError *error)
|
|
26
16
|
{
|
|
27
17
|
NSString *code = error.userInfo[@"code"];
|
|
@@ -81,8 +71,6 @@ RCT_EXPORT_MODULE(AdShiftReactNativePlugin)
|
|
|
81
71
|
|
|
82
72
|
#pragma mark - AdShiftDeepLinkEmitting
|
|
83
73
|
|
|
84
|
-
/// Returns NO when JavaScript cannot receive the event, so the caller can keep the payload.
|
|
85
|
-
/// The emitter callback is absent before the module is installed and after it is torn down.
|
|
86
74
|
- (BOOL)emitDeepLink:(NSDictionary<NSString *, id> *)payload
|
|
87
75
|
{
|
|
88
76
|
if (_invalidated || !_eventEmitterCallback) {
|
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
//
|
|
2
|
-
// AdShiftReactNativePluginHelper.swift
|
|
3
|
-
// AdShiftReactNativePlugin
|
|
4
|
-
//
|
|
5
|
-
// Swift bridge between the Objective-C++ Turbo Module and the AdShift iOS SDK.
|
|
6
|
-
//
|
|
7
1
|
// Copyright © 2025 AdShift. All rights reserved.
|
|
8
|
-
//
|
|
9
2
|
|
|
10
3
|
import Foundation
|
|
11
4
|
import AdshiftSDK
|
|
12
5
|
import os
|
|
13
6
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/// Implemented by the Turbo Module. Receives serialised deep link payloads on the main thread.
|
|
17
|
-
/// Returns false when JavaScript cannot receive the payload, so it can be delivered later.
|
|
7
|
+
/// Called on the main thread. Returns false when JavaScript cannot receive the payload,
|
|
8
|
+
/// so the bridge keeps it for later.
|
|
18
9
|
@objc public protocol AdShiftDeepLinkEmitting: AnyObject, Sendable {
|
|
19
10
|
func emitDeepLink(_ payload: [String: Any]) -> Bool
|
|
20
11
|
}
|
|
21
12
|
|
|
22
|
-
/// Delivers the `start()` result dictionary; `start()` never fails at the bridge level.
|
|
23
13
|
public typealias AdShiftStartCompletion = @Sendable ([String: Any]) -> Void
|
|
24
|
-
/// Delivers a result dictionary or a bridge `NSError` (see `BridgeError`).
|
|
25
14
|
public typealias AdShiftResultCompletion = @Sendable ([String: Any]?, NSError?) -> Void
|
|
26
15
|
public typealias AdShiftVoidCompletion = @Sendable (NSError?) -> Void
|
|
27
16
|
public typealias AdShiftStringCompletion = @Sendable (String?) -> Void
|
|
@@ -29,12 +18,7 @@ public typealias AdShiftBoolCompletion = @Sendable (Bool) -> Void
|
|
|
29
18
|
|
|
30
19
|
private let log = Logger(subsystem: "com.adshift.reactnativeplugin", category: "bridge")
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/// Platform-neutral error passed to JavaScript.
|
|
35
|
-
///
|
|
36
|
-
/// Serialised as an `NSError` whose `userInfo` carries the bridge `code`
|
|
37
|
-
/// plus the native SDK code and domain when available.
|
|
21
|
+
/// The Turbo Module reads `code`, `nativeCode` and `nativeDomain` from `nsError.userInfo`.
|
|
38
22
|
struct BridgeError: Error {
|
|
39
23
|
static let domain = "com.adshift.reactnativeplugin"
|
|
40
24
|
|
|
@@ -90,25 +74,18 @@ func mapError(_ error: Error) -> BridgeError {
|
|
|
90
74
|
)
|
|
91
75
|
}
|
|
92
76
|
|
|
93
|
-
// MARK: - Main-actor state
|
|
94
|
-
|
|
95
|
-
/// Mutable bridge state. Lives on the main actor together with the SDK.
|
|
96
77
|
@MainActor
|
|
97
78
|
private final class BridgeState {
|
|
98
79
|
static let shared = BridgeState()
|
|
99
80
|
|
|
100
|
-
/// The current Turbo Module instance; replaced on React Native reloads.
|
|
101
81
|
weak var emitter: AdShiftDeepLinkEmitting?
|
|
102
|
-
/// The SDK listener is registered once per process.
|
|
103
82
|
var isDeepLinkListenerRegistered = false
|
|
104
83
|
var pushDeepLinkPaths: Set<[String]> = []
|
|
105
|
-
///
|
|
84
|
+
/// Results that arrive while no module can receive them, as during a reload,
|
|
85
|
+
/// wait here; they are not delivered again.
|
|
106
86
|
var pendingDeepLinks: [[String: Any]] = []
|
|
107
|
-
/// URLs that opened this process, oldest first. Kept until the process dies,
|
|
108
|
-
/// because JavaScript reads the launch URL again after every reload.
|
|
109
87
|
var launchForwardedUrls: [String] = []
|
|
110
88
|
|
|
111
|
-
/// Deep link results are delivered once, so a reload must not consume them.
|
|
112
89
|
static let pendingDeepLinkLimit = 20
|
|
113
90
|
static let launchUrlMemoryLimit = 20
|
|
114
91
|
|
|
@@ -121,12 +98,7 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
121
98
|
let value: Value
|
|
122
99
|
}
|
|
123
100
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
/// Objective-C entry points for the Turbo Module.
|
|
127
|
-
///
|
|
128
|
-
/// Every method returns immediately and performs the SDK call on the main
|
|
129
|
-
/// actor; results are delivered through `@Sendable` completion blocks.
|
|
101
|
+
/// Every method returns at once and runs its SDK call on the main actor.
|
|
130
102
|
@objc public final class AdShiftReactNativePluginHelper: NSObject, @unchecked Sendable {
|
|
131
103
|
|
|
132
104
|
@objc public static let shared = AdShiftReactNativePluginHelper()
|
|
@@ -135,8 +107,6 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
135
107
|
super.init()
|
|
136
108
|
}
|
|
137
109
|
|
|
138
|
-
// MARK: Module binding
|
|
139
|
-
|
|
140
110
|
/// Registers the module that receives deep link events and delivers anything kept for it.
|
|
141
111
|
@objc nonisolated public func setModule(_ module: AdShiftDeepLinkEmitting) {
|
|
142
112
|
Task { @MainActor in
|
|
@@ -160,9 +130,7 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
160
130
|
}
|
|
161
131
|
}
|
|
162
132
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
/// Applies the configuration dictionary. Only keys that are present change SDK settings.
|
|
133
|
+
/// Keys that are absent leave the SDK's settings untouched.
|
|
166
134
|
@objc nonisolated public func initialize(config: [String: Any]) {
|
|
167
135
|
let boxed = BridgeValue(value: config)
|
|
168
136
|
Task { @MainActor in
|
|
@@ -172,7 +140,7 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
172
140
|
}
|
|
173
141
|
}
|
|
174
142
|
|
|
175
|
-
///
|
|
143
|
+
/// The result dictionary always contains `success`.
|
|
176
144
|
@objc nonisolated public func start(completion: @escaping AdShiftStartCompletion) {
|
|
177
145
|
Task { @MainActor in
|
|
178
146
|
Adshift.shared.start { response, error in
|
|
@@ -187,8 +155,6 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
187
155
|
}
|
|
188
156
|
}
|
|
189
157
|
|
|
190
|
-
// MARK: Configuration
|
|
191
|
-
|
|
192
158
|
@objc nonisolated public func setCustomerUserId(_ userId: String) {
|
|
193
159
|
Task { @MainActor in
|
|
194
160
|
Adshift.shared.setCustomerUserId(userId)
|
|
@@ -215,18 +181,14 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
215
181
|
}
|
|
216
182
|
}
|
|
217
183
|
|
|
218
|
-
/// Meta app id is used by the Android SDK only.
|
|
219
184
|
@objc nonisolated public func setMetaAppId(_ appId: String) {
|
|
220
185
|
log.debug("setMetaAppId has no effect on iOS")
|
|
221
186
|
}
|
|
222
187
|
|
|
223
|
-
/// OAID exists on Android devices only.
|
|
224
188
|
@objc nonisolated public func setOaidData(_ oaid: String) {
|
|
225
189
|
log.debug("setOaidData has no effect on iOS")
|
|
226
190
|
}
|
|
227
191
|
|
|
228
|
-
// MARK: Consent
|
|
229
|
-
|
|
230
192
|
@objc nonisolated public func setConsentData(_ consent: [String: Any]) {
|
|
231
193
|
let boxed = BridgeValue(value: consent)
|
|
232
194
|
Task { @MainActor in
|
|
@@ -246,8 +208,6 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
246
208
|
}
|
|
247
209
|
}
|
|
248
210
|
|
|
249
|
-
/// A call carrying no usable answer is dropped rather than defaulted; the
|
|
250
|
-
/// reasoning sits with the rule in `BridgeRules`.
|
|
251
211
|
@objc nonisolated public func setThirdPartySharing(_ sharing: [String: Any]) {
|
|
252
212
|
let boxed = BridgeValue(value: sharing)
|
|
253
213
|
Task { @MainActor in
|
|
@@ -273,8 +233,6 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
273
233
|
}
|
|
274
234
|
}
|
|
275
235
|
|
|
276
|
-
// MARK: Event tracking
|
|
277
|
-
|
|
278
236
|
@objc nonisolated public func trackEvent(
|
|
279
237
|
_ eventName: String,
|
|
280
238
|
values: [String: Any]?,
|
|
@@ -313,10 +271,8 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
313
271
|
}
|
|
314
272
|
}
|
|
315
273
|
|
|
316
|
-
///
|
|
317
|
-
///
|
|
318
|
-
/// An excluded device comes back as a status next to no error, and it is a
|
|
319
|
-
/// refusal to record the event, so JavaScript is told so on both platforms.
|
|
274
|
+
/// An opted-out device comes back as a status, not an error; JavaScript gets
|
|
275
|
+
/// `OPTED_OUT`, as on Android.
|
|
320
276
|
private static func trackingOutcome(_ response: [String: Any]?, _ error: Error?) -> NSError? {
|
|
321
277
|
if let error {
|
|
322
278
|
return mapError(error).nsError
|
|
@@ -345,21 +301,14 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
345
301
|
}
|
|
346
302
|
}
|
|
347
303
|
|
|
348
|
-
// MARK: Identity
|
|
349
|
-
|
|
350
304
|
@objc nonisolated public func getAdShiftDeviceId(completion: @escaping AdShiftStringCompletion) {
|
|
351
305
|
Task { @MainActor in
|
|
352
306
|
completion(Adshift.shared.getAdShiftDeviceId())
|
|
353
307
|
}
|
|
354
308
|
}
|
|
355
309
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
/// Passes a URL to the SDK. The result is delivered through the deep link listener only.
|
|
359
|
-
///
|
|
360
|
-
/// `fromLaunch` marks the URL that opened the app. Those are remembered for the lifetime of
|
|
361
|
-
/// the process, so a JavaScript reload cannot book the same link twice, while a second tap
|
|
362
|
-
/// arrives as a live URL and is forwarded.
|
|
310
|
+
/// A `fromLaunch` URL is forwarded once per process, because JavaScript reads the
|
|
311
|
+
/// launch URL again after every reload.
|
|
363
312
|
@objc nonisolated public func handleDeepLink(
|
|
364
313
|
_ urlString: String,
|
|
365
314
|
fromLaunch: Bool,
|
|
@@ -395,7 +344,7 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
395
344
|
}
|
|
396
345
|
}
|
|
397
346
|
|
|
398
|
-
/// `nil`, or a string
|
|
347
|
+
/// `nil`, or a string `URL(string:)` cannot parse, tells the SDK the user skipped the paste.
|
|
399
348
|
@objc nonisolated public func handlePastedDeepLink(_ urlString: String?) {
|
|
400
349
|
Task { @MainActor in
|
|
401
350
|
Adshift.shared.handlePastedDeepLink(urlString.flatMap(URL.init(string:)))
|
|
@@ -418,8 +367,6 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
418
367
|
}
|
|
419
368
|
}
|
|
420
369
|
|
|
421
|
-
// MARK: - Main-actor helpers
|
|
422
|
-
|
|
423
370
|
@MainActor
|
|
424
371
|
private static func applyConfig(_ config: [String: Any]) {
|
|
425
372
|
let sdk = Adshift.shared
|
|
@@ -491,8 +438,6 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
491
438
|
Adshift.shared.addPushNotificationDeepLinkPath(path)
|
|
492
439
|
}
|
|
493
440
|
|
|
494
|
-
// MARK: - Pure helpers
|
|
495
|
-
|
|
496
441
|
private static func startResult(response: [String: Any]?, error: Error?) -> [String: Any] {
|
|
497
442
|
if let error {
|
|
498
443
|
if case AdShiftError.alreadyStarted = error {
|
|
@@ -529,10 +474,7 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
529
474
|
return Int(min(value, Double(Int32.max)).rounded())
|
|
530
475
|
}
|
|
531
476
|
|
|
532
|
-
///
|
|
533
|
-
///
|
|
534
|
-
/// Booleans arrive as `NSNumber` and are converted to `Bool`; other numbers
|
|
535
|
-
/// stay `NSNumber`. Null, array and dictionary values are dropped.
|
|
477
|
+
/// Keeps strings, numbers and booleans; drops everything else.
|
|
536
478
|
private static func coerceEventValues(_ values: [String: Any]) -> [String: Any] {
|
|
537
479
|
var result: [String: Any] = [:]
|
|
538
480
|
result.reserveCapacity(values.count)
|
|
@@ -687,7 +629,6 @@ private struct BridgeValue<Value>: @unchecked Sendable {
|
|
|
687
629
|
}
|
|
688
630
|
}
|
|
689
631
|
|
|
690
|
-
/// Serialises a deep link response for JavaScript.
|
|
691
632
|
private static func serialize(_ response: DeeplinkResponse) -> [String: Any] {
|
|
692
633
|
BridgeRules.deepLinkPayload(
|
|
693
634
|
deepLink: response.deeplink,
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
|
|
3
|
-
///
|
|
4
|
-
///
|
|
5
|
-
/// Free of SDK and React types on purpose: the call sites translate native
|
|
6
|
-
/// values into plain ones, which keeps these rules exercisable on their own.
|
|
3
|
+
/// Free of SDK and React types on purpose, so `swift test` can build and run
|
|
4
|
+
/// these rules without either.
|
|
7
5
|
enum BridgeRules {
|
|
8
|
-
///
|
|
9
|
-
///
|
|
10
|
-
///
|
|
11
|
-
/// states the routing value and nothing about its own origin or outcome,
|
|
12
|
-
/// while a direct one states both, so the missing halves are derived here
|
|
13
|
-
/// and JavaScript gets one shape whatever the source was. An error outranks
|
|
14
|
-
/// any status that came with it.
|
|
6
|
+
/// `params`, `isDeferred` and `status` are always present. A deferred result can
|
|
7
|
+
/// arrive without `isDeferred` and `status`, so both are derived here; an error
|
|
8
|
+
/// outranks any reported status.
|
|
15
9
|
static func deepLinkPayload(
|
|
16
10
|
deepLink: String?,
|
|
17
11
|
deepLinkValue: String?,
|
|
@@ -39,8 +33,20 @@ enum BridgeRules {
|
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
let isDeferred = reportedIsDeferred ?? (reportedStatus == nil)
|
|
37
|
+
var resolvedParams = params ?? [:]
|
|
38
|
+
// A deferred result has no query string, so its subs go into `params` as on
|
|
39
|
+
// Android, and routing code reads them the same way for every link.
|
|
40
|
+
if isDeferred {
|
|
41
|
+
for (index, sub) in subs.prefix(5).enumerated() {
|
|
42
|
+
let key = "deep_link_sub\(index + 1)"
|
|
43
|
+
if let sub, resolvedParams[key] == nil {
|
|
44
|
+
resolvedParams[key] = sub
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
result["params"] = resolvedParams
|
|
49
|
+
result["isDeferred"] = isDeferred
|
|
44
50
|
|
|
45
51
|
let hasLink = deepLink != nil || deepLinkValue != nil
|
|
46
52
|
result["status"] = reportedStatus ?? (hasLink ? "found" : "notFound")
|
|
@@ -66,18 +72,12 @@ enum BridgeRules {
|
|
|
66
72
|
return result
|
|
67
73
|
}
|
|
68
74
|
|
|
69
|
-
/// Whether a tracking call was refused because this device is excluded.
|
|
70
|
-
///
|
|
71
|
-
/// The refusal arrives as a status next to no error, and it means the event
|
|
72
|
-
/// was not recorded.
|
|
73
75
|
static func isExcludedFromTracking(responseStatus: String?) -> Bool {
|
|
74
76
|
responseStatus == "opted_out"
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
///
|
|
78
|
-
///
|
|
79
|
-
/// Storage and data usage both have to be allowed, and only an explicit
|
|
80
|
-
/// denial refuses them.
|
|
79
|
+
/// An explicit `false` for either withholds the identifiers; `nil` (not decided)
|
|
80
|
+
/// does not.
|
|
81
81
|
static func adIdentifiersAllowed(
|
|
82
82
|
adStorageEnabled: Bool?,
|
|
83
83
|
adUserDataEnabled: Bool?
|
|
@@ -85,14 +85,9 @@ enum BridgeRules {
|
|
|
85
85
|
adStorageEnabled != false && adUserDataEnabled != false
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
///
|
|
89
|
-
///
|
|
90
|
-
///
|
|
91
|
-
/// This axis reads an absent answer as the opposite of how consent reads one:
|
|
92
|
-
/// nothing said here means sharing is allowed. So a malformed call cannot be
|
|
93
|
-
/// defaulted in either direction — `false` would record a declaration the app
|
|
94
|
-
/// never made, `true` would withhold data the user never asked to withhold,
|
|
95
|
-
/// and neither can be recalled for events already sent.
|
|
88
|
+
/// `nil` when the call carries no usable `optOut`; then nothing is forwarded.
|
|
89
|
+
/// No default is safe: `false` records a declaration the app never made, and
|
|
90
|
+
/// `true` withholds data the user never asked to withhold.
|
|
96
91
|
static func thirdPartySharingOptOut(from dictionary: [String: Any]) -> Bool? {
|
|
97
92
|
(dictionary["optOut"] as? NSNumber)?.boolValue
|
|
98
93
|
}
|