Skip to content

Commit

Permalink
Merge branch 'develop' into chore/turn-on-detox-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bataevvlad committed Jul 27, 2023
2 parents ca26c97 + 704fb0a commit 5034f4e
Show file tree
Hide file tree
Showing 26 changed files with 293 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/app_prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ jobs:
pip3 install PyJWT
echo "1.0" > $RUNNER_TEMP/.current_version
export CURRENT_VERSION=`cat $RUNNER_TEMP/.current_version`
python3 get_next_build.py com.namiml.stg.testreactnative --prerelease --platform=TV_OS > $RUNNER_TEMP/.next_build_number
python3 get_next_build.py com.namiml.app.testreactnative --prerelease --platform=TV_OS > $RUNNER_TEMP/.next_build_number
working-directory: appstoreconnect-build-tools
env:
APPSTORE_API_KEY_ID: "${{ secrets.APPSTORE_API_KEY_ID }}"
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

implementation 'com.github.jeziellago:compose-markdown:0.3.0'
implementation "com.namiml:sdk-android:3.0.22"
implementation "com.namiml:sdk-android:3.0.24"

implementation 'com.facebook.react:react-native:+' // From node_modules
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
} else {
Arguments.createArray()
}
val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.19")
val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.24")
namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
settingsList.addAll(commandsFromReact)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
const val CAMPAIGN_TYPE = "campaignType"
const val CAMPAIGN_URL = "campaignUrl"
const val PAYWALL_NAME = "paywallName"
const val COMPONENT_CHANGE_ID = "componentChangeId"
const val COMPONENT_CHANGE_NAME = "componentChangeName"
const val SEGMENT_ID = "segmentId"
const val EXTERNAL_SEGMENT_ID = "externalSegmentId"
const val DEEP_LINK_URL = "deeplinkUrl"
Expand Down Expand Up @@ -57,7 +59,6 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :

var paywallLaunchContext: PaywallLaunchContext? = null
if (context != null) {

val productGroups: MutableList<String> = mutableListOf()
val customAttributes: MutableMap<String, String> = mutableMapOf()

Expand All @@ -69,7 +70,6 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
if (groupString != null) {
productGroups.add(groupString)
}

}
}
Log.d(LOG_TAG, "productGroups $productGroups")
Expand All @@ -87,7 +87,12 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
}
}

paywallLaunchContext = PaywallLaunchContext(productGroups.toList(), customAttributes)
if (context.hasKey("productGroups")) {
paywallLaunchContext = PaywallLaunchContext(productGroups.toList(), customAttributes)
} else {
paywallLaunchContext = PaywallLaunchContext(null, customAttributes)
}

}

if (theActivity != null) {
Expand Down Expand Up @@ -186,6 +191,8 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
putString(CAMPAIGN_TYPE, campaignType ?: "")
putString(CAMPAIGN_URL, campaignUrl ?: "")
putString(PAYWALL_NAME, paywallName ?: "")
putString(COMPONENT_CHANGE_ID, "")
putString(COMPONENT_CHANGE_NAME, "")
putString(SEGMENT_ID, segmentId ?: "")
putString(EXTERNAL_SEGMENT_ID, externalSegmentId ?: "")
putString(DEEP_LINK_URL, deeplinkUrl ?: "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,19 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
}
}

@ReactMethod
fun registerRestoreHandler() {
NamiPaywallManager.registerRestoreHandler { activity ->
latestPaywallActivity = activity
val map = Arguments.createMap().apply {
putBoolean("paywallRestoreRequested", true)
}
reactApplicationContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
.emit("PaywallRestoreRequested", map)
}
}

@ReactMethod
fun show() {
// Do nothing on Android side
Expand All @@ -232,6 +245,12 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
// Do nothing on Android side
}

@ReactMethod
fun isHidden(promise: Promise) {
// Do nothing on Android side
promise.resolve(false)
}

@ReactMethod
fun addListener(eventName: String?) {
}
Expand Down
2 changes: 2 additions & 0 deletions android/src/main/java/com/nami/reactlibrary/NamiUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ fun NamiSKU.toSkuDict(): WritableMap {
productDict.putString("skuId", this.skuId)
productDict.putString("id", this.id)
productDict.putString("type", this.type.toString())
productDict.putString("promoId","")
productDict.putString("promoToken","")

return productDict
}
Expand Down
79 changes: 42 additions & 37 deletions examples/Basic/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,51 +48,56 @@ const App = () => {
}, []);

useEffect(() => {
NamiPaywallManager.registerBuySkuHandler((sku) => {
console.log(
'buy sku handler - need to start purchase flow for sku:',
sku.skuId,
);
const subscriptionRemover = NamiPaywallManager.registerBuySkuHandler(
(sku) => {
console.log(
'buy sku handler - need to start purchase flow for sku:',
sku.skuId,
sku.promoId,
);

NamiPaywallManager.dismiss(true);
NamiPaywallManager.dismiss(true);

if (Platform.OS === 'ios' || Platform.isTVOS) {
NamiPaywallManager.buySkuCompleteApple({
product: sku,
transactionID: '12345',
originalTransactionID: '12345',
originalPurchaseDate: 1684823428,
purchaseDate: 1684823428,
price: '120',
currencyCode: 'USD',
locale: 'US',
});
} else if (Platform.OS === 'android') {
if (Platform.constants.Manufacturer === 'Amazon') {
NamiPaywallManager.buySkuCompleteAmazon({
if (Platform.OS === 'ios' || Platform.isTVOS) {
NamiPaywallManager.buySkuCompleteApple({
product: sku,
transactionID: '12345',
originalTransactionID: '12345',
originalPurchaseDate: 1684823428,
purchaseDate: 1684823428,
purchaseSource: 'CAMPAIGN',
receiptId: '12345',
localizedPrice: '120',
userId: '12345',
marketplace: '12345',
});
} else {
NamiPaywallManager.buySkuCompleteGooglePlay({
product: sku,
purchaseDate: 1684823428,
purchaseSource: 'CAMPAIGN',
purchaseToken:
'jolbnkpmojnpnjecgmphbmkc.AO-J1OznE4AIzyUvKFe1RSVkxw4KEtv0WfyL_tkzozOqnlSvIPsyQJBphCN80gwIMaex4EMII95rFCZhMCbVPZDc-y_VVhQU5Ddua1dLn8zV7ms_tdwoDmE',
orderId: 'GPA.3317-0284-9993-42221',
price: '120',
currencyCode: 'USD',
locale: 'US',
});
} else if (Platform.OS === 'android') {
if (Platform.constants.Manufacturer === 'Amazon') {
NamiPaywallManager.buySkuCompleteAmazon({
product: sku,
purchaseDate: 1684823428,
purchaseSource: 'CAMPAIGN',
receiptId: '12345',
localizedPrice: '120',
userId: '12345',
marketplace: '12345',
});
} else {
NamiPaywallManager.buySkuCompleteGooglePlay({
product: sku,
purchaseDate: 1684823428,
purchaseSource: 'CAMPAIGN',
purchaseToken:
'jolbnkpmojnpnjecgmphbmkc.AO-J1OznE4AIzyUvKFe1RSVkxw4KEtv0WfyL_tkzozOqnlSvIPsyQJBphCN80gwIMaex4EMII95rFCZhMCbVPZDc-y_VVhQU5Ddua1dLn8zV7ms_tdwoDmE',
orderId: 'GPA.3317-0284-9993-42221',
});
}
}
}
});
},
);

NamiCustomerManager.setCustomerDataPlatformId('2135');
return () => {};
return () => {
subscriptionRemover();
};
}, []);

return (
Expand Down
36 changes: 27 additions & 9 deletions examples/Basic/containers/CampaignScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Text,
TouchableOpacity,
View,
Platform,
} from 'react-native';
import {ViewerTabProps} from '../App';
import theme from '../theme';
Expand Down Expand Up @@ -50,6 +51,14 @@ const CampaignScreen: FC<CampaignScreenProps> = ({navigation}) => {
'INITIAL',
);

const showPaywallIfHidden = async () => {
if (Platform.OS === 'ios' && (await NamiPaywallManager.isHidden())) {
NamiPaywallManager.show();
} else {
console.log('paywall is not hidden');
}
};

const getAllCampaigns = useCallback(async () => {
const fetchedCampaigns = await NamiCampaignManager.allCampaigns();
const validCampaigns = fetchedCampaigns.filter((campaign) =>
Expand All @@ -65,9 +74,16 @@ const CampaignScreen: FC<CampaignScreenProps> = ({navigation}) => {
const subscriptionSignInRemover = NamiPaywallManager.registerSignInHandler(
() => {
console.log('sign in');
NamiPaywallManager.hide();
NamiPaywallManager.dismiss();
},
);

const subscriptionRestoreRemover =
NamiPaywallManager.registerRestoreHandler(() => {
console.log('restore');
NamiPaywallManager.dismiss();
});

const subscriptionRemover =
NamiCampaignManager.registerAvailableCampaignsHandler(
(availableCampaigns) => {
Expand All @@ -81,19 +97,17 @@ const CampaignScreen: FC<CampaignScreenProps> = ({navigation}) => {
return () => {
subscriptionRemover();
subscriptionSignInRemover();
subscriptionRestoreRemover();
};
//Note: not needed in depts
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const triggerLaunch = (label?: any, url?: any) => {
// const paywallLaunchContext = {
// productGroups: ['group1'],
// };
return NamiCampaignManager.launch(
label,
url,
undefined,
{},
(successAction, error) => {
console.log('successAction', successAction);
console.log('error', error);
Expand All @@ -102,31 +116,35 @@ const CampaignScreen: FC<CampaignScreenProps> = ({navigation}) => {
action,
campaignId,
paywallId,
campaignLabel,
campaignName,
campaignType,
campaignLabel,
campaignUrl,
paywallName,
segmentId,
externalSegmentId,
paywallName,
deeplinkUrl,
skuId,
componentChangeId,
componentChangeName,
purchaseError,
purchases,
) => {
console.log('action', action);
setAction(action);
console.log('campaignId', campaignId);
console.log('paywallId', paywallId);
console.log('campaignLabel', campaignLabel);
console.log('campaignName', campaignName);
console.log('campaignType', campaignType);
console.log('campaignLabel', campaignLabel);
console.log('campaignUrl', campaignUrl);
console.log('paywallName', paywallName);
console.log('segmentId', segmentId);
console.log('externalSegmentId', externalSegmentId);
console.log('deeplinkUrl', deeplinkUrl);
console.log('skuId', skuId);
console.log('componentChangeId', componentChangeId);
console.log('componentChangeName', componentChangeName);
console.log('purchaseError', purchaseError);
console.log('purchases', purchases);
},
Expand Down Expand Up @@ -161,7 +179,7 @@ const CampaignScreen: FC<CampaignScreenProps> = ({navigation}) => {
}, []);

const onButtonPress = useCallback(() => {
NamiPaywallManager.show();
showPaywallIfHidden();
}, []);

useLayoutEffect(() => {
Expand Down
18 changes: 13 additions & 5 deletions examples/Basic/ios/StoreKitSTG.storekit
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"settings" : {
"_applicationInternalID" : "6443910111",
"_developerTeamID" : "K6APTMK8Y8",
"_lastSynchronizedDate" : 706849380.87510896
"_lastSynchronizedDate" : 712074466.26017404
},
"subscriptionGroups" : [
{
Expand All @@ -21,7 +21,15 @@
"subscriptions" : [
{
"adHocOffers" : [

{
"displayPrice" : "4.99",
"internalID" : "FD31BD5B",
"numberOfPeriods" : 1,
"offerID" : "plus_annual_promo_1",
"paymentMode" : "payAsYouGo",
"referenceName" : "Plus Annual Promo",
"subscriptionPeriod" : "P1Y"
}
],
"codeOffers" : [

Expand Down Expand Up @@ -81,7 +89,7 @@
"groupNumber" : 2,
"internalID" : "6447770869",
"introductoryOffer" : {
"internalID" : "E5F54037",
"internalID" : "832A850B",
"numberOfPeriods" : 1,
"paymentMode" : "free",
"subscriptionPeriod" : "P3D"
Expand Down Expand Up @@ -111,7 +119,7 @@
"groupNumber" : 1,
"internalID" : "6447770794",
"introductoryOffer" : {
"internalID" : "6574C3D4",
"internalID" : "7985E305",
"numberOfPeriods" : 1,
"paymentMode" : "free",
"subscriptionPeriod" : "P1W"
Expand Down Expand Up @@ -166,7 +174,7 @@
"groupNumber" : 1,
"internalID" : "6447770843",
"introductoryOffer" : {
"internalID" : "B9B4646C",
"internalID" : "B3B76E7C",
"numberOfPeriods" : 1,
"paymentMode" : "free",
"subscriptionPeriod" : "P3D"
Expand Down
Loading

0 comments on commit 5034f4e

Please sign in to comment.