Skip to content

Commit

Permalink
3.0.31
Browse files Browse the repository at this point in the history
  • Loading branch information
namidan committed Sep 6, 2023
1 parent cba039f commit cf37cf7
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 13 deletions.
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'
compileOnly "com.namiml:sdk-amazon:3.1.5"
compileOnly "com.namiml:sdk-amazon:3.1.7"

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.30")
val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.31")
namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
settingsList.addAll(commandsFromReact)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,18 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
}
}

@ReactMethod
fun registerDeeplinkActionHandler() {
NamiPaywallManager.registerDeepLinkHandler { activity , url ->
latestPaywallActivity = activity
reactApplicationContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
.emit("PaywallDeeplinkAction", url)
}

}


@ReactMethod
fun show() {
// Do nothing on Android side
Expand Down
7 changes: 7 additions & 0 deletions examples/Basic/containers/CampaignScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ const CampaignScreen: FC<CampaignScreenProps> = ({ navigation }) => {
NamiPaywallManager.dismiss();
});

const subscriptionDeeplinkeRemover =
NamiPaywallManager.registerDeeplinkActionHandler((url) => {
console.log('deeplink action ', url);
NamiPaywallManager.dismiss();
});

const subscriptionRemover =
NamiCampaignManager.registerAvailableCampaignsHandler(
(availableCampaigns) => {
Expand All @@ -108,6 +114,7 @@ const CampaignScreen: FC<CampaignScreenProps> = ({ navigation }) => {
subscriptionRemover();
subscriptionSignInRemover();
subscriptionRestoreRemover();
subscriptionDeeplinkeRemover();
// Clean up the launch subscription when the component unmounts
// For safety reasons
if (NamiCampaignManager.launchSubscription) {
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.30"]];
NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.31"]];

// Add additional namiCommands app may have sent in.
NSObject *appCommandStrings = configDict[@"namiCommands"];
Expand Down
2 changes: 2 additions & 0 deletions ios/NamiCampaignManagerBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class RNNamiCampaignManager: RCTEventEmitter {
actionString = "PURCHASE_SELECTED_SKU"
case .purchase_success:
actionString = "PURCHASE_SUCCESS"
case .purchase_pending:
actionString = "PURCHASE_PENDING"
case .purchase_deferred:
actionString = "PURCHASE_DEFERRED"
case .purchase_failed:
Expand Down
2 changes: 2 additions & 0 deletions ios/NamiPaywallManagerBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ @interface RCT_EXTERN_MODULE(RNNamiPaywallManager, NSObject)

RCT_EXTERN_METHOD(registerRestoreHandler)

RCT_EXTERN_METHOD(registerDeeplinkActionHandler)

RCT_EXTERN_METHOD(dismiss:(BOOL)animated)

RCT_EXTERN_METHOD(show)
Expand Down
7 changes: 7 additions & 0 deletions ios/NamiPaywallManagerBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ class RNNamiPaywallManager: RCTEventEmitter {
}
}

@objc(registerDeeplinkActionHandler)
func registerDeeplinkActionHandler() {
NamiPaywallManager.registerDeeplinkActionHandler { url in
RNNamiPaywallManager.shared?.sendEvent(withName: "PaywallDeeplinkAction", body: url)
}
}

@objc(dismiss:)
func dismiss(animated: Bool) {
NamiPaywallManager.dismiss(animated: animated) {}
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.30",
"version": "3.0.31",
"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",
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.6'
s.dependency 'Nami', '3.1.7'
s.dependency 'React'

end
3 changes: 3 additions & 0 deletions src/NamiPaywallManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const NamiPaywallManager: {
registerRestoreHandler: (
callback: () => void,
) => EmitterSubscription['remove'];
registerDeeplinkActionHandler: (
callback: (url: string) => void,
) => EmitterSubscription['remove'];
show: () => void;
hide: () => void;
buySkuCancel: () => void;
Expand Down
27 changes: 19 additions & 8 deletions src/NamiPaywallManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum NamiPaywallManagerEvents {
PaywallCloseRequested = 'PaywallCloseRequested',
PaywallSignInRequested = 'PaywallSignInRequested',
PaywallRestoreRequested = 'PaywallRestoreRequested',
PaywallDeeplinkAction = 'PaywallDeeplinkAction',
}

export enum ServicesEnum {
Expand Down Expand Up @@ -69,8 +70,7 @@ export const NamiPaywallManager: INamiPaywallManager = {
RNNamiPaywallManager.buySkuCancel();
},
registerBuySkuHandler: (callback: (sku: NamiSKU) => void) => {
let subscription;
subscription = NamiPaywallManager.paywallEmitter.addListener(
let subscription = NamiPaywallManager.paywallEmitter.addListener(
NamiPaywallManagerEvents.RegisterBuySKU,
sku => {
callback(sku);
Expand All @@ -84,8 +84,7 @@ export const NamiPaywallManager: INamiPaywallManager = {
};
},
registerCloseHandler: (callback: (body: any) => void) => {
let subscription;
subscription = NamiPaywallManager.paywallEmitter.addListener(
let subscription = NamiPaywallManager.paywallEmitter.addListener(
NamiPaywallManagerEvents.PaywallCloseRequested,
body => {
callback(body);
Expand All @@ -99,8 +98,7 @@ export const NamiPaywallManager: INamiPaywallManager = {
};
},
registerSignInHandler(callback) {
let subscription;
subscription = NamiPaywallManager.paywallEmitter.addListener(
let subscription = NamiPaywallManager.paywallEmitter.addListener(
NamiPaywallManagerEvents.PaywallSignInRequested,
() => {
callback();
Expand All @@ -115,8 +113,7 @@ export const NamiPaywallManager: INamiPaywallManager = {
};
},
registerRestoreHandler(callback) {
let subscription;
subscription = NamiPaywallManager.paywallEmitter.addListener(
let subscription = NamiPaywallManager.paywallEmitter.addListener(
NamiPaywallManagerEvents.PaywallRestoreRequested,
() => {
callback();
Expand All @@ -129,6 +126,20 @@ export const NamiPaywallManager: INamiPaywallManager = {
}
};
},
registerDeeplinkActionHandler: (callback: (url: string) => void) => {
let subscription = NamiPaywallManager.paywallEmitter.addListener(
NamiPaywallManagerEvents.PaywallDeeplinkAction,
url => {
callback(url);
},
);
RNNamiPaywallManager.registerDeeplinkActionHandler();
return () => {
if (subscription) {
subscription.remove();
}
};
},
dismiss: (animated?: boolean) => {
RNNamiPaywallManager.dismiss(animated ?? true);
},
Expand Down

0 comments on commit cf37cf7

Please sign in to comment.