react-native-nami-sdk 3.1.10 → 3.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,6 +77,12 @@ jobs:
77
77
  env:
78
78
  BASIC_ANDROID_PROD_APP_PLATFORM_ID: '${{ secrets.ANDROID_PROD_APP_PLATFORM_ID }}'
79
79
 
80
+ - name: Manually create the bundle
81
+ run: |
82
+ mkdir -p android/app/src/main/assets/
83
+ npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
84
+ working-directory: source/examples/Basic
85
+
80
86
  - name: Build Android App Bundle
81
87
  run: |
82
88
  ./gradlew clean bundleProductionRelease
@@ -77,6 +77,12 @@ jobs:
77
77
  yarn install
78
78
  working-directory: source/examples/Basic
79
79
 
80
+ - name: Manually create the bundle
81
+ run: |
82
+ mkdir -p android/app/src/main/assets/
83
+ npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
84
+ working-directory: source/examples/Basic
85
+
80
86
  - name: Build Android App Bundle
81
87
  run: |
82
88
  ./gradlew clean bundleStagingRelease
@@ -84,7 +84,7 @@ dependencies {
84
84
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
85
85
 
86
86
  implementation 'com.github.jeziellago:compose-markdown:0.3.0'
87
- compileOnly "com.namiml:sdk-amazon:3.1.10"
87
+ compileOnly "com.namiml:sdk-amazon:3.1.14"
88
88
 
89
89
  implementation 'com.facebook.react:react-native:+' // From node_modules
90
90
  coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
@@ -10,6 +10,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
10
10
  import com.facebook.react.bridge.ReactMethod
11
11
  import com.facebook.react.bridge.ReadableArray
12
12
  import com.facebook.react.bridge.ReadableMap
13
+ import com.facebook.react.bridge.Promise
13
14
  import com.namiml.Nami
14
15
  import com.namiml.NamiConfiguration
15
16
  import com.namiml.NamiLanguageCode
@@ -44,15 +45,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
44
45
  }
45
46
 
46
47
  val appContext: Context = reactApplicationContext.applicationContext
47
- Log.i(LOG_TAG, "Configure called with appID $appPlatformID")
48
- Log.i(LOG_TAG, "Configure called with context $reactApplicationContext")
49
- Log.i(LOG_TAG, "Nami Configure called with context.applicationContext $appContext")
50
-
51
- val isApplication: Boolean = (appContext is Application)
52
- Log.i(LOG_TAG, "Configure called with (context as Application) $isApplication.")
53
- Log.i(LOG_TAG, "End Application check ")
54
-
55
- // Application fred = (reactContext as Application);
48
+ Log.d(LOG_TAG, "NAMI: RN Bridge - Configure called with appPlatformID $appPlatformID")
56
49
 
57
50
  val builder: NamiConfiguration.Builder =
58
51
  NamiConfiguration.Builder(appContext, appPlatformID)
@@ -78,15 +71,15 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
78
71
  builder.logLevel(NamiLogLevel.DEBUG)
79
72
  }
80
73
  }
81
- Log.i(LOG_TAG, "Nami Configuration log level passed in is $logLevelString")
74
+ Log.d(LOG_TAG, "NAMI: RN Bridge - configuration log level is $logLevelString")
82
75
 
83
76
  val developmentMode = if (configDict.hasKey(CONFIG_MAP_DEVELOPMENT_MODE_KEY)) {
84
77
  configDict.getBoolean(CONFIG_MAP_DEVELOPMENT_MODE_KEY)
85
78
  } else {
86
79
  false
87
80
  }
88
- Log.i(LOG_TAG, "Nami Configuration developmentMode is $developmentMode")
89
81
  if (developmentMode) {
82
+ Log.d(LOG_TAG, "NAMI: RN Bridge - development mode is $developmentMode")
90
83
  builder.developmentMode = true
91
84
  }
92
85
 
@@ -115,11 +108,11 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
115
108
  } else {
116
109
  Arguments.createArray()
117
110
  }
118
- val settingsList = mutableListOf("extendedClientInfo:react-native:3.1.10")
111
+ val settingsList = mutableListOf("extendedClientInfo:react-native:3.1.12")
119
112
  namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
120
113
  settingsList.addAll(commandsFromReact)
121
114
  }
122
- Log.i(LOG_TAG, "Nami Configuration command settings are $settingsList")
115
+ Log.d(LOG_TAG, "Nami Configuration command settings are $settingsList")
123
116
  builder.settingsList = settingsList
124
117
 
125
118
  val initialConfig = if (configDict.hasKey(CONFIG_MAP_INITIAL_CONFIG_KEY)) {
@@ -128,7 +121,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
128
121
  null
129
122
  }
130
123
  initialConfig?.let { initialConfigString ->
131
- Log.i(
124
+ Log.d(
132
125
  LOG_TAG,
133
126
  "Nami Configuration initialConfig found.",
134
127
  )
@@ -136,14 +129,16 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
136
129
  }
137
130
 
138
131
  val builtConfig: NamiConfiguration = builder.build()
139
- Log.i(LOG_TAG, "Nami Configuration object is $builtConfig")
132
+ Log.d(LOG_TAG, "Nami Configuration object is $builtConfig")
140
133
 
141
134
  reactApplicationContext.runOnUiQueueThread {
135
+
142
136
  // Configure must be called on main thread
143
- Nami.configure(builtConfig)
144
- val resultMap = Arguments.createMap()
145
- resultMap.putBoolean("success", true)
146
- completion.invoke(resultMap)
137
+ Nami.configure(builtConfig) { result ->
138
+ val resultMap = Arguments.createMap()
139
+ resultMap.putBoolean("success", result)
140
+ completion.invoke(resultMap)
141
+ }
147
142
  }
148
143
  }
149
144
  }
@@ -24,6 +24,7 @@ public class NamiBridgePackage implements ReactPackage {
24
24
  moduleList.add(new NamiPurchaseManagerBridgeModule(reactContext));
25
25
  moduleList.add(new NamiEntitlementManagerBridgeModule(reactContext));
26
26
  moduleList.add(new NamiMLManagerBridgeModule(reactContext));
27
+ moduleList.add(new NamiManagerBridgeModule(reactContext));
27
28
  moduleList.add(new NamiCustomerManagerBridgeModule(reactContext));
28
29
  moduleList.add(new NamiCampaignManagerBridgeModule(reactContext));
29
30
 
@@ -156,7 +156,6 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
156
156
  putString(EXTERNAL_SEGMENT_ID, paywallEvent.externalSegmentId ?: "")
157
157
  putString(DEEP_LINK_URL, paywallEvent.deeplinkUrl ?: "")
158
158
  }
159
-
160
159
  emitEvent(_RESULT_CAMPAIGN, resultMap)
161
160
  }
162
161
 
@@ -0,0 +1,28 @@
1
+ package com.nami.reactlibrary
2
+
3
+ import android.util.Log
4
+ import com.facebook.react.bridge.*
5
+ import com.facebook.react.modules.core.DeviceEventManagerModule
6
+ import com.namiml.Nami
7
+
8
+ class NamiManagerBridgeModule(reactContext: ReactApplicationContext) :
9
+ ReactContextBaseJavaModule(reactContext) {
10
+
11
+ override fun getName(): String {
12
+ return "RNNamiManager"
13
+ }
14
+
15
+ @ReactMethod
16
+ fun sdkConfigured(promise: Promise) {
17
+ val sdkConfigured = Nami.isInitialized()
18
+ promise.resolve(sdkConfigured)
19
+ }
20
+
21
+ @ReactMethod
22
+ fun addListener(eventName: String?) {
23
+ }
24
+
25
+ @ReactMethod
26
+ fun removeListeners(count: Int?) {
27
+ }
28
+ }
@@ -239,6 +239,12 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
239
239
  promise.resolve(false)
240
240
  }
241
241
 
242
+ @ReactMethod
243
+ fun isPaywallOpen(promise: Promise) {
244
+ val paywallOpen = NamiPaywallManager.isPaywallOpen()
245
+ promise.resolve(paywallOpen)
246
+ }
247
+
242
248
  @ReactMethod
243
249
  fun buySkuCancel() {
244
250
  NamiPaywallManager.buySkuCancel()
package/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { NamiMLManager } from './src/NamiMLManager';
3
3
  export { NamiCampaignManager } from './src/NamiCampaignManager';
4
4
  export { NamiCustomerManager } from './src/NamiCustomerManager';
5
5
  export { NamiEntitlementManager } from './src/NamiEntitlementManager';
6
+ export { NamiManager } from './src/NamiManager';
6
7
  export { NamiPurchaseManager } from './src/NamiPurchaseManager';
7
8
  export { NamiPaywallManager } from './src/NamiPaywallManager';
8
9
  export * from './src/types';
package/index.ts CHANGED
@@ -3,6 +3,7 @@ export { NamiMLManager } from './src/NamiMLManager';
3
3
  export { NamiCampaignManager } from './src/NamiCampaignManager';
4
4
  export { NamiCustomerManager } from './src/NamiCustomerManager';
5
5
  export { NamiEntitlementManager } from './src/NamiEntitlementManager';
6
+ export { NamiManager } from './src/NamiManager';
6
7
  export { NamiPurchaseManager } from './src/NamiPurchaseManager';
7
8
  export { NamiPaywallManager } from './src/NamiPaywallManager';
8
9
  export * from './src/types';
package/ios/Nami.m CHANGED
@@ -20,13 +20,11 @@
20
20
  @implementation NamiBridge (RCTExternModule)
21
21
 
22
22
  RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict completion: (RCTResponseSenderBlock) completion) {
23
- if ([configDict count] == 0 || [configDict[@"logLevel"] isEqual: @"DEBUG"] ) {
24
- NSLog(@"Configure dictionary is %@", configDict);
25
- }
26
23
  NSString *appID = configDict[@"appPlatformID-apple"];
27
24
 
28
25
  if ([appID length] > 0 ) {
29
26
  NamiConfiguration *config = [NamiConfiguration configurationForAppPlatformId:appID];
27
+ NSLog(@"NAMI: RN Bridge - appPlatformId: %@", appID);
30
28
 
31
29
  NSString *logLevelString = configDict[@"logLevel"];
32
30
  if ([logLevelString isEqualToString:@"ERROR" ]) {
@@ -42,7 +40,7 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict completion: (RCTResponse
42
40
 
43
41
  NSString *languageString = configDict[@"namiLanguageCode"];
44
42
  if ([languageString length] > 0) {
45
- NSLog(@"Nami language code from config dictionary is %@", languageString);
43
+ NSLog(@"NAMI: RN Bridge - language code: %@", languageString);
46
44
  if ([[NamiLanguageCodes allAvailableNamiLanguageCodes]
47
45
  containsObject:[languageString lowercaseString]] ) {
48
46
  config.namiLanguageCode = languageString;
@@ -52,12 +50,12 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict completion: (RCTResponse
52
50
  }
53
51
 
54
52
  // Start commands with header iformation for Nami to let them know this is a React client.
55
- NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.1.10"]];
53
+ NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.1.12"]];
56
54
 
57
55
  // Add additional namiCommands app may have sent in.
58
56
  NSObject *appCommandStrings = configDict[@"namiCommands"];
59
57
  if ( appCommandStrings != NULL ) {
60
- NSLog(@"NamiCommand from dictionary is %@", configDict[@"namiCommands"]);
58
+ NSLog(@"NAMI: RN Bridge - additional config settings %@", configDict[@"namiCommands"]);
61
59
  if ([appCommandStrings isKindOfClass:[NSArray class]] ) {
62
60
  for (NSObject *commandObj in ((NSArray *)appCommandStrings)){
63
61
  if ([commandObj isKindOfClass:[NSString class]]) {
@@ -71,13 +69,19 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict completion: (RCTResponse
71
69
 
72
70
  NSString *initialConfigString = configDict[@"initialConfig"];
73
71
  if ([initialConfigString length] > 0) {
74
- NSLog(@"Found an initialConfig file to use for Nami SDK setup.");
72
+ NSLog(@"NAMI: RN Bridge - Found an initialConfig file to use for Nami SDK setup.");
75
73
  config.initialConfig = initialConfigString;
76
74
  }
77
75
 
78
- [Nami configureWith:config];
79
- NSDictionary *dict = @{@"success": @YES};
80
- completion(@[dict]);
76
+ [Nami configureWith:config :^(BOOL sdkConfigured) {
77
+ if ( sdkConfigured == YES ) {
78
+ NSDictionary *dict = @{@"success": @YES};
79
+ completion(@[dict]);
80
+ } else {
81
+ NSDictionary *dict = @{@"success": @NO};
82
+ completion(@[dict]);
83
+ }
84
+ }];
81
85
  }
82
86
  }
83
87
 
@@ -0,0 +1,18 @@
1
+ //
2
+ // NamiManager.m
3
+ // RNNami
4
+ //
5
+ // Copyright © 2020-2023 Nami ML Inc. All rights reserved.
6
+ //
7
+
8
+ #import <React/RCTBridgeModule.h>
9
+
10
+ @interface RCT_EXTERN_MODULE(RNNamiManager, NSObject)
11
+
12
+ RCT_EXTERN_METHOD(sdkConfigured:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
13
+
14
+ + (BOOL)requiresMainQueueSetup {
15
+ return YES;
16
+ }
17
+
18
+ @end
@@ -0,0 +1,30 @@
1
+ //
2
+ // NamiManager.swift
3
+ // RNNami
4
+ //
5
+ // Copyright © 2023 Nami ML INc.. All rights reserved.
6
+ //
7
+
8
+ import Foundation
9
+ import NamiApple
10
+ import React
11
+
12
+ @objc(RNNamiManager)
13
+ class RNNamiManager: RCTEventEmitter {
14
+ public static var shared: RNNamiManager?
15
+
16
+ override init() {
17
+ super.init()
18
+ RNNamiManager.shared = self
19
+ }
20
+
21
+ override func supportedEvents() -> [String]! {
22
+ return []
23
+ }
24
+
25
+ @objc(sdkConfigured:rejecter:)
26
+ func sdkConfigured(resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
27
+ let sdkConfigured = Nami.sdkConfigured()
28
+ resolve(sdkConfigured)
29
+ }
30
+ }
@@ -35,6 +35,8 @@ RCT_EXTERN_METHOD(hide)
35
35
 
36
36
  RCT_EXTERN_METHOD(isHidden:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
37
37
 
38
+ RCT_EXTERN_METHOD(isPaywallOpen:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
39
+
38
40
  RCT_EXTERN_METHOD(buySkuCancel)
39
41
 
40
42
  + (BOOL)requiresMainQueueSetup {
@@ -151,4 +151,12 @@ class RNNamiPaywallManager: RCTEventEmitter {
151
151
  resolve(isHidden)
152
152
  }
153
153
  }
154
+
155
+ @objc(isPaywallOpen:rejecter:)
156
+ func isPaywallOpen(resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
157
+ DispatchQueue.main.async {
158
+ let isPaywallOpen = NamiPaywallManager.isPaywallOpen()
159
+ resolve(isPaywallOpen)
160
+ }
161
+ }
154
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nami-sdk",
3
- "version": "3.1.10",
3
+ "version": "3.1.12",
4
4
  "description": "React Native Module for Nami - Easy subscriptions & in-app purchases, with powerful built-in paywalls and A/B testing.",
5
5
  "main": "index.ts",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,7 @@ Pod::Spec.new do |s|
20
20
  s.source_files = "ios/**/*.{h,m,swift}"
21
21
  s.requires_arc = true
22
22
 
23
- s.dependency 'Nami', '3.1.10'
23
+ s.dependency 'Nami', '3.1.13'
24
24
  s.dependency 'React'
25
25
 
26
26
  end
package/src/Nami.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { NativeModules } from 'react-native';
2
2
  import { NamiConfiguration } from './types';
3
3
 
4
- export const { NamiBridge } = NativeModules;
4
+ export const { NamiBridge, NamiManager } = NativeModules;
5
5
 
6
6
  export interface INami {
7
7
  configure: (
@@ -1,4 +1,5 @@
1
1
  import { EmitterSubscription } from 'react-native';
2
+ import { AccountStateAction } from './types';
2
3
 
3
4
  export const NamiCustomerManager: {
4
5
  setCustomerAttribute: (key: string, value: string) => void;
@@ -36,17 +37,3 @@ export type CustomerJourneyState = {
36
37
  inPause: boolean;
37
38
  inAccountHold: boolean;
38
39
  };
39
-
40
- export type AccountStateAction =
41
- | 'login'
42
- | 'logout'
43
- | 'advertising_id_set'
44
- | 'vendor_id_set'
45
- | 'customer_data_platform_id_set'
46
- | 'nami_device_id_set'
47
- | 'advertising_id_cleared'
48
- | 'vendor_id_cleared'
49
- | 'customer_data_platform_id_cleared'
50
- | 'nami_device_id_cleared'
51
- | 'anonymous_mode_on'
52
- | 'anonymous_mode_off';
@@ -0,0 +1,3 @@
1
+ export const NamiManager: {
2
+ sdkConfigured: () => Promise<boolean>;
3
+ };
@@ -0,0 +1,14 @@
1
+ import { NativeModules } from 'react-native';
2
+
3
+ export const { RNNamiManager } = NativeModules;
4
+
5
+ export interface INamiManager {
6
+ sdkConfigured: () => Promise<boolean>;
7
+ }
8
+
9
+ export const NamiManager: INamiManager = {
10
+ ...RNNamiManager,
11
+ sdkConfigured: () => {
12
+ return RNNamiManager.sdkConfigured();
13
+ },
14
+ };
@@ -25,6 +25,7 @@ export const NamiPaywallManager: {
25
25
  hide: () => void;
26
26
  buySkuCancel: () => void;
27
27
  isHidden: () => Promise<boolean>;
28
+ isPaywallOpen: () => Promise<boolean>;
28
29
  };
29
30
 
30
31
  export type NamiPurchaseSuccessApple = {
@@ -48,6 +48,7 @@ export interface INamiPaywallManager {
48
48
  show: () => void;
49
49
  hide: () => void;
50
50
  isHidden: () => Promise<boolean>;
51
+ isPaywallOpen: () => Promise<boolean>;
51
52
  }
52
53
 
53
54
  const { NamiPaywallManagerBridge, RNNamiPaywallManager } = NativeModules;
@@ -156,4 +157,7 @@ export const NamiPaywallManager: INamiPaywallManager = {
156
157
  isHidden: () => {
157
158
  return RNNamiPaywallManager.isHidden();
158
159
  },
160
+ isPaywallOpen: () => {
161
+ return RNNamiPaywallManager.isPaywallOpen();
162
+ },
159
163
  };
package/src/types.ts CHANGED
@@ -193,7 +193,6 @@ export type PaywallLaunchContext = {
193
193
  };
194
194
  };
195
195
 
196
- // NamiCustomerManager
197
196
  export type CustomerJourneyState = {
198
197
  formerSubscriber: boolean;
199
198
  inGracePeriod: boolean;
@@ -204,7 +203,19 @@ export type CustomerJourneyState = {
204
203
  inAccountHold: boolean;
205
204
  };
206
205
 
207
- export type AccountStateAction = 'login' | 'logout';
206
+ export type AccountStateAction =
207
+ | 'login'
208
+ | 'logout'
209
+ | 'advertising_id_set'
210
+ | 'vendor_id_set'
211
+ | 'customer_data_platform_id_set'
212
+ | 'nami_device_id_set'
213
+ | 'advertising_id_cleared'
214
+ | 'vendor_id_cleared'
215
+ | 'customer_data_platform_id_cleared'
216
+ | 'nami_device_id_cleared'
217
+ | 'anonymous_mode_on'
218
+ | 'anonymous_mode_off';
208
219
 
209
220
  // NamiEntitlementManager
210
221
  export type NamiEntitlement = {