insert-affiliate-react-native-sdk 1.1.7 → 1.1.8
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/package.json +1 -1
- package/readme.md +32 -42
- package/src/DeepLinkIapProvider.tsx +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insert-affiliate-react-native-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "A package that will give context having implementation of react-native-branch and react-native-iap and iaptic validate api.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/readme.md
CHANGED
|
@@ -10,18 +10,11 @@ The **InsertAffiliateReactNative SDK** is designed for React Native applications
|
|
|
10
10
|
- **Affiliate Identifier Management**: Set and retrieve the affiliate identifier based on user-specific links.
|
|
11
11
|
- **In-App Purchase (IAP) Initialisation**: Easily reinitialise in-app purchases with the option to validate using an affiliate identifier.
|
|
12
12
|
|
|
13
|
-
## Peer Dependencies
|
|
14
|
-
|
|
15
|
-
Before using this package, ensure you have the following dependencies installed:
|
|
16
|
-
|
|
17
|
-
- [react-native-iap](https://www.npmjs.com/package/react-native-iap)
|
|
18
|
-
- [axios](https://www.npmjs.com/package/axios)
|
|
19
|
-
|
|
20
13
|
## Getting Started
|
|
21
14
|
|
|
22
15
|
To get started with the InsertAffiliateReactNative SDK:
|
|
23
16
|
|
|
24
|
-
1. [Install the
|
|
17
|
+
1. [Install the SDK](#installation)
|
|
25
18
|
2. [Initialise the SDK in App.tsx](#basic-usage)
|
|
26
19
|
3. [Set up in-app purchases (Required)](#in-app-purchase-setup-required)
|
|
27
20
|
4. [Set up deep linking (Required)](#deep-link-setup-required)
|
|
@@ -37,7 +30,9 @@ npm install insert-affiliate-react-native-sdk
|
|
|
37
30
|
|
|
38
31
|
## Basic Usage
|
|
39
32
|
|
|
40
|
-
|
|
33
|
+
Follow the steps below to install the SDK. You can use different methods depending on your project setup (e.g., Gradle, Maven, or manual download).
|
|
34
|
+
|
|
35
|
+
#### Step 1: Initialisation in `App.tsx`
|
|
41
36
|
|
|
42
37
|
First, wrap your with our provider and call the `initialise` method early in your app's lifecycle:
|
|
43
38
|
|
|
@@ -60,7 +55,6 @@ const Child = () => {
|
|
|
60
55
|
}, [initialize, isInitialized]);
|
|
61
56
|
|
|
62
57
|
// ...
|
|
63
|
-
|
|
64
58
|
}
|
|
65
59
|
|
|
66
60
|
const App = () => {
|
|
@@ -71,9 +65,6 @@ const App = () => {
|
|
|
71
65
|
);
|
|
72
66
|
};
|
|
73
67
|
```
|
|
74
|
-
- Replace `{{ your_iaptic_app_id }}` with your **Iaptic App ID**. You can find this [here](https://www.iaptic.com/account).
|
|
75
|
-
- Replace `{{ your_iaptic_app_name }}` with your **Iaptic App Name**. You can find this [here](https://www.iaptic.com/account).
|
|
76
|
-
- Replace `{{ your_iaptic_public_key }}` with your **Iaptic Public Key**. You can find this [here](https://www.iaptic.com/settings).
|
|
77
68
|
- Replace `{{ your_company_code }}` with the unique company code associated with your Insert Affiliate account. You can find this code in your dashboard under [Settings](http://app.insertaffiliate.com/settings).
|
|
78
69
|
|
|
79
70
|
## In-App Purchase Setup [Required]
|
|
@@ -84,7 +75,7 @@ Insert Affiliate requires a Receipt Verification platform to validate in-app pur
|
|
|
84
75
|
### Option 1: Iaptic Integration
|
|
85
76
|
First, complete the [Iaptic account setup](https://www.iaptic.com/signup) and code integration.
|
|
86
77
|
|
|
87
|
-
Then after setting up the in app purchase (IAP) with Iaptic, call Insert Affiliate's
|
|
78
|
+
Then after setting up the in app purchase (IAP) with Iaptic, call Insert Affiliate's ```validatePurchaseWithIapticAPI``` on purchase.
|
|
88
79
|
|
|
89
80
|
```javascript
|
|
90
81
|
import React from 'react';
|
|
@@ -96,7 +87,7 @@ const Child = () => {
|
|
|
96
87
|
const {
|
|
97
88
|
initialize,
|
|
98
89
|
isInitialized,
|
|
99
|
-
|
|
90
|
+
validatePurchaseWithIapticAPI,
|
|
100
91
|
} = useDeepLinkIapProvider();
|
|
101
92
|
|
|
102
93
|
const [iapLoading, setIapLoading] = useState(false);
|
|
@@ -108,34 +99,39 @@ const Child = () => {
|
|
|
108
99
|
|
|
109
100
|
// Initialize the Insert Affiliate SDK at the earliest possible moment
|
|
110
101
|
useEffect(() => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
102
|
+
if (!isInitialized) {
|
|
103
|
+
initialize("{{ your_company_code }}");
|
|
104
|
+
}
|
|
114
105
|
}, [initialize, isInitialized]);
|
|
115
106
|
|
|
116
107
|
|
|
117
108
|
// Validate the purchase with Iaptic through Insert Affiliate's SDK for Affiliate Tracking
|
|
118
109
|
useEffect(() => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
110
|
+
if (currentPurchase) {
|
|
111
|
+
validatePurchaseWithIapticAPI(
|
|
112
|
+
currentPurchase,
|
|
113
|
+
'{{ your_iaptic_app_id }}',
|
|
114
|
+
'{{ your_iaptic_app_name }}',
|
|
115
|
+
'{{ your_iaptic_public_key }}',
|
|
116
|
+
).then((isValid: boolean) => {
|
|
117
|
+
if (isValid) {
|
|
118
|
+
console.log("Purchase validated successfully.");
|
|
119
|
+
} else {
|
|
120
|
+
console.error("Purchase validation failed.");
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
128
124
|
}, [currentPurchase, handlePurchaseValidation]);
|
|
129
125
|
|
|
130
126
|
return (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
127
|
+
<View>
|
|
128
|
+
<Button
|
|
129
|
+
disabled={iapLoading}
|
|
130
|
+
title={`Click to Buy Subscription`}
|
|
131
|
+
onPress={() => handleBuySubscription("oneMonthSubscriptionTwo")}
|
|
132
|
+
/>
|
|
133
|
+
{iapLoading && <ActivityIndicator size={"small"} color={"black"} />}
|
|
134
|
+
</View>
|
|
139
135
|
);
|
|
140
136
|
};
|
|
141
137
|
|
|
@@ -236,13 +232,7 @@ To track an event, use the `trackEvent` function. Make sure to set an affiliate
|
|
|
236
232
|
|
|
237
233
|
```javascript
|
|
238
234
|
const {
|
|
239
|
-
|
|
240
|
-
subscriptions,
|
|
241
|
-
iapLoading,
|
|
242
|
-
validatePurchaseWithIapticAPI,
|
|
243
|
-
userId,
|
|
244
|
-
userPurchase,
|
|
245
|
-
trackEvent, // Required for trackEvent
|
|
235
|
+
trackEvent,
|
|
246
236
|
} = useDeepLinkIapProvider();
|
|
247
237
|
|
|
248
238
|
<Button
|