Skip to content

Commit

Permalink
Merge branch 'main' into feat/leverage-sdk-compability
Browse files Browse the repository at this point in the history
# Conflicts:
#	examples/Basic/src/containers/EntitlementsScreen.tsx
  • Loading branch information
bataevvlad committed Aug 30, 2023
2 parents c87eec8 + cba039f commit 0ac3066
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 16 deletions.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
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.29")
val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.30")
namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
settingsList.addAll(commandsFromReact)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class NamiEntitlementManagerBridgeModule(reactContext: ReactApplicationContext)
}
}

@ReactMethod
fun clearProvisionalEntitlementGrants() {
NamiEntitlementManager.clearProvisionalEntitlementGrants()
}

@ReactMethod
fun addListener(eventName: String?) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
promise.resolve(false)
}

@ReactMethod
fun buySkuCancel() {
NamiPaywallManager.buySkuCancel()
}

@ReactMethod
fun addListener(eventName: String?) {
}
Expand Down
2 changes: 2 additions & 0 deletions examples/Basic/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
</network-security-config>
10 changes: 8 additions & 2 deletions examples/Basic/src/containers/CampaignScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ const HeaderRight = ({ onRefreshPress }: {onRefreshPress: () => void}) => (
// For Nami testing purposes only
const HeaderLeft = ({ onButtonPress }: {onButtonPress: () => void}) => (
<TouchableOpacity
style={styles.headerButton}
style={styles.headerButtonLeft}
onPress={onButtonPress}>
<Text
testID="show_paywall_button"
style={styles.headerButtonText}>
Show Paywall
Show
</Text>
</TouchableOpacity>
);
Expand Down Expand Up @@ -362,6 +362,12 @@ const styles = StyleSheet.create({
justifyContent: 'center',
alignItems: 'center',
},
headerButtonLeft: {
marginLeft: 15,
height: 30,
justifyContent: 'center',
alignItems: 'center',
},
headerButtonText: {
color: theme.links,
fontSize: 16,
Expand Down
23 changes: 23 additions & 0 deletions examples/Basic/src/containers/EntitlementsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const EntitlementsScreen: FC<EntitlementsScreenProps> = ({ navigation }) => {
});
};

const onClearPress = () => {
NamiEntitlementManager.clearProvisionalEntitlementGrants();
};

useEffect(() => {
getAllEntitlements();
const subscriptionRemover =
Expand Down Expand Up @@ -65,6 +69,19 @@ const EntitlementsScreen: FC<EntitlementsScreenProps> = ({ navigation }) => {
</TouchableOpacity>
);
},
headerLeft: () => {
return (
<TouchableOpacity
style={styles.headerLeftButton}
onPress={onClearPress}>
<Text
testID="clear_entitlements"
style={styles.headerButtonText}>
Clear
</Text>
</TouchableOpacity>
);
},
});
}, [navigation]);

Expand Down Expand Up @@ -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,
Expand Down
9 changes: 3 additions & 6 deletions examples/TestNamiTV/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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/"}
}
}
}

Expand All @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions examples/TestNamiTV/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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/"}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ console.log('configDict', configDict);
const Root = () => {
const [isConfigurationComplete, setIsConfigurationComplete] = useState();
useEffect(() => {
Nami.configure(configDict, (resultObject: any) => {
Nami.configure(configDict, (resultObject) => {
setIsConfigurationComplete(resultObject.success);
});
// eslint-disable-next-line @typescript-eslint/no-empty-function
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.29"]];
NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.30"]];

// Add additional namiCommands app may have sent in.
NSObject *appCommandStrings = configDict[@"namiCommands"];
Expand Down
2 changes: 2 additions & 0 deletions ios/NamiEntitlementManagerBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ @interface RCT_EXTERN_MODULE(RNNamiEntitlementManager, NSObject)

RCT_EXTERN_METHOD(registerActiveEntitlementsHandler)

RCT_EXTERN_METHOD(clearProvisionalEntitlementGrants)

+ (BOOL)requiresMainQueueSetup {
return YES;
}
Expand Down
6 changes: 6 additions & 0 deletions ios/NamiEntitlementManagerBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class RNNamiEntitlementManager: RCTEventEmitter {
let dictionary = RNNamiPurchaseManager.skuToSKUDict(sku)
return dictionary
}

let dictionary: [String: Any?] = [
"name": entitlement.name,
"desc": entitlement.desc,
Expand Down Expand Up @@ -78,4 +79,9 @@ class RNNamiEntitlementManager: RCTEventEmitter {
RNNamiEntitlementManager.shared?.sendEvent(withName: "EntitlementsChanged", body: dictionaries)
}
}

@objc(clearProvisionalEntitlementGrants)
func clearProvisionalEntitlementGrants() {
NamiEntitlementManager.clearProvisionalEntitlementGrants()
}
}
2 changes: 2 additions & 0 deletions ios/NamiPaywallManagerBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions ios/NamiPaywallManagerBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": "lib/commonjs/index.js",
"module": "lib/module/index.js",
Expand Down
2 changes: 1 addition & 1 deletion react-native-nami-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/core/NamiEntitlementManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type NamiEntitlementManager = {
registerActiveEntitlementsHandler: (
callback: (activeEntitlements: NamiEntitlement[]) => void
) => EmitterSubscription['remove'];
clearProvisionalEntitlementGrants: () => void;
};

export type NamiEntitlement = {
Expand Down
1 change: 1 addition & 0 deletions src/core/NamiEntitlementManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface INamiEntitlementManager {
registerActiveEntitlementsHandler: (
callback: (activeEntitlements: NamiEntitlement[]) => void
) => EmitterSubscription['remove'];
clearProvisionalEntitlementGrants: () => void;
}

export const NamiEntitlementManager: INamiEntitlementManager = {
Expand Down
1 change: 1 addition & 0 deletions src/core/NamiPaywallManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type NamiPaywallManager = {
) => EmitterSubscription['remove'];
show: () => void;
hide: () => void;
buySkuCancel: () => void;
isHidden: () => Promise<boolean>;
};

Expand Down
3 changes: 3 additions & 0 deletions src/core/NamiPaywallManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export const NamiPaywallManager: INamiPaywallManager = {
ServicesEnum.GooglePlay
);
},
buySkuCancel: () => {
RNNamiPaywallManager.buySkuCancel();
},
registerBuySkuHandler: (callback: (sku: NamiSKU) => void) => {
let subscription: EmitterSubscription;
subscription = NamiPaywallManager.paywallEmitter.addListener(
Expand Down

0 comments on commit 0ac3066

Please sign in to comment.