diff --git a/android/build.gradle b/android/build.gradle index a10ffa5c..0a6ff5a7 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -65,7 +65,7 @@ repositories { mavenCentral() // ref: https://www.baeldung.com/maven-local-repository mavenLocal() - maven { url("https://packages.namiml.com/NamiSDK/Android/") } + maven { url("https://packages.namiml.com/NamiSDK/Amazon/") } maven { url 'https://jitpack.io' } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm @@ -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.1.3" + compileOnly "com.namiml:sdk-amazon:3.1.5" implementation 'com.facebook.react:react-native:+' // From node_modules coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" diff --git a/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt index b19c1328..5e03a7cd 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt @@ -115,7 +115,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) : } else { Arguments.createArray() } - val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.29") + val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.30") namiCommandsReact?.toArrayList()?.filterIsInstance()?.let { commandsFromReact -> settingsList.addAll(commandsFromReact) } diff --git a/android/src/main/java/com/nami/reactlibrary/NamiEntitlementManagerBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiEntitlementManagerBridgeModule.kt index 7847b17a..33046ed8 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiEntitlementManagerBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiEntitlementManagerBridgeModule.kt @@ -61,6 +61,11 @@ class NamiEntitlementManagerBridgeModule(reactContext: ReactApplicationContext) } } + @ReactMethod + fun clearProvisionalEntitlementGrants() { + NamiEntitlementManager.clearProvisionalEntitlementGrants() + } + @ReactMethod fun addListener(eventName: String?) { } diff --git a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt index cff2af45..1c079260 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt @@ -251,6 +251,11 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) : promise.resolve(false) } + @ReactMethod + fun buySkuCancel() { + NamiPaywallManager.buySkuCancel() + } + @ReactMethod fun addListener(eventName: String?) { } diff --git a/examples/Basic/android/app/build.gradle b/examples/Basic/android/app/build.gradle index a177b37a..ee133f7d 100644 --- a/examples/Basic/android/app/build.gradle +++ b/examples/Basic/android/app/build.gradle @@ -218,6 +218,8 @@ dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" // From node_modules implementation 'com.github.jeziellago:compose-markdown:0.3.0' + implementation "com.namiml:sdk-android:3.1.5" + implementation project(':react-native-screens') if (enableHermes) { diff --git a/examples/Basic/android/app/src/main/res/xml/network_security_config.xml b/examples/Basic/android/app/src/main/res/xml/network_security_config.xml index c7755e76..fe0064a2 100644 --- a/examples/Basic/android/app/src/main/res/xml/network_security_config.xml +++ b/examples/Basic/android/app/src/main/res/xml/network_security_config.xml @@ -4,4 +4,4 @@ 10.0.2.2 localhost - \ No newline at end of file + diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index 0d5ebc46..b400cd86 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -39,12 +39,12 @@ const HeaderRight = ({ onRefreshPress }: {onRefreshPress: () => void}) => ( // For Nami testing purposes only const HeaderLeft = ({ onButtonPress } : { onButtonPress: () => void }) => ( - Show Paywall + Show ); @@ -194,7 +194,8 @@ const CampaignScreen: FC = ({ navigation }) => { }, []); const onButtonPress = useCallback(() => { - showPaywallIfHidden(); + // showPaywallIfHidden(); + NamiPaywallManager.buySkuCancel(); }, []); useLayoutEffect(() => { @@ -358,6 +359,12 @@ const styles = StyleSheet.create({ justifyContent: 'center', alignItems: 'center', }, + headerButtonLeft: { + marginLeft: 15, + height: 30, + justifyContent: 'center', + alignItems: 'center', + }, headerButtonText: { color: theme.links, fontSize: 16, diff --git a/examples/Basic/containers/EntitlementsScreen.tsx b/examples/Basic/containers/EntitlementsScreen.tsx index 0a4472fc..9a6216ff 100644 --- a/examples/Basic/containers/EntitlementsScreen.tsx +++ b/examples/Basic/containers/EntitlementsScreen.tsx @@ -31,11 +31,15 @@ const EntitlementsScreen: FC = ({ navigation }) => { }; const onRefreshPress = () => { - NamiEntitlementManager.refresh(newEtitlements => { - console.log('newEntitlements', newEtitlements); + NamiEntitlementManager.refresh(newEntitlements => { + console.log('newEntitlements', newEntitlements); }); }; + const onClearPress = () => { + NamiEntitlementManager.clearProvisionalEntitlementGrants(); + }; + useEffect(() => { getAllEntitlements(); const subscriptionRemover = @@ -65,6 +69,19 @@ const EntitlementsScreen: FC = ({ navigation }) => { ); }, + headerLeft: () => { + return ( + + + Clear + + + ); + }, }); }, [navigation]); @@ -136,6 +153,12 @@ const styles = StyleSheet.create({ justifyContent: 'center', alignItems: 'center', }, + headerLeftButton: { + marginLeft: 15, + height: 30, + justifyContent: 'center', + alignItems: 'center', + }, headerButtonText: { color: theme.links, fontSize: 16, diff --git a/examples/TestNamiTV/android/app/build.gradle b/examples/TestNamiTV/android/app/build.gradle index eed31459..834ebb16 100644 --- a/examples/TestNamiTV/android/app/build.gradle +++ b/examples/TestNamiTV/android/app/build.gradle @@ -200,15 +200,9 @@ android { 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/"} - } } } @@ -233,6 +227,9 @@ dependencies { implementation "com.facebook.react:react-native:+" // From node_modules implementation 'com.github.jeziellago:compose-markdown:0.3.0' + amazonImplementation "com.namiml:sdk-amazon:3.1.5" + playImplementation "com.namiml:sdk-android:3.1.5" + if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") diff --git a/examples/TestNamiTV/android/build.gradle b/examples/TestNamiTV/android/build.gradle index e251fb35..186f4252 100644 --- a/examples/TestNamiTV/android/build.gradle +++ b/examples/TestNamiTV/android/build.gradle @@ -46,5 +46,8 @@ allprojects { google() jcenter() maven { url 'https://jitpack.io' } + maven { url "https://packages.namiml.com/NamiSDK/Amazon/"} + maven { url "https://packages.namiml.com/NamiSDK/Android/"} + } } diff --git a/ios/Nami.m b/ios/Nami.m index 708152d5..3a82b8c1 100644 --- a/ios/Nami.m +++ b/ios/Nami.m @@ -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.29"]]; + NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.30"]]; // Add additional namiCommands app may have sent in. NSObject *appCommandStrings = configDict[@"namiCommands"]; diff --git a/ios/NamiEntitlementManagerBridge.m b/ios/NamiEntitlementManagerBridge.m index 6f746826..979e1ceb 100644 --- a/ios/NamiEntitlementManagerBridge.m +++ b/ios/NamiEntitlementManagerBridge.m @@ -18,6 +18,8 @@ @interface RCT_EXTERN_MODULE(RNNamiEntitlementManager, NSObject) RCT_EXTERN_METHOD(registerActiveEntitlementsHandler) +RCT_EXTERN_METHOD(clearProvisionalEntitlementGrants) + + (BOOL)requiresMainQueueSetup { return YES; } diff --git a/ios/NamiEntitlementManagerBridge.swift b/ios/NamiEntitlementManagerBridge.swift index 16490ca9..a69e9bf8 100644 --- a/ios/NamiEntitlementManagerBridge.swift +++ b/ios/NamiEntitlementManagerBridge.swift @@ -36,6 +36,7 @@ class RNNamiEntitlementManager: RCTEventEmitter { let dictionary = RNNamiPurchaseManager.skuToSKUDict(sku) return dictionary } + let dictionary: [String: Any?] = [ "name": entitlement.name, "desc": entitlement.desc, @@ -78,4 +79,9 @@ class RNNamiEntitlementManager: RCTEventEmitter { RNNamiEntitlementManager.shared?.sendEvent(withName: "EntitlementsChanged", body: dictionaries) } } + + @objc(clearProvisionalEntitlementGrants) + func clearProvisionalEntitlementGrants() { + NamiEntitlementManager.clearProvisionalEntitlementGrants() + } } diff --git a/ios/NamiPaywallManagerBridge.m b/ios/NamiPaywallManagerBridge.m index 672ab67b..081b7ec2 100644 --- a/ios/NamiPaywallManagerBridge.m +++ b/ios/NamiPaywallManagerBridge.m @@ -33,6 +33,8 @@ @interface RCT_EXTERN_MODULE(RNNamiPaywallManager, NSObject) RCT_EXTERN_METHOD(isHidden:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) +RCT_EXTERN_METHOD(buySkuCancel) + + (BOOL)requiresMainQueueSetup { return YES; } diff --git a/ios/NamiPaywallManagerBridge.swift b/ios/NamiPaywallManagerBridge.swift index 77716c9c..1f60a261 100644 --- a/ios/NamiPaywallManagerBridge.swift +++ b/ios/NamiPaywallManagerBridge.swift @@ -130,6 +130,13 @@ class RNNamiPaywallManager: RCTEventEmitter { } } + @objc(buySkuCancel) + func buySkuCancel() { + DispatchQueue.main.async { + NamiPaywallManager.buySkuCancel() + } + } + @objc(isHidden:rejecter:) func isHidden(resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) { DispatchQueue.main.async { diff --git a/package.json b/package.json index 0e710d49..80a8f09e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nami-sdk", - "version": "3.0.29", + "version": "3.0.30", "description": "React Native Module for Nami - Easy subscriptions & in-app purchases, with powerful built-in paywalls and A/B testing.", "main": "index.ts", "types": "index.d.ts", diff --git a/react-native-nami-sdk.podspec b/react-native-nami-sdk.podspec index 4cef317e..4db49625 100644 --- a/react-native-nami-sdk.podspec +++ b/react-native-nami-sdk.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,swift}" s.requires_arc = true - s.dependency 'Nami', '3.1.4' + s.dependency 'Nami', '3.1.6' s.dependency 'React' end diff --git a/src/NamiEntitlementManager.d.ts b/src/NamiEntitlementManager.d.ts index cd901c02..f55c52cf 100644 --- a/src/NamiEntitlementManager.d.ts +++ b/src/NamiEntitlementManager.d.ts @@ -10,6 +10,7 @@ export const NamiEntitlementManager: { registerActiveEntitlementsHandler: ( callback: (activeEntitlements: NamiEntitlement[]) => void, ) => EmitterSubscription['remove']; + clearProvisionalEntitlementGrants: () => void; }; export type NamiEntitlement = { diff --git a/src/NamiEntitlementManager.ts b/src/NamiEntitlementManager.ts index 456e0429..08a9a44e 100644 --- a/src/NamiEntitlementManager.ts +++ b/src/NamiEntitlementManager.ts @@ -22,6 +22,7 @@ export interface INamiEntitlementManager { registerActiveEntitlementsHandler: ( callback: (activeEntitlements: NamiEntitlement[]) => void, ) => EmitterSubscription['remove']; + clearProvisionalEntitlementGrants: () => void; } export const NamiEntitlementManager: INamiEntitlementManager = { diff --git a/src/NamiPaywallManager.d.ts b/src/NamiPaywallManager.d.ts index 378738e2..c20b3dd3 100644 --- a/src/NamiPaywallManager.d.ts +++ b/src/NamiPaywallManager.d.ts @@ -20,6 +20,7 @@ export const NamiPaywallManager: { ) => EmitterSubscription['remove']; show: () => void; hide: () => void; + buySkuCancel: () => void; isHidden: () => Promise; }; diff --git a/src/NamiPaywallManager.ts b/src/NamiPaywallManager.ts index bd704236..b8b185bb 100644 --- a/src/NamiPaywallManager.ts +++ b/src/NamiPaywallManager.ts @@ -65,6 +65,9 @@ export const NamiPaywallManager: INamiPaywallManager = { ServicesEnum.GooglePlay, ); }, + buySkuCancel: () => { + RNNamiPaywallManager.buySkuCancel(); + }, registerBuySkuHandler: (callback: (sku: NamiSKU) => void) => { let subscription; subscription = NamiPaywallManager.paywallEmitter.addListener(