insert-affiliate-react-native-sdk 1.6.2 → 1.6.3
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/dist/DeepLinkIapProvider.js +13 -4
- package/package.json +1 -1
- package/readme.md +29 -5
- package/src/DeepLinkIapProvider.tsx +13 -4
|
@@ -548,9 +548,18 @@ const DeepLinkIapProvider = ({ children, }) => {
|
|
|
548
548
|
verboseLog('Cannot fetch offer code: no company code available');
|
|
549
549
|
return null;
|
|
550
550
|
}
|
|
551
|
+
let platformType = 'ios';
|
|
552
|
+
// Check if its iOs or Android here
|
|
553
|
+
if (react_native_1.Platform.OS !== 'ios') {
|
|
554
|
+
verboseLog('Platform is not iOS, setting platform type to android');
|
|
555
|
+
platformType = 'android';
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
verboseLog('Platform is iOS, setting platform type to ios');
|
|
559
|
+
}
|
|
551
560
|
const encodedAffiliateLink = encodeURIComponent(affiliateLink);
|
|
552
|
-
const url = `https://api.insertaffiliate.com/v1/affiliateReturnOfferCode/${activeCompanyCode}/${encodedAffiliateLink}`;
|
|
553
|
-
verboseLog(`
|
|
561
|
+
const url = `https://api.insertaffiliate.com/v1/affiliateReturnOfferCode/${activeCompanyCode}/${encodedAffiliateLink}?platformType=${platformType}`;
|
|
562
|
+
verboseLog(`Starting to fetch offer code from: ${url}`);
|
|
554
563
|
const response = yield axios_1.default.get(url);
|
|
555
564
|
if (response.status === 200) {
|
|
556
565
|
const offerCode = response.data;
|
|
@@ -603,8 +612,8 @@ const DeepLinkIapProvider = ({ children, }) => {
|
|
|
603
612
|
}
|
|
604
613
|
});
|
|
605
614
|
const removeSpecialCharacters = (offerCode) => {
|
|
606
|
-
// Remove special characters, keep only alphanumeric and
|
|
607
|
-
return offerCode.replace(/[^a-zA-Z0-9_]/g, '');
|
|
615
|
+
// Remove special characters, keep only alphanumeric, underscores, and hyphens
|
|
616
|
+
return offerCode.replace(/[^a-zA-Z0-9_-]/g, '');
|
|
608
617
|
};
|
|
609
618
|
const cleanOfferCode = (offerCode) => {
|
|
610
619
|
// Remove special characters, keep only alphanumeric
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -524,13 +524,10 @@ const {
|
|
|
524
524
|
|
|
525
525
|
The SDK allows you to apply dynamic modifiers to in-app purchases based on whether the app was installed via an affiliate. These modifiers can be used to swap the default product ID for a discounted or trial-based one - similar to applying an offer code.
|
|
526
526
|
|
|
527
|
-
> **Note:** Offer Codes are currently supported on **iOS only**.
|
|
528
|
-
|
|
529
527
|
#### How It Works
|
|
530
528
|
|
|
531
529
|
When a user clicks an affiliate link or enters a short code linked to an offer (set up in the **Insert Affiliate Dashboard**), the SDK auto-populates the `OfferCode` field with a relevant modifier (e.g., `_oneWeekFree`). You can append this to your base product ID to dynamically display the correct subscription.
|
|
532
530
|
|
|
533
|
-
|
|
534
531
|
#### Basic Usage
|
|
535
532
|
|
|
536
533
|
##### 1. Automatic Offer Code Fetching
|
|
@@ -545,12 +542,41 @@ const { OfferCode } = useDeepLinkIapProvider();
|
|
|
545
542
|
|
|
546
543
|
##### Setup Requirements
|
|
547
544
|
|
|
545
|
+
#### Insert Affiliate Setup Instructions
|
|
546
|
+
|
|
547
|
+
1. Go to your Insert Affiliate dashboard at [app.insertaffiliate.com/affiliates](https://app.insertaffiliate.com/affiliates)
|
|
548
|
+
2. Select the affiliate you want to configure
|
|
549
|
+
3. Click "View" to access the affiliate's settings
|
|
550
|
+
4. Assign an iOS IAP Modifier to the affiliate (e.g., `_oneWeekFree`, `_threeMonthsFree`)
|
|
551
|
+
5. Assign an Android IAP Modifier to the affiliate (e.g., `-oneweekfree`, `-threemonthsfree`)
|
|
552
|
+
5. Save the settings
|
|
553
|
+
|
|
554
|
+
Once configured, when users click that affiliate's links or enter their short codes, your app will automatically receive the modifier and can load the appropriate discounted product.
|
|
555
|
+
|
|
548
556
|
#### App Store Connect Configuration
|
|
549
557
|
1. Create both a base and a promotional product:
|
|
550
558
|
- Base product: `oneMonthSubscription`
|
|
551
559
|
- Promo product: `oneMonthSubscription_oneWeekFree`
|
|
552
560
|
2. Ensure **both** products are approved and available for sale.
|
|
553
561
|
|
|
562
|
+
#### Google Play Console Configuration
|
|
563
|
+
There are multiple ways you can configure your products in Google Play Console:
|
|
564
|
+
|
|
565
|
+
1. **Multiple Products Approach**: Create both a base and a promotional product:
|
|
566
|
+
- Base product: `oneMonthSubscription`
|
|
567
|
+
- Promo product: `oneMonthSubscription-oneweekfree`
|
|
568
|
+
|
|
569
|
+
2. **Single Product with Multiple Base Plans**: Create one product with multiple base plans, one with an offer attached
|
|
570
|
+
|
|
571
|
+
3. **Developer Triggered Offers**: Have one base product and apply the offer through developer-triggered offers
|
|
572
|
+
|
|
573
|
+
4. **Base Product with Intro Offers**: Have one base product that includes an introductory offer
|
|
574
|
+
|
|
575
|
+
Any of these approaches are suitable and work with the SDK. The important part is that your product naming follows the pattern where the offer code modifier can be appended to identify the promotional version.
|
|
576
|
+
|
|
577
|
+
**If using the Multiple Products Approach:**
|
|
578
|
+
- Ensure **both** products are activated and available for purchase.
|
|
579
|
+
- Generate a release to at least **Internal Testing** to make the products available in your current app build
|
|
554
580
|
|
|
555
581
|
**Product Naming Pattern:**
|
|
556
582
|
- Follow the pattern: `{baseProductId}{OfferCode}`
|
|
@@ -829,8 +855,6 @@ Short codes must meet the following criteria:
|
|
|
829
855
|
- Contain only **letters, numbers, and underscores** (alphanumeric characters and underscores).
|
|
830
856
|
- Replace {{ user_entered_short_code }} with the short code the user enters through your chosen input method, i.e. an input field / pop up element
|
|
831
857
|
|
|
832
|
-
When a short code is set, the SDK automatically attempts to fetch and store any associated offer codes for iOS users.
|
|
833
|
-
|
|
834
858
|
```javascript
|
|
835
859
|
import {
|
|
836
860
|
DeepLinkIapProvider,
|
|
@@ -661,10 +661,19 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
661
661
|
return null;
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
+
let platformType = 'ios'
|
|
665
|
+
// Check if its iOs or Android here
|
|
666
|
+
if (Platform.OS !== 'ios') {
|
|
667
|
+
verboseLog('Platform is not iOS, setting platform type to android');
|
|
668
|
+
platformType = 'android'
|
|
669
|
+
} else {
|
|
670
|
+
verboseLog('Platform is iOS, setting platform type to ios');
|
|
671
|
+
}
|
|
672
|
+
|
|
664
673
|
const encodedAffiliateLink = encodeURIComponent(affiliateLink);
|
|
665
|
-
const url = `https://api.insertaffiliate.com/v1/affiliateReturnOfferCode/${activeCompanyCode}/${encodedAffiliateLink}`;
|
|
674
|
+
const url = `https://api.insertaffiliate.com/v1/affiliateReturnOfferCode/${activeCompanyCode}/${encodedAffiliateLink}?platformType=${platformType}`;
|
|
666
675
|
|
|
667
|
-
verboseLog(`
|
|
676
|
+
verboseLog(`Starting to fetch offer code from: ${url}`);
|
|
668
677
|
|
|
669
678
|
const response = await axios.get(url);
|
|
670
679
|
|
|
@@ -723,8 +732,8 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
723
732
|
};
|
|
724
733
|
|
|
725
734
|
const removeSpecialCharacters = (offerCode: string): string => {
|
|
726
|
-
// Remove special characters, keep only alphanumeric and
|
|
727
|
-
return offerCode.replace(/[^a-zA-Z0-9_]/g, '');
|
|
735
|
+
// Remove special characters, keep only alphanumeric, underscores, and hyphens
|
|
736
|
+
return offerCode.replace(/[^a-zA-Z0-9_-]/g, '');
|
|
728
737
|
};
|
|
729
738
|
|
|
730
739
|
const cleanOfferCode = (offerCode: string): string => {
|