Skip to content

Commit

Permalink
Apple 3.1.0 with paywall action event (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
namidan authored Jul 26, 2023
1 parent a5efae7 commit 3035b12
Show file tree
Hide file tree
Showing 20 changed files with 208 additions and 105 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
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.23")
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 @@ -189,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
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
10 changes: 7 additions & 3 deletions examples/Basic/containers/CampaignScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,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
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
18 changes: 17 additions & 1 deletion examples/TestNamiTV/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ android {
manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round"
manifestPlaceholders.app_icon = "@mipmap/ic_launcher"
}
flavorDimensions "default"
flavorDimensions "default", "store"
productFlavors {
production {
applicationId "com.namiml.testreact.prod"
Expand Down Expand Up @@ -196,6 +196,22 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}

productFlavors {
amazon {
dimension "store"
repositories {
maven { url "https://packages.namiml.com/NamiSDK/Amazon/"}
}
}
play {
dimension "store"
repositories {
maven { url "https://packages.namiml.com/NamiSDK/Android/"}
}
}
}

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down
1 change: 0 additions & 1 deletion examples/TestNamiTV/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ allprojects {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url("https://packages.namiml.com/NamiSDK/Android/") }
}
}
38 changes: 35 additions & 3 deletions examples/TestNamiTV/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,48 @@ export function getConfigObject() {
switch (flavor) {
case 'staging':
return {
'appPlatformID-apple': 'APPLE_STG_APP_PLATFORM_ID',
'appPlatformID-android': 'ANDROID_STG_APP_PLATFORM_ID',
'appPlatformID-apple': 'APPLE_STAGE_APP_PLATFORM_ID',
'appPlatformID-android': 'UNUSED',
logLevel: 'DEBUG',
namiCommands: ['useStagingAPI'],
initialConfig: getInitialConfig(),
};
case 'stagingAmazon':
return {
'appPlatformID-apple': 'UNUSED',
'appPlatformID-android': 'AMAZON_STAGE_APP_PLATFORM_ID',
logLevel: 'DEBUG',
namiCommands: ['useStagingAPI'],
initialConfig: getInitialConfig(),
};
case 'stagingGoogle':
return {
'appPlatformID-apple': 'UNUSED',
'appPlatformID-android': 'GOOGLE_PROD_APP_PLATFORM_ID',
logLevel: 'DEBUG',
namiCommands: ['useStagingAPI'],
initialConfig: getInitialConfig(),
};
case 'productionAmazon':
return {
'appPlatformID-apple': 'UNUSED',
'appPlatformID-android': 'AMAZON_PROD_APP_PLATFORM_ID',
logLevel: 'DEBUG',
namiCommands: ['useStagingAPI'],
initialConfig: getInitialConfig(),
};
case 'productionGoogle':
return {
'appPlatformID-apple': 'UNUSED',
'appPlatformID-android': 'GOOGLE_PROD_APP_PLATFORM_ID',
logLevel: 'DEBUG',
namiCommands: ['useStagingAPI'],
initialConfig: getInitialConfig(),
};
default:
return {
'appPlatformID-apple': 'APPLE_PROD_APP_PLATFORM_ID',
'appPlatformID-android': 'ANDROID_PROD_APP_PLATFORM_ID',
'appPlatformID-android': 'GOOGLE_PROD_APP_PLATFORM_ID',
logLevel: 'DEBUG',
initialConfig: getInitialConfig(),
};
Expand Down
19 changes: 10 additions & 9 deletions examples/TestNamiTV/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@react-native-community/cli-platform-android": "^11.3.1",
"@react-native-community/masked-view": "^0.1.11",
"@react-navigation/bottom-tabs": "^6.5.7",
"@react-navigation/native": "^6.1.6",
"@react-navigation/native-stack": "^6.9.12",
"react": "^18.0.0",
"react": "18.0.0",
"react-native": "npm:react-native-tvos@0.69.8-2",
"react-native-nami-sdk": "file:../../",
"react-native-reanimated": "^3.0.1",
"react-native-safe-area-context": "^4.5.3",
"react-native-screens": "^3.20.0",
"react-native-theoplayer": "2.8.0"
"react-native-reanimated": "^2.3.1",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "^3.20.0"
},
"devDependencies": {
"@babel/core": "^7.16.5",
Expand All @@ -33,19 +33,20 @@
"@tsconfig/react-native": "^2.0.3",
"@types/jest": "^29.5.0",
"@types/react": "^18.0.31",
"@types/react-native": "^0.63.18",
"@types/react-native": "^0.71.5",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"babel-jest": "^27.4.5",
"detox": "^20.9.1",
"eslint": "^8.37.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-native": "^4.0.0",
"jest": "^27.4.5",
"metro-react-native-babel-preset": "^0.76.5",
"jest": "^29.5.0",
"metro-react-native-babel-preset": "^0.66.2",
"prettier": "^2.8.7",
"react-native-codegen": "^0.0.12",
"react-test-renderer": "^18.2.0",
"react-test-renderer": "17.0.2",
"typescript": "^5.0.2"
},
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion ios/Nami.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ @implementation NamiBridge (RCTExternModule)
}

// Start commands with header iformation for Nami to let them know this is a React client.
NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.23"]];
NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.24"]];

// Add additional namiCommands app may have sent in.
NSObject *appCommandStrings = configDict[@"namiCommands"];
Expand Down
Loading

0 comments on commit 3035b12

Please sign in to comment.