Skip to content

Commit

Permalink
final resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
namidan committed Aug 21, 2024
1 parent 190179e commit df0a5bb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
putString("id", paywallEvent.sku?.id ?: "")
putString("skuId", paywallEvent.sku?.skuId ?: "")
putString("name", paywallEvent.sku?.name ?: "")
putString("type", paywallEvent.sku?.type.toString())
putString("type", paywallEvent.sku?.type.toString().lowercase())
}
resultMap.putMap(SKU, skuMap)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/Basic/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Linking, Platform, EmitterSubscription } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { NamiPaywallManager } from 'react-native-nami-sdk';
import { NamiPaywallManager, NamiSKU } from 'react-native-nami-sdk';

import CampaignScreen from './containers/CampaignScreen';
import ProfileScreen from './containers/ProfileScreen';
Expand Down
18 changes: 13 additions & 5 deletions examples/Basic/containers/CampaignScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@ const CampaignScreen: FC<CampaignScreenProps> = ({ navigation }) => {
const validCampaigns = fetchedCampaigns.filter((campaign) =>
Boolean(campaign.value),
);
setCampaigns(validCampaigns);
console.log('validCampaigns', validCampaigns);
return validCampaigns;

const sortedCampaigns = validCampaigns.sort( (a, b) => (a.value ?? '').localeCompare(b.value ?? '') );
setCampaigns(sortedCampaigns);
console.log('validCampaigns', sortedCampaigns);
return sortedCampaigns;
}, []);

useEffect(() => {

const subscriptionSignInRemover = NamiPaywallManager.registerSignInHandler(
async () => {
console.log('sign in');
Expand Down Expand Up @@ -135,7 +138,8 @@ const CampaignScreen: FC<CampaignScreenProps> = ({ navigation }) => {
const isEqualList =
JSON.stringify(campaigns) === JSON.stringify(availableCampaigns);
setRefresh(!isEqualList);
setCampaigns(availableCampaigns);
const sortedCampaigns = availableCampaigns.sort( (a, b) => (a.value ?? '').localeCompare(b.value ?? '') );
setCampaigns(sortedCampaigns);
},
);

Expand Down Expand Up @@ -189,7 +193,11 @@ const CampaignScreen: FC<CampaignScreenProps> = ({ navigation }) => {
log.info(`NamiPaywallEvent video metadata autoplayVideo - ${event.videoMetadata?.autoplayVideo?.toString()}"`);
log.info(`NamiPaywallEvent video metadata muteByDefault - ${event.videoMetadata?.muteByDefault?.toString()}"`);
log.info(`NamiPaywallEvent video metadata loopVideo - ${event.videoMetadata?.loopVideo?.toString()}"`);
log.info(`NamiPaywallEvent sku - ${event.sku?.skuId}"`);
log.info(`NamiPaywallEvent sku name - ${event.sku?.name}"`);
log.info(`NamiPaywallEvent sku id - ${event.sku?.id}"`);
log.info(`NamiPaywallEvent sku skuId - ${event.sku?.skuId}"`);
log.info(`NamiPaywallEvent sku type - ${event.sku?.type}"`);

setAction(event.action);
},
);
Expand Down
21 changes: 13 additions & 8 deletions examples/Basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,22 @@ const Root = () => {
console.log('NamiSDK: configured', configured);
};

useEffect(async() => {
useEffect(() => {

checkSdkConfigured();

const result = await Nami.configure(configDict);
if(result.success){
setIsConfigurationComplete(true);
async function configureSDK() {
// You can await here
checkSdkConfigured();
}

initStoreConnection();
const result = await Nami.configure(configDict);
if(result.success){
setIsConfigurationComplete(true);
checkSdkConfigured();
}

initStoreConnection();
// ...
}
configureSDK();

// eslint-disable-next-line @typescript-eslint/no-empty-function
return () => {};
Expand Down
2 changes: 1 addition & 1 deletion ios/NamiCampaignManagerBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class RNNamiCampaignManager: RCTEventEmitter {
skuDict["id"] = sku.id
skuDict["name"] = sku.name
skuDict["skuId"] = sku.skuId
skuDict["type"] = sku.type
skuDict["type"] = sku.type.description
}

var componentChange: [String: Any?] = [:]
Expand Down

0 comments on commit df0a5bb

Please sign in to comment.