gomarketme-react-native 4.0.0 → 5.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/LICENSE +21 -0
- package/README.md +89 -51
- package/android/build.gradle +46 -0
- package/android/libs/core-5.0.0.jar +0 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/co/gomarketme/reactnative/GoMarketMeReactNativeModule.kt +184 -0
- package/android/src/main/java/co/gomarketme/reactnative/GoMarketMeReactNativePackage.kt +16 -0
- package/gomarketme-react-native.podspec +18 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/Info.plist +44 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64/GoMarketMeAppleCoreKit.framework/GoMarketMeAppleCoreKit +0 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64/GoMarketMeAppleCoreKit.framework/Info.plist +0 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios.abi.json +2932 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios.package.swiftinterface +86 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios.private.swiftinterface +86 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios.swiftinterface +86 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/GoMarketMeAppleCoreKit +0 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Info.plist +0 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios-simulator.abi.json +2932 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios-simulator.package.swiftinterface +86 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +86 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +86 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +2932 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/x86_64-apple-ios-simulator.package.swiftinterface +86 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +86 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/Modules/GoMarketMeAppleCoreKit.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +86 -0
- package/ios/Frameworks/GoMarketMeAppleCoreKit.xcframework/ios-arm64_x86_64-simulator/GoMarketMeAppleCoreKit.framework/_CodeSignature/CodeResources +101 -0
- package/ios/GoMarketMeReactNative.swift +133 -0
- package/ios/GoMarketMeReactNativeBridge.m +17 -0
- package/{dist → lib}/index.d.ts +27 -30
- package/lib/index.js +172 -0
- package/package.json +41 -18
- package/react-native.config.js +12 -0
- package/.editorconfig +0 -15
- package/.gitattributes +0 -3
- package/.github/actions/setup/action.yml +0 -27
- package/.github/workflows/ci.yml +0 -157
- package/.nvmrc +0 -1
- package/.watchmanconfig +0 -1
- package/.yarn/releases/yarn-4.3.1-git.20240705.hash-35167b2.cjs +0 -894
- package/.yarnrc.yml +0 -5
- package/dist/index.js +0 -544
- package/lefthook.yml +0 -35
- package/src/index.tsx +0 -392
- package/tsconfig.json +0 -19
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) GoMarketMe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,96 +1,134 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<img src="https://static.gomarketme.net/assets/gmm-icon.png" alt="GoMarketMe" />
|
|
3
|
+
<br />
|
|
4
|
+
<h1>GoMarketMe React Native SDK</h1>
|
|
5
|
+
<p>Affiliate marketing for React Native apps on iOS and Android.</p>
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
10
|
-
###
|
|
10
|
+
### npm
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npm install gomarketme-react-native@
|
|
13
|
+
npm install gomarketme-react-native@5.0.0
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
###
|
|
16
|
+
### Yarn
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
yarn add gomarketme-react-native@
|
|
19
|
+
yarn add gomarketme-react-native@5.0.0
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
###
|
|
22
|
+
### pnpm
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
pnpm add gomarketme-react-native@
|
|
26
|
-
```
|
|
27
|
-
##
|
|
28
|
-
|
|
29
|
-
GoMarketMe is built on top of react-native-iap, so you may also need to install the following packages:
|
|
30
|
-
```bash
|
|
31
|
-
npm install react-native-iap react-native-nitro-modules
|
|
32
|
-
(or yarn add react-native-iap react-native-nitro-modules)
|
|
33
|
-
(or pnpm add react-native-iap react-native-nitro-modules)
|
|
25
|
+
pnpm add gomarketme-react-native@5.0.0
|
|
34
26
|
```
|
|
35
27
|
|
|
36
28
|
## Usage
|
|
37
29
|
|
|
38
|
-
|
|
30
|
+
GoMarketMe takes only a few lines to set up.
|
|
39
31
|
|
|
40
|
-
|
|
32
|
+
### Step 1/3: Initialize
|
|
33
|
+
|
|
34
|
+
Import `gomarketme-react-native` and initialize the SDK with your GoMarketMe API key.
|
|
41
35
|
|
|
42
36
|
```tsx
|
|
37
|
+
import { useEffect } from 'react';
|
|
43
38
|
import GoMarketMe from 'gomarketme-react-native';
|
|
44
39
|
|
|
45
40
|
useEffect(() => {
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
const initializeGoMarketMe = async () => {
|
|
42
|
+
await GoMarketMe.initialize('API_KEY');
|
|
43
|
+
};
|
|
48
44
|
|
|
45
|
+
initializeGoMarketMe();
|
|
49
46
|
}, []);
|
|
50
47
|
```
|
|
51
48
|
|
|
52
|
-
|
|
49
|
+
Replace `API_KEY` with your actual GoMarketMe API key. You can find it on the product onboarding page and under **Profile > API Key**.
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
### Step 2/3: Sync after purchase
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
- Affiliate-aware paywalls: Offer exclusive pricing or promotions to users acquired through affiliate campaigns.
|
|
58
|
-
- Personalized onboarding: For example, a social or fitness app can automatically make new users follow the influencer who referred them, strengthening engagement and maximizing the affiliate’s impact.
|
|
53
|
+
After your app completes a purchase through `react-native-iap`, `expo-iap`, RevenueCat, Adapty, or another in-app purchase provider, call:
|
|
59
54
|
|
|
60
55
|
```tsx
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
await GoMarketMe.syncAllTransactions();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If your purchase library lets you decide when to finish, acknowledge, consume, or complete the transaction, call `syncAllTransactions()` first.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
purchaseUpdateSub = purchaseUpdatedListener(async purchase => {
|
|
63
|
+
await GoMarketMe.syncAllTransactions();
|
|
64
|
+
|
|
65
|
+
await finishTransaction({ purchase, isConsumable: true });
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Step 3/3: iOS consumables only
|
|
70
|
+
|
|
71
|
+
If your iOS app sells consumable in-app purchases, add this key to your app's `Info.plist`:
|
|
72
|
+
|
|
73
|
+
```xml
|
|
74
|
+
<key>SKIncludeConsumableInAppPurchaseHistory</key>
|
|
75
|
+
<true/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
That's it. GoMarketMe automatically attributes and reports affiliate sales.
|
|
79
|
+
|
|
80
|
+
## Alternative Step 1: Advanced integration
|
|
81
|
+
|
|
82
|
+
For advanced use cases, you can also read GoMarketMe affiliate marketing data after initialization. This is useful for Programmatic Affiliate Marketing, such as affiliate-aware paywalls, personalized onboarding, promotions, or custom in-app experiences.
|
|
83
|
+
|
|
84
|
+
Common use cases include:
|
|
85
|
+
|
|
86
|
+
- Affiliate-aware paywalls and promotions.
|
|
87
|
+
- Personalized onboarding.
|
|
88
|
+
- Automatically connecting new users with the influencer who referred them.
|
|
89
|
+
|
|
90
|
+
Learn more about [Programmatic Affiliate Marketing](https://gomarketme.co/programmatic-affiliate-marketing/).
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { useEffect, useState } from 'react';
|
|
94
|
+
import GoMarketMe, {
|
|
95
|
+
GoMarketMeAffiliateMarketingData,
|
|
96
|
+
} from 'gomarketme-react-native';
|
|
97
|
+
|
|
98
|
+
const [affiliateData, setAffiliateData] =
|
|
99
|
+
useState<GoMarketMeAffiliateMarketingData | null>(null);
|
|
65
100
|
|
|
66
101
|
useEffect(() => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
console.log('Affiliate ID:', data.affiliate?.id); // maps to GoMarketMe > Affiliates > Export > id column
|
|
76
|
-
console.log('Affiliate %:', data.saleDistribution?.affiliatePercentage); // maps to GoMarketMe > Campaigns > [Name] > Affiliate's Revenue Split (%)
|
|
77
|
-
console.log('Campaign ID:', data.campaign?.id); // maps to GoMarketMe > Campaigns > [Name] > id in the URL
|
|
78
|
-
|
|
79
|
-
setAffiliateData(data);
|
|
102
|
+
const initializeGoMarketMe = async () => {
|
|
103
|
+
await GoMarketMe.initialize('API_KEY');
|
|
104
|
+
|
|
105
|
+
const data = GoMarketMe.affiliateMarketingData;
|
|
106
|
+
|
|
107
|
+
if (!data) {
|
|
108
|
+
return;
|
|
80
109
|
}
|
|
81
110
|
|
|
111
|
+
// Maps to GoMarketMe > Affiliates > Export > id column.
|
|
112
|
+
console.log('Affiliate ID:', data.affiliate?.id);
|
|
113
|
+
|
|
114
|
+
// Maps to GoMarketMe > Campaigns > [Name] > Affiliate's Revenue Split (%).
|
|
115
|
+
console.log('Affiliate %:', data.saleDistribution?.affiliatePercentage);
|
|
116
|
+
|
|
117
|
+
// Maps to GoMarketMe > Campaigns > [Name] > id in the URL.
|
|
118
|
+
console.log('Campaign ID:', data.campaign?.id);
|
|
119
|
+
|
|
120
|
+
// Use this data to customize onboarding, paywalls, promotions, or in-app experiences.
|
|
121
|
+
setAffiliateData(data);
|
|
82
122
|
};
|
|
83
123
|
|
|
84
|
-
|
|
124
|
+
initializeGoMarketMe();
|
|
85
125
|
}, []);
|
|
86
126
|
```
|
|
87
127
|
|
|
88
|
-
Make sure to replace `API_KEY` with your actual GoMarketMe API key. You can find it on the product onboarding page and under **Profile > API Key**.
|
|
89
|
-
|
|
90
|
-
For Expo, go to [https://www.npmjs.com/package/gomarketme-react-native-expo](https://www.npmjs.com/package/gomarketme-react-native-expo).
|
|
91
|
-
|
|
92
128
|
## Support
|
|
93
129
|
|
|
94
|
-
Check out
|
|
130
|
+
Check out the sample React Native app:
|
|
131
|
+
|
|
132
|
+
[https://github.com/GoMarketMe/gomarketme-react-native-sample-app](https://github.com/GoMarketMe/gomarketme-react-native-sample-app)
|
|
95
133
|
|
|
96
|
-
|
|
134
|
+
For integration support, contact [integrations@gomarketme.co](mailto:integrations@gomarketme.co) or visit [https://gomarketme.co](https://gomarketme.co).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.kotlin_version = '2.1.0'
|
|
3
|
+
|
|
4
|
+
repositories {
|
|
5
|
+
google()
|
|
6
|
+
mavenCentral()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
dependencies {
|
|
10
|
+
classpath 'com.android.tools.build:gradle:8.7.3'
|
|
11
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
apply plugin: 'com.android.library'
|
|
16
|
+
apply plugin: 'org.jetbrains.kotlin.android'
|
|
17
|
+
|
|
18
|
+
android {
|
|
19
|
+
namespace 'co.gomarketme.reactnative'
|
|
20
|
+
compileSdk 35
|
|
21
|
+
|
|
22
|
+
defaultConfig {
|
|
23
|
+
minSdk 23
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
compileOptions {
|
|
27
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
28
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
kotlinOptions {
|
|
32
|
+
jvmTarget = '17'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
repositories {
|
|
37
|
+
google()
|
|
38
|
+
mavenCentral()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
dependencies {
|
|
42
|
+
implementation files('libs/core-5.0.0.jar')
|
|
43
|
+
implementation 'com.android.billingclient:billing:8.3.0'
|
|
44
|
+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0'
|
|
45
|
+
compileOnly 'com.facebook.react:react-android:+'
|
|
46
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
package co.gomarketme.reactnative
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import co.gomarketme.core.GoMarketMeGoogleCore
|
|
5
|
+
import co.gomarketme.core.GoMarketMeGoogleCoreConfiguration
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
7
|
+
import com.facebook.react.bridge.Promise
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
10
|
+
import com.facebook.react.bridge.ReactMethod
|
|
11
|
+
import com.facebook.react.bridge.WritableArray
|
|
12
|
+
import com.facebook.react.bridge.WritableMap
|
|
13
|
+
import kotlinx.coroutines.CoroutineScope
|
|
14
|
+
import kotlinx.coroutines.Dispatchers
|
|
15
|
+
import kotlinx.coroutines.SupervisorJob
|
|
16
|
+
import kotlinx.coroutines.launch
|
|
17
|
+
|
|
18
|
+
class GoMarketMeReactNativeModule(
|
|
19
|
+
private val reactContext: ReactApplicationContext
|
|
20
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
21
|
+
private var core: GoMarketMeGoogleCore? = null
|
|
22
|
+
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
|
|
23
|
+
|
|
24
|
+
override fun getName(): String = MODULE_NAME
|
|
25
|
+
|
|
26
|
+
@ReactMethod
|
|
27
|
+
fun initialize(
|
|
28
|
+
apiKey: String,
|
|
29
|
+
sdkType: String,
|
|
30
|
+
sdkVersion: String,
|
|
31
|
+
isProduction: Boolean,
|
|
32
|
+
promise: Promise
|
|
33
|
+
) {
|
|
34
|
+
val trimmedApiKey = apiKey.trim()
|
|
35
|
+
|
|
36
|
+
if (trimmedApiKey.isEmpty()) {
|
|
37
|
+
promise.reject("invalid_arguments", "apiKey is required")
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
val initialConfiguration = GoMarketMeGoogleCoreConfiguration(
|
|
42
|
+
apiKey = trimmedApiKey,
|
|
43
|
+
sdkType = sdkType.ifBlank { "ReactNative" },
|
|
44
|
+
sdkVersion = sdkVersion.takeIf { it.isNotBlank() },
|
|
45
|
+
isProduction = isProduction
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
val googleCore = core ?: GoMarketMeGoogleCore(reactContext.applicationContext)
|
|
49
|
+
|
|
50
|
+
if (IS_DEBUG_LOGGING_ENABLED) {
|
|
51
|
+
googleCore.onPurchase = { event ->
|
|
52
|
+
Log.d(TAG, "purchase observed by core: ${event.toMap()}")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
googleCore.onError = { throwable ->
|
|
56
|
+
Log.e(TAG, "core error", throwable)
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
googleCore.onPurchase = null
|
|
60
|
+
googleCore.onError = null
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
scope.launch {
|
|
64
|
+
try {
|
|
65
|
+
val prepared = googleCore.prepareAttribution(initialConfiguration)
|
|
66
|
+
val config = prepared.first
|
|
67
|
+
val affiliateMarketingData = prepared.second
|
|
68
|
+
|
|
69
|
+
googleCore.configure(config)
|
|
70
|
+
googleCore.start()
|
|
71
|
+
core = googleCore
|
|
72
|
+
|
|
73
|
+
val response = Arguments.createMap().apply {
|
|
74
|
+
putBoolean("initialized", true)
|
|
75
|
+
putString("platform", "android")
|
|
76
|
+
putString("source", config.sourceName)
|
|
77
|
+
putMap("affiliateMarketingData", affiliateMarketingData.toWritableMap())
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
promise.resolve(response)
|
|
81
|
+
} catch (throwable: Throwable) {
|
|
82
|
+
promise.reject("initialize_failed", throwable.message, throwable)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@ReactMethod
|
|
88
|
+
fun syncAllTransactions(promise: Promise) {
|
|
89
|
+
val googleCore = core
|
|
90
|
+
|
|
91
|
+
if (googleCore == null) {
|
|
92
|
+
promise.reject("not_initialized", "GoMarketMe SDK must be initialized before syncing transactions")
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
scope.launch {
|
|
97
|
+
try {
|
|
98
|
+
val result = googleCore.sendCurrentPurchasesWithResult()
|
|
99
|
+
|
|
100
|
+
val response = Arguments.createMap().apply {
|
|
101
|
+
putInt("fetchedCount", result.fetchedCount)
|
|
102
|
+
putInt("sentCount", result.sentCount)
|
|
103
|
+
putInt("failedCount", result.failedCount)
|
|
104
|
+
putBoolean("success", result.success)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
promise.resolve(response)
|
|
108
|
+
} catch (throwable: Throwable) {
|
|
109
|
+
promise.reject("sync_all_transactions_failed", throwable.message, throwable)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@ReactMethod
|
|
115
|
+
fun stop() {
|
|
116
|
+
core?.stop()
|
|
117
|
+
core = null
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
override fun invalidate() {
|
|
121
|
+
stop()
|
|
122
|
+
super.invalidate()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private fun Map<String, Any?>.toWritableMap(): WritableMap {
|
|
126
|
+
val writableMap = Arguments.createMap()
|
|
127
|
+
|
|
128
|
+
forEach { (key, value) ->
|
|
129
|
+
writableMap.putAny(key, value)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return writableMap
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private fun WritableMap.putAny(key: String, value: Any?) {
|
|
136
|
+
when (value) {
|
|
137
|
+
null -> putNull(key)
|
|
138
|
+
is Boolean -> putBoolean(key, value)
|
|
139
|
+
is Int -> putInt(key, value)
|
|
140
|
+
is Long -> putDouble(key, value.toDouble())
|
|
141
|
+
is Float -> putDouble(key, value.toDouble())
|
|
142
|
+
is Double -> putDouble(key, value)
|
|
143
|
+
is Number -> putDouble(key, value.toDouble())
|
|
144
|
+
is String -> putString(key, value)
|
|
145
|
+
is Map<*, *> -> putMap(key, value.toStringKeyMap().toWritableMap())
|
|
146
|
+
is Iterable<*> -> putArray(key, value.toWritableArray())
|
|
147
|
+
is Array<*> -> putArray(key, value.asIterable().toWritableArray())
|
|
148
|
+
else -> putString(key, value.toString())
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private fun Iterable<*>.toWritableArray(): WritableArray {
|
|
153
|
+
val writableArray = Arguments.createArray()
|
|
154
|
+
|
|
155
|
+
forEach { value ->
|
|
156
|
+
when (value) {
|
|
157
|
+
null -> writableArray.pushNull()
|
|
158
|
+
is Boolean -> writableArray.pushBoolean(value)
|
|
159
|
+
is Int -> writableArray.pushInt(value)
|
|
160
|
+
is Long -> writableArray.pushDouble(value.toDouble())
|
|
161
|
+
is Float -> writableArray.pushDouble(value.toDouble())
|
|
162
|
+
is Double -> writableArray.pushDouble(value)
|
|
163
|
+
is Number -> writableArray.pushDouble(value.toDouble())
|
|
164
|
+
is String -> writableArray.pushString(value)
|
|
165
|
+
is Map<*, *> -> writableArray.pushMap(value.toStringKeyMap().toWritableMap())
|
|
166
|
+
is Iterable<*> -> writableArray.pushArray(value.toWritableArray())
|
|
167
|
+
is Array<*> -> writableArray.pushArray(value.asIterable().toWritableArray())
|
|
168
|
+
else -> writableArray.pushString(value.toString())
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return writableArray
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private fun Map<*, *>.toStringKeyMap(): Map<String, Any?> = entries.associate { (key, value) ->
|
|
176
|
+
key.toString() to value
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private companion object {
|
|
180
|
+
const val MODULE_NAME = "GoMarketMeReactNative"
|
|
181
|
+
const val TAG = "GoMarketMeReactNative"
|
|
182
|
+
const val IS_DEBUG_LOGGING_ENABLED = false
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package co.gomarketme.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class GoMarketMeReactNativePackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
+
return listOf(GoMarketMeReactNativeModule(reactContext))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
+
return emptyList()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'gomarketme-react-native'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.homepage = package['homepage']
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.platforms = { :ios => '15.0' }
|
|
14
|
+
s.source_files = 'ios/**/*.{h,m,mm,swift}'
|
|
15
|
+
s.vendored_frameworks = 'ios/Frameworks/GoMarketMeAppleCoreKit.xcframework'
|
|
16
|
+
s.dependency 'React-Core'
|
|
17
|
+
s.swift_version = '5.9'
|
|
18
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>AvailableLibraries</key>
|
|
6
|
+
<array>
|
|
7
|
+
<dict>
|
|
8
|
+
<key>BinaryPath</key>
|
|
9
|
+
<string>GoMarketMeAppleCoreKit.framework/GoMarketMeAppleCoreKit</string>
|
|
10
|
+
<key>LibraryIdentifier</key>
|
|
11
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
12
|
+
<key>LibraryPath</key>
|
|
13
|
+
<string>GoMarketMeAppleCoreKit.framework</string>
|
|
14
|
+
<key>SupportedArchitectures</key>
|
|
15
|
+
<array>
|
|
16
|
+
<string>arm64</string>
|
|
17
|
+
<string>x86_64</string>
|
|
18
|
+
</array>
|
|
19
|
+
<key>SupportedPlatform</key>
|
|
20
|
+
<string>ios</string>
|
|
21
|
+
<key>SupportedPlatformVariant</key>
|
|
22
|
+
<string>simulator</string>
|
|
23
|
+
</dict>
|
|
24
|
+
<dict>
|
|
25
|
+
<key>BinaryPath</key>
|
|
26
|
+
<string>GoMarketMeAppleCoreKit.framework/GoMarketMeAppleCoreKit</string>
|
|
27
|
+
<key>LibraryIdentifier</key>
|
|
28
|
+
<string>ios-arm64</string>
|
|
29
|
+
<key>LibraryPath</key>
|
|
30
|
+
<string>GoMarketMeAppleCoreKit.framework</string>
|
|
31
|
+
<key>SupportedArchitectures</key>
|
|
32
|
+
<array>
|
|
33
|
+
<string>arm64</string>
|
|
34
|
+
</array>
|
|
35
|
+
<key>SupportedPlatform</key>
|
|
36
|
+
<string>ios</string>
|
|
37
|
+
</dict>
|
|
38
|
+
</array>
|
|
39
|
+
<key>CFBundlePackageType</key>
|
|
40
|
+
<string>XFWK</string>
|
|
41
|
+
<key>XCFrameworkFormatVersion</key>
|
|
42
|
+
<string>1.0</string>
|
|
43
|
+
</dict>
|
|
44
|
+
</plist>
|
|
Binary file
|