react-native-mparticle 2.7.12 → 2.8.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/SECURITY.md +9 -0
- package/android/build.gradle +65 -10
- package/android/src/main/AndroidManifestNew.xml +3 -0
- package/android/src/main/java/com/mparticle/react/MParticleModule.kt +976 -0
- package/android/src/main/java/com/mparticle/react/MParticlePackage.kt +68 -0
- package/android/src/main/java/com/mparticle/react/rokt/MPRoktModuleImpl.kt +251 -0
- package/android/src/main/java/com/mparticle/react/rokt/RoktLayoutViewManagerImpl.kt +79 -0
- package/android/src/newarch/java/com/mparticle/react/rokt/MPRoktModule.kt +130 -0
- package/android/src/newarch/java/com/mparticle/react/rokt/RoktLayoutViewManager.kt +22 -0
- package/android/src/oldarch/java/com/mparticle/react/NativeMPRoktSpec.kt +29 -0
- package/android/src/oldarch/java/com/mparticle/react/NativeMParticleSpec.kt +153 -0
- package/android/src/oldarch/java/com/mparticle/react/rokt/MPRoktModule.kt +79 -0
- package/android/src/oldarch/java/com/mparticle/react/rokt/RoktLayoutViewManager.kt +34 -0
- package/ios/RNMParticle/RNMPRokt.h +15 -0
- package/ios/RNMParticle/RNMPRokt.mm +247 -0
- package/ios/RNMParticle/RNMParticle.h +6 -1
- package/ios/RNMParticle/RNMParticle.mm +1199 -0
- package/ios/RNMParticle/RoktEventManager.h +16 -0
- package/ios/RNMParticle/RoktEventManager.m +174 -0
- package/ios/RNMParticle/RoktLayoutManager.m +22 -0
- package/ios/RNMParticle/RoktNativeLayoutComponentView.h +18 -0
- package/ios/RNMParticle/RoktNativeLayoutComponentView.mm +50 -0
- package/ios/RNMParticle.xcodeproj/project.pbxproj +29 -6
- package/js/codegenSpecs/NativeMParticle.ts +214 -0
- package/js/codegenSpecs/rokt/NativeMPRokt.ts +32 -0
- package/js/codegenSpecs/rokt/RoktLayoutNativeComponent.ts +29 -0
- package/js/index.tsx +940 -0
- package/js/rokt/rokt-layout-view.android.tsx +133 -0
- package/js/rokt/rokt-layout-view.ios.tsx +121 -0
- package/js/rokt/rokt-layout-view.tsx +15 -0
- package/js/rokt/rokt.ts +87 -0
- package/js/utils/architecture.ts +22 -0
- package/lib/codegenSpecs/NativeMParticle.d.ts +148 -0
- package/lib/codegenSpecs/NativeMParticle.js +5 -0
- package/lib/codegenSpecs/NativeMParticle.js.map +1 -0
- package/lib/codegenSpecs/rokt/NativeMPRokt.d.ts +24 -0
- package/lib/codegenSpecs/rokt/NativeMPRokt.js +5 -0
- package/lib/codegenSpecs/rokt/NativeMPRokt.js.map +1 -0
- package/lib/codegenSpecs/rokt/RoktLayoutNativeComponent.d.ts +18 -0
- package/lib/codegenSpecs/rokt/RoktLayoutNativeComponent.js +8 -0
- package/lib/codegenSpecs/rokt/RoktLayoutNativeComponent.js.map +1 -0
- package/lib/index.d.ts +410 -0
- package/lib/index.js +645 -0
- package/lib/index.js.map +1 -0
- package/lib/rokt/rokt-layout-view.android.d.ts +39 -0
- package/lib/rokt/rokt-layout-view.android.js +109 -0
- package/lib/rokt/rokt-layout-view.android.js.map +1 -0
- package/lib/rokt/rokt-layout-view.d.ts +5 -0
- package/lib/rokt/rokt-layout-view.ios.d.ts +32 -0
- package/lib/rokt/rokt-layout-view.ios.js +84 -0
- package/lib/rokt/rokt-layout-view.ios.js.map +1 -0
- package/lib/rokt/rokt-layout-view.js +12 -0
- package/lib/rokt/rokt-layout-view.js.map +1 -0
- package/lib/rokt/rokt.d.ts +40 -0
- package/lib/rokt/rokt.js +54 -0
- package/lib/rokt/rokt.js.map +1 -0
- package/lib/utils/architecture.d.ts +9 -0
- package/lib/utils/architecture.js +19 -0
- package/lib/utils/architecture.js.map +1 -0
- package/package.json +32 -10
- package/react-native-mparticle.podspec +7 -6
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -8
- package/.github/dependabot.yml +0 -12
- package/.github/workflows/daily.yml +0 -19
- package/.github/workflows/dependabot-automerge.yml +0 -12
- package/.github/workflows/pull-request.yml +0 -60
- package/.github/workflows/release.yml +0 -60
- package/.github/workflows/sonarcloud.yml +0 -16
- package/android/.classpath +0 -6
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.5.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.5.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.5.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.project +0 -34
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/.settings/org.eclipse.jdt.core.prefs +0 -4
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/android/gradle.properties +0 -53
- package/android/gradlew +0 -160
- package/android/gradlew.bat +0 -90
- package/android/libs/java-json.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module +0 -204
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom +0 -44
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml +0 -13
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar +0 -0
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar +0 -0
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module +0 -628
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom +0 -156
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml +0 -13
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.sha512 +0 -1
- package/android/src/main/java/com/mparticle/react/MParticleModule.java +0 -987
- package/android/src/main/java/com/mparticle/react/MParticlePackage.java +0 -34
- package/android/src/test/java/com/mparticle/react/IdentityApiTest.java +0 -230
- package/android/src/test/java/com/mparticle/react/MParticleUserTest.java +0 -233
- package/android/src/test/java/com/mparticle/react/testutils/MockMParticleUser.java +0 -103
- package/android/src/test/java/com/mparticle/react/testutils/MockMap.java +0 -169
- package/android/src/test/java/com/mparticle/react/testutils/MockReadableArray.java +0 -53
- package/android/src/test/java/com/mparticle/react/testutils/MockWritableMap.java +0 -4
- package/android/src/test/java/com/mparticle/react/testutils/Mutable.java +0 -13
- package/ios/RNMParticle/RNMParticle.m +0 -671
- package/ios/RNMParticle.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RNMParticle.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RNMParticle.xcodeproj/project.xcworkspace/xcuserdata/bstalnaker.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNMParticle.xcodeproj/xcuserdata/bstalnaker.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
- package/ios/RNMParticle.xcodeproj/xcuserdata/bstalnaker.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/js/index.js +0 -697
- package/release.sh +0 -6
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
package com.mparticle.react
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Callback
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.facebook.react.bridge.ReadableArray
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
|
+
|
|
9
|
+
abstract class NativeMParticleSpec(
|
|
10
|
+
reactContext: ReactApplicationContext,
|
|
11
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
12
|
+
companion object {
|
|
13
|
+
private const val MODULE_NAME = "RNMParticle"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun getName(): String = MODULE_NAME
|
|
17
|
+
|
|
18
|
+
abstract fun upload()
|
|
19
|
+
|
|
20
|
+
abstract fun setUploadInterval(uploadInterval: Double)
|
|
21
|
+
|
|
22
|
+
abstract fun logEvent(
|
|
23
|
+
eventName: String,
|
|
24
|
+
eventType: Double,
|
|
25
|
+
attributes: ReadableMap?,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
abstract fun logMPEvent(event: ReadableMap?)
|
|
29
|
+
|
|
30
|
+
abstract fun logCommerceEvent(commerceEvent: ReadableMap?)
|
|
31
|
+
|
|
32
|
+
abstract fun logScreenEvent(
|
|
33
|
+
screenName: String,
|
|
34
|
+
attributes: ReadableMap?,
|
|
35
|
+
shouldUploadEvent: Boolean,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
abstract fun setATTStatus(status: Double)
|
|
39
|
+
|
|
40
|
+
abstract fun setATTStatusWithCustomTimestamp(
|
|
41
|
+
status: Double,
|
|
42
|
+
timestamp: Double,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
abstract fun setOptOut(optOut: Boolean)
|
|
46
|
+
|
|
47
|
+
abstract fun getOptOut(callback: Callback)
|
|
48
|
+
|
|
49
|
+
abstract fun addGDPRConsentState(
|
|
50
|
+
consent: ReadableMap?,
|
|
51
|
+
purpose: String,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
abstract fun removeGDPRConsentStateWithPurpose(purpose: String)
|
|
55
|
+
|
|
56
|
+
abstract fun setCCPAConsentState(consent: ReadableMap?)
|
|
57
|
+
|
|
58
|
+
abstract fun removeCCPAConsentState()
|
|
59
|
+
|
|
60
|
+
abstract fun isKitActive(
|
|
61
|
+
kitId: Double,
|
|
62
|
+
callback: Callback,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
abstract fun getAttributions(callback: Callback)
|
|
66
|
+
|
|
67
|
+
abstract fun logPushRegistration(
|
|
68
|
+
token: String?,
|
|
69
|
+
senderId: String?,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
abstract fun getSession(callback: Callback)
|
|
73
|
+
|
|
74
|
+
abstract fun setLocation(
|
|
75
|
+
latitude: Double,
|
|
76
|
+
longitude: Double,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
abstract fun setUserAttribute(
|
|
80
|
+
mpid: String,
|
|
81
|
+
key: String,
|
|
82
|
+
value: String,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
abstract fun setUserAttributeArray(
|
|
86
|
+
mpid: String,
|
|
87
|
+
key: String,
|
|
88
|
+
value: ReadableArray?,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
abstract fun getUserAttributes(
|
|
92
|
+
mpid: String,
|
|
93
|
+
callback: Callback,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
abstract fun setUserTag(
|
|
97
|
+
mpid: String,
|
|
98
|
+
tag: String,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
abstract fun incrementUserAttribute(
|
|
102
|
+
mpid: String,
|
|
103
|
+
key: String,
|
|
104
|
+
value: Double,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
abstract fun removeUserAttribute(
|
|
108
|
+
mpid: String,
|
|
109
|
+
key: String,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
abstract fun getUserIdentities(
|
|
113
|
+
mpid: String,
|
|
114
|
+
callback: Callback,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
abstract fun getFirstSeen(
|
|
118
|
+
mpid: String,
|
|
119
|
+
callback: Callback,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
abstract fun getLastSeen(
|
|
123
|
+
mpid: String,
|
|
124
|
+
callback: Callback,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
abstract fun getCurrentUserWithCompletion(callback: Callback)
|
|
128
|
+
|
|
129
|
+
abstract fun identify(
|
|
130
|
+
identityRequest: ReadableMap?,
|
|
131
|
+
callback: Callback,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
abstract fun login(
|
|
135
|
+
identityRequest: ReadableMap?,
|
|
136
|
+
callback: Callback,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
abstract fun logout(
|
|
140
|
+
identityRequest: ReadableMap?,
|
|
141
|
+
callback: Callback,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
abstract fun modify(
|
|
145
|
+
identityRequest: ReadableMap?,
|
|
146
|
+
callback: Callback,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
abstract fun aliasUsers(
|
|
150
|
+
aliasRequest: ReadableMap?,
|
|
151
|
+
callback: Callback,
|
|
152
|
+
)
|
|
153
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
package com.mparticle.react.rokt
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactMethod
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.facebook.react.uimanager.NativeViewHierarchyManager
|
|
7
|
+
import com.facebook.react.uimanager.UIManagerModule
|
|
8
|
+
import com.mparticle.MParticle
|
|
9
|
+
import com.mparticle.internal.Logger
|
|
10
|
+
import com.mparticle.react.NativeMPRoktSpec
|
|
11
|
+
import com.mparticle.rokt.RoktEmbeddedView
|
|
12
|
+
import java.lang.ref.WeakReference
|
|
13
|
+
|
|
14
|
+
class MPRoktModule(
|
|
15
|
+
private val reactContext: ReactApplicationContext,
|
|
16
|
+
) : NativeMPRoktSpec(reactContext) {
|
|
17
|
+
private val impl = MPRoktModuleImpl(reactContext)
|
|
18
|
+
|
|
19
|
+
override fun getName(): String = impl.getName()
|
|
20
|
+
|
|
21
|
+
@ReactMethod
|
|
22
|
+
override fun selectPlacements(
|
|
23
|
+
identifier: String,
|
|
24
|
+
attributes: ReadableMap?,
|
|
25
|
+
placeholders: ReadableMap?,
|
|
26
|
+
roktConfig: ReadableMap?,
|
|
27
|
+
fontFilesMap: ReadableMap?,
|
|
28
|
+
) {
|
|
29
|
+
if (identifier.isBlank()) {
|
|
30
|
+
Logger.warning("selectPlacements failed. identifier cannot be empty")
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
val uiManager = reactContext.getNativeModule(UIManagerModule::class.java)
|
|
34
|
+
MParticle.getInstance()?.Rokt()?.events(identifier)?.let {
|
|
35
|
+
impl.startRoktEventListener(it, reactContext.currentActivity, identifier)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
val config = roktConfig?.let { impl.buildRoktConfig(it) }
|
|
39
|
+
uiManager?.addUIBlock { nativeViewHierarchyManager ->
|
|
40
|
+
MParticle.getInstance()?.Rokt()?.selectPlacements(
|
|
41
|
+
identifier = identifier,
|
|
42
|
+
attributes = impl.readableMapToMapOfStrings(attributes),
|
|
43
|
+
callbacks = impl.createRoktCallback(),
|
|
44
|
+
embeddedViews = safeUnwrapPlaceholders(placeholders, nativeViewHierarchyManager),
|
|
45
|
+
fontTypefaces = null, // TODO
|
|
46
|
+
config = config,
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@ReactMethod
|
|
52
|
+
override fun purchaseFinalized(
|
|
53
|
+
placementId: String,
|
|
54
|
+
catalogItemId: String,
|
|
55
|
+
success: Boolean,
|
|
56
|
+
) {
|
|
57
|
+
impl.purchaseFinalized(placementId, catalogItemId, success)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private fun safeUnwrapPlaceholders(
|
|
61
|
+
placeholders: ReadableMap?,
|
|
62
|
+
nativeViewHierarchyManager: NativeViewHierarchyManager,
|
|
63
|
+
): Map<String, WeakReference<RoktEmbeddedView>> {
|
|
64
|
+
val placeholderMap: MutableMap<String, WeakReference<RoktEmbeddedView>> = HashMap()
|
|
65
|
+
|
|
66
|
+
if (placeholders != null) {
|
|
67
|
+
placeholderMap.putAll(
|
|
68
|
+
placeholders
|
|
69
|
+
.toHashMap()
|
|
70
|
+
.filterValues { value -> value is Double }
|
|
71
|
+
.mapValues { pair -> (pair.value as Double).toInt() }
|
|
72
|
+
.mapValues { pair -> nativeViewHierarchyManager.resolveView(pair.value) as? RoktEmbeddedView }
|
|
73
|
+
.filterValues { value -> value != null }
|
|
74
|
+
.mapValues { WeakReference(it.value as RoktEmbeddedView) },
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
return placeholderMap
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package com.mparticle.react.rokt
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.common.MapBuilder
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
6
|
+
import com.mparticle.rokt.RoktEmbeddedView
|
|
7
|
+
|
|
8
|
+
class RoktLayoutViewManager : ViewGroupManager<RoktEmbeddedView>() {
|
|
9
|
+
private val impl = RoktLayoutViewManagerImpl()
|
|
10
|
+
|
|
11
|
+
override fun getName(): String = impl.getName()
|
|
12
|
+
|
|
13
|
+
override fun createViewInstance(reactContext: ThemedReactContext): RoktEmbeddedView = impl.createViewInstance(reactContext)
|
|
14
|
+
|
|
15
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any>? =
|
|
16
|
+
MapBuilder
|
|
17
|
+
.builder<String, Any>()
|
|
18
|
+
.put(
|
|
19
|
+
RoktLayoutViewManagerImpl.EVENT_HEIGHT_CHANGED,
|
|
20
|
+
MapBuilder.of("registrationName", RoktLayoutViewManagerImpl.EVENT_HEIGHT_CHANGED),
|
|
21
|
+
).put(
|
|
22
|
+
RoktLayoutViewManagerImpl.EVENT_MARGIN_CHANGED,
|
|
23
|
+
MapBuilder.of("registrationName", RoktLayoutViewManagerImpl.EVENT_MARGIN_CHANGED),
|
|
24
|
+
).build()
|
|
25
|
+
|
|
26
|
+
override fun needsCustomLayoutForChildren(): Boolean = false
|
|
27
|
+
|
|
28
|
+
fun setPlaceholderName(
|
|
29
|
+
view: RoktEmbeddedView?,
|
|
30
|
+
value: String?,
|
|
31
|
+
) {
|
|
32
|
+
impl.setPlaceholderName(view, value)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
+
#import <RNMParticle/RNMParticle.h>
|
|
5
|
+
#import <React/RCTBridge.h>
|
|
6
|
+
|
|
7
|
+
@interface RNMPRokt : NSObject<NativeMPRoktSpec>
|
|
8
|
+
@property (nonatomic, weak, nullable) RCTBridge *bridge;
|
|
9
|
+
#else
|
|
10
|
+
|
|
11
|
+
#import <React/RCTBridgeModule.h>
|
|
12
|
+
@interface RNMPRokt : NSObject <RCTBridgeModule>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
@end
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#import "RNMPRokt.h"
|
|
2
|
+
#if defined(__has_include) && __has_include(<mParticle_Apple_SDK/mParticle.h>)
|
|
3
|
+
#import <mParticle_Apple_SDK/mParticle.h>
|
|
4
|
+
#import <mParticle_Apple_SDK/MPRokt.h>
|
|
5
|
+
#elif defined(__has_include) && __has_include(<mParticle_Apple_SDK_NoLocation/mParticle.h>)
|
|
6
|
+
#import <mParticle_Apple_SDK_NoLocation/mParticle.h>
|
|
7
|
+
#else
|
|
8
|
+
#import <mParticle_Apple_SDK/Include/mParticle.h>
|
|
9
|
+
#endif
|
|
10
|
+
#if defined(__has_include) && __has_include(<mParticle_Apple_SDK/mParticle_Apple_SDK-Swift.h>)
|
|
11
|
+
#import <mParticle_Apple_SDK/mParticle_Apple_SDK-Swift.h>
|
|
12
|
+
#elif defined(__has_include) && __has_include(<mParticle_Apple_SDK_NoLocation/mParticle_Apple_SDK-Swift.h>)
|
|
13
|
+
#import <mParticle_Apple_SDK_NoLocation/mParticle_Apple_SDK-Swift.h>
|
|
14
|
+
#else
|
|
15
|
+
#import "mParticle_Apple_SDK-Swift.h"
|
|
16
|
+
#endif
|
|
17
|
+
#import <React/RCTConvert.h>
|
|
18
|
+
#import <React/RCTEventEmitter.h>
|
|
19
|
+
#import <React/RCTViewManager.h>
|
|
20
|
+
#import <React/RCTUIManager.h>
|
|
21
|
+
#import <React/RCTBridge.h>
|
|
22
|
+
#import "RoktEventManager.h"
|
|
23
|
+
|
|
24
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
25
|
+
#import "RoktNativeLayoutComponentView.h"
|
|
26
|
+
#import <RNMParticle/RNMParticle.h>
|
|
27
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
28
|
+
|
|
29
|
+
@interface RNMPRokt ()
|
|
30
|
+
|
|
31
|
+
@property (nonatomic, nullable) RoktEventManager *eventManager;
|
|
32
|
+
|
|
33
|
+
@end
|
|
34
|
+
|
|
35
|
+
@implementation RNMPRokt
|
|
36
|
+
|
|
37
|
+
@synthesize bridge = _bridge;
|
|
38
|
+
|
|
39
|
+
RCT_EXTERN void RCTRegisterModule(Class);
|
|
40
|
+
|
|
41
|
+
+ (NSString *)moduleName {
|
|
42
|
+
return @"RNMPRokt";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
+ (void)load {
|
|
46
|
+
RCTRegisterModule(self);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (dispatch_queue_t)methodQueue
|
|
50
|
+
{
|
|
51
|
+
return self.bridge.uiManager.methodQueue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (void)setMethodQueue:(dispatch_queue_t)methodQueue
|
|
55
|
+
{
|
|
56
|
+
// No-op setter to satisfy TurboModule requirements
|
|
57
|
+
// We always return the UI manager's method queue
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
61
|
+
// New Architecture Implementation
|
|
62
|
+
- (void)selectPlacements:(NSString *)identifer
|
|
63
|
+
attributes:(NSDictionary *)attributes
|
|
64
|
+
placeholders:(NSDictionary *)placeholders
|
|
65
|
+
roktConfig:(JS::NativeMPRokt::RoktConfigType &)roktConfig
|
|
66
|
+
fontFilesMap:(NSDictionary *)fontFilesMap
|
|
67
|
+
{
|
|
68
|
+
NSMutableDictionary *finalAttributes = [self convertToMutableDictionaryOfStrings:attributes];
|
|
69
|
+
|
|
70
|
+
// Convert JS struct to NSDictionary for internal use
|
|
71
|
+
NSMutableDictionary *roktConfigDict = [[NSMutableDictionary alloc] init];
|
|
72
|
+
if (&roktConfig != nullptr && roktConfig.cacheConfig().has_value()) {
|
|
73
|
+
NSMutableDictionary *cacheConfigDict = [[NSMutableDictionary alloc] init];
|
|
74
|
+
auto cacheConfig = roktConfig.cacheConfig().value();
|
|
75
|
+
if (cacheConfig.cacheDurationInSeconds().has_value()) {
|
|
76
|
+
cacheConfigDict[@"cacheDurationInSeconds"] = @(cacheConfig.cacheDurationInSeconds().value());
|
|
77
|
+
}
|
|
78
|
+
if (cacheConfig.cacheAttributes()) {
|
|
79
|
+
cacheConfigDict[@"cacheAttributes"] = cacheConfig.cacheAttributes();
|
|
80
|
+
}
|
|
81
|
+
roktConfigDict[@"cacheConfig"] = cacheConfigDict;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
MPRoktConfig *config = [self buildRoktConfigFromDict:roktConfigDict];
|
|
85
|
+
#else
|
|
86
|
+
// Old Architecture Implementation
|
|
87
|
+
RCT_EXPORT_METHOD(selectPlacements:(NSString *) identifer attributes:(NSDictionary *)attributes placeholders:(NSDictionary * _Nullable)placeholders roktConfig:(NSDictionary * _Nullable)roktConfig fontFilesMap:(NSDictionary * _Nullable)fontFilesMap)
|
|
88
|
+
{
|
|
89
|
+
NSMutableDictionary *finalAttributes = [self convertToMutableDictionaryOfStrings:attributes];
|
|
90
|
+
MPRoktConfig *config = [self buildRoktConfigFromDict:roktConfig];
|
|
91
|
+
#endif
|
|
92
|
+
|
|
93
|
+
[MParticle _setWrapperSdk_internal:MPWrapperSdkReactNative version:@""];
|
|
94
|
+
// Create callback implementation
|
|
95
|
+
MPRoktEventCallback *callbacks = [[MPRoktEventCallback alloc] init];
|
|
96
|
+
|
|
97
|
+
__weak __typeof__(self) weakSelf = self;
|
|
98
|
+
|
|
99
|
+
callbacks.onLoad = ^{
|
|
100
|
+
[self.eventManager onRoktCallbackReceived:@"onLoad"];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
callbacks.onUnLoad = ^{
|
|
104
|
+
[self.eventManager onRoktCallbackReceived:@"onUnLoad"];
|
|
105
|
+
RCTLogInfo(@"unloaded");
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
callbacks.onShouldShowLoadingIndicator = ^{
|
|
109
|
+
[self.eventManager onRoktCallbackReceived:@"onShouldShowLoadingIndicator"];
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
callbacks.onShouldHideLoadingIndicator = ^{
|
|
113
|
+
[self.eventManager onRoktCallbackReceived:@"onShouldHideLoadingIndicator"];
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
callbacks.onEmbeddedSizeChange = ^(NSString *placementId, CGFloat height) {
|
|
117
|
+
[self.eventManager onWidgetHeightChanges:height placement:placementId];
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
121
|
+
NSMutableDictionary *nativePlaceholders = [self getNativePlaceholders:placeholders viewRegistry:viewRegistry];
|
|
122
|
+
|
|
123
|
+
[self subscribeViewEvents:identifer];
|
|
124
|
+
|
|
125
|
+
[[[MParticle sharedInstance] rokt] selectPlacements:identifer
|
|
126
|
+
attributes:finalAttributes
|
|
127
|
+
embeddedViews:nativePlaceholders
|
|
128
|
+
config:config
|
|
129
|
+
callbacks:callbacks];
|
|
130
|
+
}];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
RCT_EXPORT_METHOD(purchaseFinalized : (NSString *)placementId catalogItemId : (
|
|
134
|
+
NSString *)catalogItemId success : (BOOL)success) {
|
|
135
|
+
[[[MParticle sharedInstance] rokt] purchaseFinalized:placementId
|
|
136
|
+
catalogItemId:catalogItemId
|
|
137
|
+
success:success];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
- (NSMutableDictionary*)convertToMutableDictionaryOfStrings:(NSDictionary*)attributes
|
|
141
|
+
{
|
|
142
|
+
NSMutableDictionary *finalAttributes = [attributes mutableCopy];
|
|
143
|
+
NSArray *keysForNullValues = [finalAttributes allKeysForObject:[NSNull null]];
|
|
144
|
+
[finalAttributes removeObjectsForKeys:keysForNullValues];
|
|
145
|
+
|
|
146
|
+
NSSet *keys = [finalAttributes keysOfEntriesPassingTest:^BOOL(id key, id obj, BOOL *stop) {
|
|
147
|
+
return ![obj isKindOfClass:[NSString class]];
|
|
148
|
+
}];
|
|
149
|
+
|
|
150
|
+
[finalAttributes removeObjectsForKeys:[keys allObjects]];
|
|
151
|
+
return finalAttributes;
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (MPColorMode)stringToColorMode:(NSString*)colorString
|
|
156
|
+
{
|
|
157
|
+
if ([colorString isEqualToString:@"light"]) {
|
|
158
|
+
return MPColorModeLight;
|
|
159
|
+
}
|
|
160
|
+
else if ([colorString isEqualToString:@"dark"]) {
|
|
161
|
+
return MPColorModeDark;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return MPColorModeSystem;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (MPRoktConfig *)buildRoktConfigFromDict:(NSDictionary<NSString *, id> *)configMap {
|
|
169
|
+
MPRoktConfig *config = [[MPRoktConfig alloc] init];
|
|
170
|
+
BOOL isConfigEmpty = YES;
|
|
171
|
+
|
|
172
|
+
NSString *colorModeString = configMap[@"colorMode"];
|
|
173
|
+
if (colorModeString && [colorModeString isKindOfClass:[NSString class]]) {
|
|
174
|
+
if (@available(iOS 12.0, *)) {
|
|
175
|
+
isConfigEmpty = NO;
|
|
176
|
+
if ([colorModeString isEqualToString:@"dark"]) {
|
|
177
|
+
if (@available(iOS 13.0, *)) {
|
|
178
|
+
config.colorMode = MPColorModeDark;
|
|
179
|
+
}
|
|
180
|
+
} else if ([colorModeString isEqualToString:@"light"]) {
|
|
181
|
+
config.colorMode = MPColorModeLight;
|
|
182
|
+
} else {
|
|
183
|
+
// default: "system"
|
|
184
|
+
config.colorMode = MPColorModeSystem;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
NSDictionary *cacheConfigMap = configMap[@"cacheConfig"];
|
|
190
|
+
if (cacheConfigMap && [cacheConfigMap isKindOfClass:[NSDictionary class]]) {
|
|
191
|
+
isConfigEmpty = NO;
|
|
192
|
+
NSNumber *cacheDuration = cacheConfigMap[@"cacheDurationInSeconds"];
|
|
193
|
+
if (!cacheDuration) {
|
|
194
|
+
cacheDuration = @0;
|
|
195
|
+
}
|
|
196
|
+
NSDictionary<NSString *, NSString *> *cacheAttributes = cacheConfigMap[@"cacheAttributes"];
|
|
197
|
+
config.cacheAttributes = cacheAttributes;
|
|
198
|
+
config.cacheDuration = cacheDuration;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return isConfigEmpty ? nil : config;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
- (void)subscribeViewEvents:(NSString* _Nonnull) viewName
|
|
205
|
+
{
|
|
206
|
+
if (self.eventManager == nil) {
|
|
207
|
+
self.eventManager = [RoktEventManager allocWithZone: nil];
|
|
208
|
+
}
|
|
209
|
+
[[[MParticle sharedInstance] rokt] events:viewName onEvent:^(MPRoktEvent * _Nonnull roktEvent) {
|
|
210
|
+
[self.eventManager onRoktEvents:roktEvent viewName:viewName];
|
|
211
|
+
}];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
- (NSMutableDictionary *)getNativePlaceholders:(NSDictionary *)placeholders viewRegistry:(NSDictionary<NSNumber *, UIView *> *)viewRegistry
|
|
215
|
+
{
|
|
216
|
+
NSMutableDictionary *nativePlaceholders = [[NSMutableDictionary alloc]initWithCapacity:placeholders.count];
|
|
217
|
+
|
|
218
|
+
for(id key in placeholders){
|
|
219
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
220
|
+
RoktNativeLayoutComponentView *wrapperView = (RoktNativeLayoutComponentView *)viewRegistry[[placeholders objectForKey:key]];
|
|
221
|
+
if (!wrapperView || ![wrapperView isKindOfClass:[RoktNativeLayoutComponentView class]]) {
|
|
222
|
+
RCTLogError(@"Cannot find RoktNativeWidgetComponentView with tag #%@", key);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
nativePlaceholders[key] = wrapperView.roktEmbeddedView;
|
|
226
|
+
#else
|
|
227
|
+
MPRoktEmbeddedView *view = viewRegistry[[placeholders objectForKey:key]];
|
|
228
|
+
if (!view || ![view isKindOfClass:[MPRoktEmbeddedView class]]) {
|
|
229
|
+
RCTLogError(@"Cannot find RoktEmbeddedView with tag #%@", key);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
nativePlaceholders[key] = view;
|
|
234
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return nativePlaceholders;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
241
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
242
|
+
self.bridge = params.instance.bridge;
|
|
243
|
+
return std::make_shared<facebook::react::NativeMPRoktSpecJSI>(params);
|
|
244
|
+
}
|
|
245
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
246
|
+
|
|
247
|
+
@end
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
|
-
#import <React/RCTBridge.h>
|
|
3
2
|
|
|
3
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
+
#import <RNMParticle/RNMParticle.h>
|
|
5
|
+
@interface RNMParticle : NSObject <NativeMParticleSpec>
|
|
6
|
+
#else
|
|
7
|
+
#import <React/RCTBridgeModule.h>
|
|
4
8
|
@interface RNMParticle : NSObject <RCTBridgeModule>
|
|
9
|
+
#endif
|
|
5
10
|
|
|
6
11
|
@end
|