From e8e5a752df8f05ee9972adf2dbb9efcb5da01e18 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 26 Sep 2023 17:59:29 -0600 Subject: [PATCH 1/7] improvements to configure and dependency updates --- android/build.gradle | 2 +- .../com/nami/reactlibrary/NamiBridgeModule.kt | 33 ++++++++----------- .../nami/reactlibrary/NamiBridgePackage.java | 1 + .../reactlibrary/NamiCampaignManagerBridge.kt | 1 + .../nami/reactlibrary/NamiManagerBridge.kt | 28 ++++++++++++++++ .../NamiPaywallManagerBridgeModule.kt | 6 ++++ examples/Basic/android/app/build.gradle | 12 +++++-- examples/Basic/config/getInitialConfig.ts | 2 +- examples/TestNamiTV/android/app/build.gradle | 4 +-- index.d.ts | 1 + index.ts | 1 + ios/Nami.m | 24 ++++++++------ ios/NamiManager.m | 18 ++++++++++ ios/NamiManager.swift | 30 +++++++++++++++++ ios/NamiPaywallManagerBridge.m | 2 ++ ios/NamiPaywallManagerBridge.swift | 8 +++++ package.json | 2 +- react-native-nami-sdk.podspec | 2 +- src/Nami.ts | 2 +- src/NamiCustomerManager.d.ts | 15 +-------- src/NamiManager.d.ts | 3 ++ src/NamiManager.ts | 14 ++++++++ src/NamiPaywallManager.d.ts | 1 + src/NamiPaywallManager.ts | 4 +++ src/types.ts | 15 +++++++-- tsconfig.json | 2 +- 26 files changed, 177 insertions(+), 56 deletions(-) create mode 100644 android/src/main/java/com/nami/reactlibrary/NamiManagerBridge.kt create mode 100644 ios/NamiManager.m create mode 100644 ios/NamiManager.swift create mode 100644 src/NamiManager.d.ts create mode 100644 src/NamiManager.ts diff --git a/android/build.gradle b/android/build.gradle index 05222a2f..358ab315 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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.10" + compileOnly "com.namiml:sdk-amazon:3.1.13-rc.01" 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 695e015b..7e67a1ff 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt @@ -10,6 +10,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule import com.facebook.react.bridge.ReactMethod import com.facebook.react.bridge.ReadableArray import com.facebook.react.bridge.ReadableMap +import com.facebook.react.bridge.Promise import com.namiml.Nami import com.namiml.NamiConfiguration import com.namiml.NamiLanguageCode @@ -44,15 +45,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) : } val appContext: Context = reactApplicationContext.applicationContext - Log.i(LOG_TAG, "Configure called with appID $appPlatformID") - Log.i(LOG_TAG, "Configure called with context $reactApplicationContext") - Log.i(LOG_TAG, "Nami Configure called with context.applicationContext $appContext") - - val isApplication: Boolean = (appContext is Application) - Log.i(LOG_TAG, "Configure called with (context as Application) $isApplication.") - Log.i(LOG_TAG, "End Application check ") - - // Application fred = (reactContext as Application); + Log.d(LOG_TAG, "NAMI: RN Bridge - Configure called with appPlatformID $appPlatformID") val builder: NamiConfiguration.Builder = NamiConfiguration.Builder(appContext, appPlatformID) @@ -78,15 +71,15 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) : builder.logLevel(NamiLogLevel.DEBUG) } } - Log.i(LOG_TAG, "Nami Configuration log level passed in is $logLevelString") + Log.d(LOG_TAG, "NAMI: RN Bridge - configuration log level is $logLevelString") val developmentMode = if (configDict.hasKey(CONFIG_MAP_DEVELOPMENT_MODE_KEY)) { configDict.getBoolean(CONFIG_MAP_DEVELOPMENT_MODE_KEY) } else { false } - Log.i(LOG_TAG, "Nami Configuration developmentMode is $developmentMode") if (developmentMode) { + Log.d(LOG_TAG, "NAMI: RN Bridge - development mode is $developmentMode") builder.developmentMode = true } @@ -115,11 +108,11 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) : } else { Arguments.createArray() } - val settingsList = mutableListOf("extendedClientInfo:react-native:3.1.10") + val settingsList = mutableListOf("extendedClientInfo:react-native:3.1.11") namiCommandsReact?.toArrayList()?.filterIsInstance()?.let { commandsFromReact -> settingsList.addAll(commandsFromReact) } - Log.i(LOG_TAG, "Nami Configuration command settings are $settingsList") + Log.d(LOG_TAG, "Nami Configuration command settings are $settingsList") builder.settingsList = settingsList val initialConfig = if (configDict.hasKey(CONFIG_MAP_INITIAL_CONFIG_KEY)) { @@ -128,7 +121,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) : null } initialConfig?.let { initialConfigString -> - Log.i( + Log.d( LOG_TAG, "Nami Configuration initialConfig found.", ) @@ -136,14 +129,16 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) : } val builtConfig: NamiConfiguration = builder.build() - Log.i(LOG_TAG, "Nami Configuration object is $builtConfig") + Log.d(LOG_TAG, "Nami Configuration object is $builtConfig") reactApplicationContext.runOnUiQueueThread { + // Configure must be called on main thread - Nami.configure(builtConfig) - val resultMap = Arguments.createMap() - resultMap.putBoolean("success", true) - completion.invoke(resultMap) + Nami.configure(builtConfig) { result -> + val resultMap = Arguments.createMap() + resultMap.putBoolean("success", result) + completion.invoke(resultMap) + } } } } diff --git a/android/src/main/java/com/nami/reactlibrary/NamiBridgePackage.java b/android/src/main/java/com/nami/reactlibrary/NamiBridgePackage.java index 2194ecb4..2a2d3f3e 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiBridgePackage.java +++ b/android/src/main/java/com/nami/reactlibrary/NamiBridgePackage.java @@ -24,6 +24,7 @@ public List createNativeModules(@NotNull ReactApplicationContext r moduleList.add(new NamiPurchaseManagerBridgeModule(reactContext)); moduleList.add(new NamiEntitlementManagerBridgeModule(reactContext)); moduleList.add(new NamiMLManagerBridgeModule(reactContext)); + moduleList.add(new NamiManagerBridgeModule(reactContext)); moduleList.add(new NamiCustomerManagerBridgeModule(reactContext)); moduleList.add(new NamiCampaignManagerBridgeModule(reactContext)); diff --git a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt index c6fa3826..04836c65 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt @@ -156,6 +156,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : putString(EXTERNAL_SEGMENT_ID, paywallEvent.externalSegmentId ?: "") putString(DEEP_LINK_URL, paywallEvent.deeplinkUrl ?: "") } + Log.d(LOG_TAG, "Paywall event being emitted - $resultMap") emitEvent(_RESULT_CAMPAIGN, resultMap) } diff --git a/android/src/main/java/com/nami/reactlibrary/NamiManagerBridge.kt b/android/src/main/java/com/nami/reactlibrary/NamiManagerBridge.kt new file mode 100644 index 00000000..26a40f3c --- /dev/null +++ b/android/src/main/java/com/nami/reactlibrary/NamiManagerBridge.kt @@ -0,0 +1,28 @@ +package com.nami.reactlibrary + +import android.util.Log +import com.facebook.react.bridge.* +import com.facebook.react.modules.core.DeviceEventManagerModule +import com.namiml.Nami + +class NamiManagerBridgeModule(reactContext: ReactApplicationContext) : + ReactContextBaseJavaModule(reactContext) { + + override fun getName(): String { + return "RNNamiManager" + } + + @ReactMethod + fun sdkConfigured(promise: Promise) { + val sdkConfigured = Nami.isInitialized() + promise.resolve(sdkConfigured) + } + + @ReactMethod + fun addListener(eventName: String?) { + } + + @ReactMethod + fun removeListeners(count: Int?) { + } +} diff --git a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt index 24eb5668..b914f575 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt @@ -239,6 +239,12 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) : promise.resolve(false) } + @ReactMethod + fun isPaywallOpen(promise: Promise) { + val paywallOpen = NamiPaywallManager.isPaywallOpen() + promise.resolve(paywallOpen) + } + @ReactMethod fun buySkuCancel() { NamiPaywallManager.buySkuCancel() diff --git a/examples/Basic/android/app/build.gradle b/examples/Basic/android/app/build.gradle index b96d29a4..e240ebae 100644 --- a/examples/Basic/android/app/build.gradle +++ b/examples/Basic/android/app/build.gradle @@ -126,6 +126,10 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } + lintOptions { + checkReleaseBuilds false + } + defaultConfig { applicationId "com.namiml.stg.testreactnative" minSdkVersion 26 @@ -177,6 +181,7 @@ android { storePassword 'android' keyAlias 'androidreleasekey' keyPassword 'android' + v2SigningEnabled true } } buildTypes { @@ -186,8 +191,9 @@ android { release { // Caution! In production, you need to generate your own keystore file. // see https://facebook.github.io/react-native/docs/signed-apk-android. - signingConfig null - minifyEnabled enableProguardInReleaseBuilds + signingConfig signingConfigs.release + minifyEnabled true + shrinkResources = true proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" } @@ -218,7 +224,7 @@ 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.10" + implementation "com.namiml:sdk-android:3.1.13-rc.01" implementation project(':react-native-screens') diff --git a/examples/Basic/config/getInitialConfig.ts b/examples/Basic/config/getInitialConfig.ts index 2007753d..f6703e05 100644 --- a/examples/Basic/config/getInitialConfig.ts +++ b/examples/Basic/config/getInitialConfig.ts @@ -17,7 +17,7 @@ export const getInitialConfig = () => { ); case 'ios': return JSON.stringify( - flavor !== 'production' + flavor === 'production' ? initAppleProductionConfig : initAppleStageConfig, ); diff --git a/examples/TestNamiTV/android/app/build.gradle b/examples/TestNamiTV/android/app/build.gradle index 9bbefc79..5d2e2d53 100644 --- a/examples/TestNamiTV/android/app/build.gradle +++ b/examples/TestNamiTV/android/app/build.gradle @@ -227,8 +227,8 @@ 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.10" - playImplementation "com.namiml:sdk-android:3.1.10" + amazonImplementation "com.namiml:sdk-amazon::3.1.13-rc.01" + playImplementation "com.namiml:sdk-android::3.1.13-rc.01" if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; diff --git a/index.d.ts b/index.d.ts index 949b52b4..2123350f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,6 +3,7 @@ export { NamiMLManager } from './src/NamiMLManager'; export { NamiCampaignManager } from './src/NamiCampaignManager'; export { NamiCustomerManager } from './src/NamiCustomerManager'; export { NamiEntitlementManager } from './src/NamiEntitlementManager'; +export { NamiManager } from './src/NamiManager'; export { NamiPurchaseManager } from './src/NamiPurchaseManager'; export { NamiPaywallManager } from './src/NamiPaywallManager'; export * from './src/types'; diff --git a/index.ts b/index.ts index 949b52b4..2123350f 100644 --- a/index.ts +++ b/index.ts @@ -3,6 +3,7 @@ export { NamiMLManager } from './src/NamiMLManager'; export { NamiCampaignManager } from './src/NamiCampaignManager'; export { NamiCustomerManager } from './src/NamiCustomerManager'; export { NamiEntitlementManager } from './src/NamiEntitlementManager'; +export { NamiManager } from './src/NamiManager'; export { NamiPurchaseManager } from './src/NamiPurchaseManager'; export { NamiPaywallManager } from './src/NamiPaywallManager'; export * from './src/types'; diff --git a/ios/Nami.m b/ios/Nami.m index 95aaa2ef..099cf61d 100644 --- a/ios/Nami.m +++ b/ios/Nami.m @@ -20,13 +20,11 @@ @interface NamiBridge : NSObject @implementation NamiBridge (RCTExternModule) RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict completion: (RCTResponseSenderBlock) completion) { - if ([configDict count] == 0 || [configDict[@"logLevel"] isEqual: @"DEBUG"] ) { - NSLog(@"Configure dictionary is %@", configDict); - } NSString *appID = configDict[@"appPlatformID-apple"]; if ([appID length] > 0 ) { NamiConfiguration *config = [NamiConfiguration configurationForAppPlatformId:appID]; + NSLog(@"NAMI: RN Bridge - appPlatformId: %@", appID); NSString *logLevelString = configDict[@"logLevel"]; if ([logLevelString isEqualToString:@"ERROR" ]) { @@ -42,7 +40,7 @@ @implementation NamiBridge (RCTExternModule) NSString *languageString = configDict[@"namiLanguageCode"]; if ([languageString length] > 0) { - NSLog(@"Nami language code from config dictionary is %@", languageString); + NSLog(@"NAMI: RN Bridge - language code: %@", languageString); if ([[NamiLanguageCodes allAvailableNamiLanguageCodes] containsObject:[languageString lowercaseString]] ) { config.namiLanguageCode = languageString; @@ -52,12 +50,12 @@ @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.1.10"]]; + NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.1.11"]]; // Add additional namiCommands app may have sent in. NSObject *appCommandStrings = configDict[@"namiCommands"]; if ( appCommandStrings != NULL ) { - NSLog(@"NamiCommand from dictionary is %@", configDict[@"namiCommands"]); + NSLog(@"NAMI: RN Bridge - additional config settings %@", configDict[@"namiCommands"]); if ([appCommandStrings isKindOfClass:[NSArray class]] ) { for (NSObject *commandObj in ((NSArray *)appCommandStrings)){ if ([commandObj isKindOfClass:[NSString class]]) { @@ -71,13 +69,19 @@ @implementation NamiBridge (RCTExternModule) NSString *initialConfigString = configDict[@"initialConfig"]; if ([initialConfigString length] > 0) { - NSLog(@"Found an initialConfig file to use for Nami SDK setup."); + NSLog(@"NAMI: RN Bridge - Found an initialConfig file to use for Nami SDK setup."); config.initialConfig = initialConfigString; } - [Nami configureWith:config]; - NSDictionary *dict = @{@"success": @YES}; - completion(@[dict]); + [Nami configureWith:config :^(BOOL sdkConfigured) { + if ( sdkConfigured == YES ) { + NSDictionary *dict = @{@"success": @YES}; + completion(@[dict]); + } else { + NSDictionary *dict = @{@"success": @NO}; + completion(@[dict]); + } + }]; } } diff --git a/ios/NamiManager.m b/ios/NamiManager.m new file mode 100644 index 00000000..a06e5324 --- /dev/null +++ b/ios/NamiManager.m @@ -0,0 +1,18 @@ +// +// NamiManager.m +// RNNami +// +// Copyright © 2020-2023 Nami ML Inc. All rights reserved. +// + +#import + +@interface RCT_EXTERN_MODULE(RNNamiManager, NSObject) + +RCT_EXTERN_METHOD(sdkConfigured:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) + ++ (BOOL)requiresMainQueueSetup { + return YES; +} + +@end diff --git a/ios/NamiManager.swift b/ios/NamiManager.swift new file mode 100644 index 00000000..3709031c --- /dev/null +++ b/ios/NamiManager.swift @@ -0,0 +1,30 @@ +// +// NamiManager.swift +// RNNami +// +// Copyright © 2023 Nami ML INc.. All rights reserved. +// + +import Foundation +import NamiApple +import React + +@objc(RNNamiManager) +class RNNamiManager: RCTEventEmitter { + public static var shared: RNNamiManager? + + override init() { + super.init() + RNNamiManager.shared = self + } + + override func supportedEvents() -> [String]! { + return [] + } + + @objc(sdkConfigured:rejecter:) + func sdkConfigured(resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) { + let sdkConfigured = Nami.sdkConfigured() + resolve(sdkConfigured) + } +} diff --git a/ios/NamiPaywallManagerBridge.m b/ios/NamiPaywallManagerBridge.m index b79315d1..26dae537 100644 --- a/ios/NamiPaywallManagerBridge.m +++ b/ios/NamiPaywallManagerBridge.m @@ -35,6 +35,8 @@ @interface RCT_EXTERN_MODULE(RNNamiPaywallManager, NSObject) RCT_EXTERN_METHOD(isHidden:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) +RCT_EXTERN_METHOD(isPaywallOpen:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) + RCT_EXTERN_METHOD(buySkuCancel) + (BOOL)requiresMainQueueSetup { diff --git a/ios/NamiPaywallManagerBridge.swift b/ios/NamiPaywallManagerBridge.swift index f010f2b9..780f1cda 100644 --- a/ios/NamiPaywallManagerBridge.swift +++ b/ios/NamiPaywallManagerBridge.swift @@ -151,4 +151,12 @@ class RNNamiPaywallManager: RCTEventEmitter { resolve(isHidden) } } + + @objc(isPaywallOpen:rejecter:) + func isPaywallOpen(resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) { + DispatchQueue.main.async { + let isPaywallOpen = NamiPaywallManager.isPaywallOpen() + resolve(isPaywallOpen) + } + } } diff --git a/package.json b/package.json index 5572ee2f..dceb02cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nami-sdk", - "version": "3.1.10", + "version": "3.1.11", "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 9825869b..c92d409e 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.10' + s.dependency 'Nami', '3.1.12' s.dependency 'React' end diff --git a/src/Nami.ts b/src/Nami.ts index 98d1b68f..613a6e49 100644 --- a/src/Nami.ts +++ b/src/Nami.ts @@ -1,7 +1,7 @@ import { NativeModules } from 'react-native'; import { NamiConfiguration } from './types'; -export const { NamiBridge } = NativeModules; +export const { NamiBridge, NamiManager } = NativeModules; export interface INami { configure: ( diff --git a/src/NamiCustomerManager.d.ts b/src/NamiCustomerManager.d.ts index 67dbee5f..7d15c0d8 100644 --- a/src/NamiCustomerManager.d.ts +++ b/src/NamiCustomerManager.d.ts @@ -1,4 +1,5 @@ import { EmitterSubscription } from 'react-native'; +import { AccountStateAction } from './types'; export const NamiCustomerManager: { setCustomerAttribute: (key: string, value: string) => void; @@ -36,17 +37,3 @@ export type CustomerJourneyState = { inPause: boolean; inAccountHold: boolean; }; - -export type AccountStateAction = - | 'login' - | 'logout' - | 'advertising_id_set' - | 'vendor_id_set' - | 'customer_data_platform_id_set' - | 'nami_device_id_set' - | 'advertising_id_cleared' - | 'vendor_id_cleared' - | 'customer_data_platform_id_cleared' - | 'nami_device_id_cleared' - | 'anonymous_mode_on' - | 'anonymous_mode_off'; diff --git a/src/NamiManager.d.ts b/src/NamiManager.d.ts new file mode 100644 index 00000000..c837c3c1 --- /dev/null +++ b/src/NamiManager.d.ts @@ -0,0 +1,3 @@ +export const NamiManager: { + sdkConfigured: () => Promise; +}; diff --git a/src/NamiManager.ts b/src/NamiManager.ts new file mode 100644 index 00000000..a5c27be2 --- /dev/null +++ b/src/NamiManager.ts @@ -0,0 +1,14 @@ +import { NativeModules } from 'react-native'; + +export const { RNNamiManager } = NativeModules; + +export interface INamiManager { + sdkConfigured: () => Promise; +} + +export const NamiManager: INamiManager = { + ...RNNamiManager, + sdkConfigured: () => { + return RNNamiManager.sdkConfigured(); + }, +}; diff --git a/src/NamiPaywallManager.d.ts b/src/NamiPaywallManager.d.ts index 210405b3..86dfb896 100644 --- a/src/NamiPaywallManager.d.ts +++ b/src/NamiPaywallManager.d.ts @@ -25,6 +25,7 @@ export const NamiPaywallManager: { hide: () => void; buySkuCancel: () => void; isHidden: () => Promise; + isPaywallOpen: () => Promise; }; export type NamiPurchaseSuccessApple = { diff --git a/src/NamiPaywallManager.ts b/src/NamiPaywallManager.ts index fd554608..fa3003bc 100644 --- a/src/NamiPaywallManager.ts +++ b/src/NamiPaywallManager.ts @@ -48,6 +48,7 @@ export interface INamiPaywallManager { show: () => void; hide: () => void; isHidden: () => Promise; + isPaywallOpen: () => Promise; } const { NamiPaywallManagerBridge, RNNamiPaywallManager } = NativeModules; @@ -156,4 +157,7 @@ export const NamiPaywallManager: INamiPaywallManager = { isHidden: () => { return RNNamiPaywallManager.isHidden(); }, + isPaywallOpen: () => { + return RNNamiPaywallManager.isPaywallOpen(); + }, }; diff --git a/src/types.ts b/src/types.ts index 2de19ef4..bbf57368 100644 --- a/src/types.ts +++ b/src/types.ts @@ -193,7 +193,6 @@ export type PaywallLaunchContext = { }; }; -// NamiCustomerManager export type CustomerJourneyState = { formerSubscriber: boolean; inGracePeriod: boolean; @@ -204,7 +203,19 @@ export type CustomerJourneyState = { inAccountHold: boolean; }; -export type AccountStateAction = 'login' | 'logout'; +export type AccountStateAction = + | 'login' + | 'logout' + | 'advertising_id_set' + | 'vendor_id_set' + | 'customer_data_platform_id_set' + | 'nami_device_id_set' + | 'advertising_id_cleared' + | 'vendor_id_cleared' + | 'customer_data_platform_id_cleared' + | 'nami_device_id_cleared' + | 'anonymous_mode_on' + | 'anonymous_mode_off'; // NamiEntitlementManager export type NamiEntitlement = { diff --git a/tsconfig.json b/tsconfig.json index 6fa1d9f7..152f95e6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ // "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "dist", /* Redirect output structure to the directory. */ - "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "removeComments": true, /* Do not emit comments to output. */ "noEmit": true, /* Do not emit outputs. */ // "incremental": true, /* Enable incremental compilation */ From 8c13c62bcdf2e73bdb64d7ea0cfcf0d744d14d98 Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Tue, 26 Sep 2023 18:12:43 -0600 Subject: [PATCH 2/7] Update build.gradle --- examples/Basic/android/app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Basic/android/app/build.gradle b/examples/Basic/android/app/build.gradle index e240ebae..7bb5a9cb 100644 --- a/examples/Basic/android/app/build.gradle +++ b/examples/Basic/android/app/build.gradle @@ -191,8 +191,8 @@ android { release { // Caution! In production, you need to generate your own keystore file. // see https://facebook.github.io/react-native/docs/signed-apk-android. - signingConfig signingConfigs.release - minifyEnabled true + signingConfig null + minifyEnabled true shrinkResources = true proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" From b6a927b24e799d74f51a1091abfd5226cbb8a7f9 Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Wed, 27 Sep 2023 08:24:18 -0600 Subject: [PATCH 3/7] Update tsconfig.json --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 152f95e6..6fa1d9f7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ // "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "dist", /* Redirect output structure to the directory. */ - "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "removeComments": true, /* Do not emit comments to output. */ "noEmit": true, /* Do not emit outputs. */ // "incremental": true, /* Enable incremental compilation */ From 607cff443a34508511c7f4a9eb99cea8e33253da Mon Sep 17 00:00:00 2001 From: dannami Date: Wed, 27 Sep 2023 09:01:37 -0600 Subject: [PATCH 4/7] update sample add and android release --- android/build.gradle | 2 +- .../reactlibrary/NamiCampaignManagerBridge.kt | 2 -- examples/Basic/App.tsx | 1 - examples/Basic/android/app/build.gradle | 10 +++++----- examples/Basic/config/index.ts | 4 ++-- examples/Basic/containers/CampaignScreen.tsx | 10 ++++++++++ examples/Basic/containers/ProfileScreen.tsx | 3 +++ examples/Basic/index.js | 19 +++++++++++++++++-- examples/TestNamiTV/android/app/build.gradle | 4 ++-- 9 files changed, 40 insertions(+), 15 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 358ab315..c9a33042 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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.13-rc.01" + compileOnly "com.namiml:sdk-amazon:3.1.13" 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/NamiCampaignManagerBridge.kt b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt index 04836c65..2cc47715 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt @@ -156,8 +156,6 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : putString(EXTERNAL_SEGMENT_ID, paywallEvent.externalSegmentId ?: "") putString(DEEP_LINK_URL, paywallEvent.deeplinkUrl ?: "") } - Log.d(LOG_TAG, "Paywall event being emitted - $resultMap") - emitEvent(_RESULT_CAMPAIGN, resultMap) } diff --git a/examples/Basic/App.tsx b/examples/Basic/App.tsx index 31785547..7e6117e2 100644 --- a/examples/Basic/App.tsx +++ b/examples/Basic/App.tsx @@ -93,7 +93,6 @@ const App = () => { }, ); - NamiCustomerManager.setCustomerDataPlatformId('2135'); return () => { subscriptionRemover(); }; diff --git a/examples/Basic/android/app/build.gradle b/examples/Basic/android/app/build.gradle index 7bb5a9cb..d2be7ad1 100644 --- a/examples/Basic/android/app/build.gradle +++ b/examples/Basic/android/app/build.gradle @@ -177,10 +177,10 @@ android { keyPassword 'android' } release { - storeFile file('release.keystore') - storePassword 'android' - keyAlias 'androidreleasekey' - keyPassword 'android' + storeFile file('/Users/dannami/Nami/SigningKeys/GooglePlay/release.keystore') + storePassword 'kyFYiLg7QVe78QaEg' + keyAlias 'namirelease' + keyPassword 'kyFYiLg7QVe78QaEg' v2SigningEnabled true } } @@ -224,7 +224,7 @@ 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.13-rc.01" + implementation "com.namiml:sdk-android:3.1.13" implementation project(':react-native-screens') diff --git a/examples/Basic/config/index.ts b/examples/Basic/config/index.ts index 65c31506..d022a9d2 100644 --- a/examples/Basic/config/index.ts +++ b/examples/Basic/config/index.ts @@ -7,8 +7,8 @@ export function getConfigObject() { switch (flavor) { case 'staging': return { - 'appPlatformID-apple': 'APPLE_STG_APP_PLATFORM_ID', - 'appPlatformID-android': 'ANDROID_STG_APP_PLATFORM_ID', + 'appPlatformID-apple': '4a2f6dbf-e684-4d65-a4df-0488771c577d', + 'appPlatformID-android': 'b7232eba-ff1d-4b7f-b8d0-55593b66c1d5', logLevel: 'DEBUG', namiCommands: ['useStagingAPI', 'useNamiWindow'], initialConfig: getInitialConfig(), diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index e16633fc..44417596 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -56,6 +56,11 @@ const CampaignScreen: FC = ({ navigation }) => { 'INITIAL', ); + const checkIfPaywallOpen = async () => { + const isOpen = await NamiPaywallManager.isPaywallOpen(); + console.log('NamiSDK: paywall open? ', isOpen); +}; + const showPaywallIfHidden = async () => { try { const isHidden = await NamiPaywallManager.isHidden() @@ -129,6 +134,8 @@ const CampaignScreen: FC = ({ navigation }) => { }, []); const triggerLaunch = (label?: any, url?: any) => { + checkIfPaywallOpen(); + return NamiCampaignManager.launch( label, url, @@ -136,6 +143,9 @@ const CampaignScreen: FC = ({ navigation }) => { (successAction, error) => { console.log('successAction', successAction); console.log('error', error); + + checkIfPaywallOpen(); + }, ( action, diff --git a/examples/Basic/containers/ProfileScreen.tsx b/examples/Basic/containers/ProfileScreen.tsx index 4e2b27d0..4ab75dcc 100644 --- a/examples/Basic/containers/ProfileScreen.tsx +++ b/examples/Basic/containers/ProfileScreen.tsx @@ -153,6 +153,9 @@ const ProfileScreen: FC = ({ navigation }) => { } }, ); + + NamiCustomerManager.setCustomerDataPlatformId('4444'); + return () => { subscriptionJourneyStateRemover(); subscriptionAccountStateRemover(); diff --git a/examples/Basic/index.js b/examples/Basic/index.js index 00d34f31..612d4746 100644 --- a/examples/Basic/index.js +++ b/examples/Basic/index.js @@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react'; import { View } from 'react-native'; import { AppRegistry } from 'react-native'; -import { Nami } from 'react-native-nami-sdk'; +import { Nami, NamiManager } from 'react-native-nami-sdk'; import App from './App'; import { name as appName } from './app.json'; import { getConfigObject } from './config'; @@ -12,14 +12,29 @@ import { getConfigObject } from './config'; const configDict = getConfigObject(); console.log('configDict', configDict); + const Root = () => { const [isConfigurationComplete, setIsConfigurationComplete] = useState(); + + const checkSdkConfigured = async () => { + const configured = await NamiManager.sdkConfigured(); + console.log('NamiSDK: configured', configured); + }; + useEffect(() => { + + checkSdkConfigured(); + Nami.configure(configDict, (resultObject) => { - setIsConfigurationComplete(resultObject.success); + setIsConfigurationComplete(true); + checkSdkConfigured(); + }); + // eslint-disable-next-line @typescript-eslint/no-empty-function return () => {}; + + }, []); return isConfigurationComplete ? : ; diff --git a/examples/TestNamiTV/android/app/build.gradle b/examples/TestNamiTV/android/app/build.gradle index 5d2e2d53..4123f38b 100644 --- a/examples/TestNamiTV/android/app/build.gradle +++ b/examples/TestNamiTV/android/app/build.gradle @@ -227,8 +227,8 @@ 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.13-rc.01" - playImplementation "com.namiml:sdk-android::3.1.13-rc.01" + amazonImplementation "com.namiml:sdk-amazon::3.1.13" + playImplementation "com.namiml:sdk-android::3.1.13" if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; From 8f9e25a5ccaeb5520678d2a7f40c6479c175f9c6 Mon Sep 17 00:00:00 2001 From: dannami Date: Wed, 27 Sep 2023 09:11:45 -0600 Subject: [PATCH 5/7] eslint --- examples/Basic/App.tsx | 2 +- examples/Basic/containers/CampaignScreen.tsx | 2 +- examples/Basic/containers/ProfileScreen.tsx | 2 +- examples/Basic/index.js | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/Basic/App.tsx b/examples/Basic/App.tsx index 7e6117e2..e270c407 100644 --- a/examples/Basic/App.tsx +++ b/examples/Basic/App.tsx @@ -3,7 +3,7 @@ import { Linking, Platform } from 'react-native'; import { NavigationContainer } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; -import { NamiCustomerManager, NamiPaywallManager } from 'react-native-nami-sdk'; +import { NamiPaywallManager } from 'react-native-nami-sdk'; import CampaignScreen from './containers/CampaignScreen'; import ProfileScreen from './containers/ProfileScreen'; diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index 44417596..89866f6d 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -59,7 +59,7 @@ const CampaignScreen: FC = ({ navigation }) => { const checkIfPaywallOpen = async () => { const isOpen = await NamiPaywallManager.isPaywallOpen(); console.log('NamiSDK: paywall open? ', isOpen); -}; + }; const showPaywallIfHidden = async () => { try { diff --git a/examples/Basic/containers/ProfileScreen.tsx b/examples/Basic/containers/ProfileScreen.tsx index 4ab75dcc..258e4e2e 100644 --- a/examples/Basic/containers/ProfileScreen.tsx +++ b/examples/Basic/containers/ProfileScreen.tsx @@ -154,7 +154,7 @@ const ProfileScreen: FC = ({ navigation }) => { }, ); - NamiCustomerManager.setCustomerDataPlatformId('4444'); + NamiCustomerManager.setCustomerDataPlatformId('4444'); return () => { subscriptionJourneyStateRemover(); diff --git a/examples/Basic/index.js b/examples/Basic/index.js index 612d4746..053c518d 100644 --- a/examples/Basic/index.js +++ b/examples/Basic/index.js @@ -17,8 +17,8 @@ const Root = () => { const [isConfigurationComplete, setIsConfigurationComplete] = useState(); const checkSdkConfigured = async () => { - const configured = await NamiManager.sdkConfigured(); - console.log('NamiSDK: configured', configured); + const configured = await NamiManager.sdkConfigured(); + console.log('NamiSDK: configured', configured); }; useEffect(() => { From 7eb6727dcbfadfe11984ae5940d6be9cb5cd2750 Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Wed, 27 Sep 2023 09:14:24 -0600 Subject: [PATCH 6/7] Update index.ts --- examples/Basic/config/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Basic/config/index.ts b/examples/Basic/config/index.ts index d022a9d2..65c31506 100644 --- a/examples/Basic/config/index.ts +++ b/examples/Basic/config/index.ts @@ -7,8 +7,8 @@ export function getConfigObject() { switch (flavor) { case 'staging': return { - 'appPlatformID-apple': '4a2f6dbf-e684-4d65-a4df-0488771c577d', - 'appPlatformID-android': 'b7232eba-ff1d-4b7f-b8d0-55593b66c1d5', + 'appPlatformID-apple': 'APPLE_STG_APP_PLATFORM_ID', + 'appPlatformID-android': 'ANDROID_STG_APP_PLATFORM_ID', logLevel: 'DEBUG', namiCommands: ['useStagingAPI', 'useNamiWindow'], initialConfig: getInitialConfig(), From 278054490c8a284e224e77b54fec1d9f72d6ff2a Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Wed, 27 Sep 2023 09:14:57 -0600 Subject: [PATCH 7/7] Update build.gradle --- examples/Basic/android/app/build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/Basic/android/app/build.gradle b/examples/Basic/android/app/build.gradle index d2be7ad1..bdfd872d 100644 --- a/examples/Basic/android/app/build.gradle +++ b/examples/Basic/android/app/build.gradle @@ -177,10 +177,10 @@ android { keyPassword 'android' } release { - storeFile file('/Users/dannami/Nami/SigningKeys/GooglePlay/release.keystore') - storePassword 'kyFYiLg7QVe78QaEg' - keyAlias 'namirelease' - keyPassword 'kyFYiLg7QVe78QaEg' + storeFile file('release.keystore') + storePassword 'android' + keyAlias 'androidreleasekey' + keyPassword 'android' v2SigningEnabled true } }