@appboxo/react-native-sdk 1.0.34 → 1.0.36
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.
- package/README.md +3 -2
- package/android/src/main/java/com/appboxo/RnappboxosdkModule.java +28 -2
- package/index.d.ts +2 -3
- package/ios/Rnappboxosdk.m +5 -2
- package/js/mSetConfig.js +2 -2
- package/package.json +1 -1
- package/types.ts +1 -0
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ import { StyleSheet, View, Button } from 'react-native';
|
|
|
26
26
|
export default function App() {
|
|
27
27
|
|
|
28
28
|
React.useEffect(() => {
|
|
29
|
-
appboxo.setConfig('[client_id]', false); //set your Appboxo client_id and specify multitask mode (by default is "true")
|
|
29
|
+
appboxo.setConfig('[client_id]', false, false); //set your Appboxo client_id, sandbox mode (by default is "false") and specify multitask mode (by default is "true")
|
|
30
30
|
}, [])
|
|
31
31
|
|
|
32
32
|
const handleOpenMiniapp = () => {
|
|
@@ -69,13 +69,14 @@ import { StyleSheet, View, Button } from 'react-native';
|
|
|
69
69
|
export default function App() {
|
|
70
70
|
|
|
71
71
|
React.useEffect(() => {
|
|
72
|
-
appboxo.setConfig('[client_id]', false); //set your Appboxo client_id and specify multitask mode (by default is "true")
|
|
72
|
+
appboxo.setConfig('[client_id]', false, false); //set your Appboxo client_id, sandbox mode and specify multitask mode (by default is "true")
|
|
73
73
|
|
|
74
74
|
const subscription = appboxo.lifecycleHooksListener({
|
|
75
75
|
onLaunch: (appId: string) => console.log('onLaunch', appId), // called when the miniapp will launch with openMiniapp(...)
|
|
76
76
|
onResume: (appId: string) => console.log('onResume', appId), // called when the miniapp will start interacting with the user
|
|
77
77
|
onPause: (appId: string) => console.log('onPause', appId), // called when clicked close button in miniapp or when destroyed miniapp activity
|
|
78
78
|
onClose: (appId: string) => console.log('onClose', appId), // called when the miniapp loses foreground state
|
|
79
|
+
onAuth: (appId: string) => console.log('onAuth', appId), // called when authorization flow starts
|
|
79
80
|
onError: (appId: string, error: string) => console.log('onError', appId, error), // handle error
|
|
80
81
|
});
|
|
81
82
|
|
|
@@ -44,8 +44,9 @@ import java.util.HashMap;
|
|
|
44
44
|
import java.util.Map;
|
|
45
45
|
|
|
46
46
|
public class RnappboxosdkModule extends ReactContextBaseJavaModule
|
|
47
|
-
implements Miniapp.LifecycleListener, Miniapp.CustomEventListener, Miniapp.AuthListener {
|
|
47
|
+
implements Miniapp.LifecycleListener, Miniapp.CustomEventListener, Miniapp.AuthListener, Miniapp.PaymentEventListener {
|
|
48
48
|
private static final String CUSTOM_EVENTS_EVENT_NAME = "appboxo_custom_events";
|
|
49
|
+
private static final String PAYMENT_EVENTS_EVENT_NAME = "appboxo_payment_events";
|
|
49
50
|
private static final String MINIAPP_LIFECYCLE_EVENT_NAME = "appboxo_miniapp_lifecycle";
|
|
50
51
|
|
|
51
52
|
private final ReactApplicationContext reactContext;
|
|
@@ -64,7 +65,7 @@ public class RnappboxosdkModule extends ReactContextBaseJavaModule
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
@ReactMethod
|
|
67
|
-
public void setConfig(String clientId, boolean enableMultitaskMode, String theme) {
|
|
68
|
+
public void setConfig(String clientId, boolean sandboxMode, boolean enableMultitaskMode, String theme) {
|
|
68
69
|
Config.Theme globalTheme;
|
|
69
70
|
switch (theme) {
|
|
70
71
|
case "light":
|
|
@@ -79,6 +80,7 @@ public class RnappboxosdkModule extends ReactContextBaseJavaModule
|
|
|
79
80
|
Appboxo.INSTANCE
|
|
80
81
|
.setConfig(new Config.Builder()
|
|
81
82
|
.setClientId(clientId)
|
|
83
|
+
.sandboxMode(sandboxMode)
|
|
82
84
|
.multitaskMode(enableMultitaskMode)
|
|
83
85
|
.setTheme(globalTheme)
|
|
84
86
|
.build());
|
|
@@ -88,6 +90,7 @@ public class RnappboxosdkModule extends ReactContextBaseJavaModule
|
|
|
88
90
|
public void openMiniapp(String appId, ReadableMap data, String theme, ReadableMap customUrlParams) {
|
|
89
91
|
Miniapp miniapp = Appboxo.INSTANCE.getMiniapp(appId)
|
|
90
92
|
.setCustomEventListener(this)
|
|
93
|
+
.setPaymentEventListener(this)
|
|
91
94
|
.setAuthListener(this)
|
|
92
95
|
.setLifecycleListener(this);
|
|
93
96
|
|
|
@@ -273,4 +276,27 @@ public class RnappboxosdkModule extends ReactContextBaseJavaModule
|
|
|
273
276
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
274
277
|
.emit(name, params);
|
|
275
278
|
}
|
|
279
|
+
|
|
280
|
+
@Override
|
|
281
|
+
public void handle(AppboxoActivity appboxoActivity, Miniapp miniapp, PaymentData paymentData) {
|
|
282
|
+
WritableMap params = Arguments.createMap();
|
|
283
|
+
params.putString("app_id", miniapp.getAppId());
|
|
284
|
+
WritableMap event = Arguments.createMap();
|
|
285
|
+
try {
|
|
286
|
+
event.putString("transaction_token", paymentData.getTransactionToken());
|
|
287
|
+
event.putString("miniapp_order_id", paymentData.getMiniappOrderId());
|
|
288
|
+
event.putDouble("amount", paymentData.getAmount());
|
|
289
|
+
event.putString("currency", paymentData.getCurrency());
|
|
290
|
+
event.putString("status", paymentData.getStatus());
|
|
291
|
+
event.putString("hostapp_order_id", paymentData.getHostappOrderId());
|
|
292
|
+
if (paymentData.getExtraParams() != null) {
|
|
293
|
+
event.putMap("extra_params", MapUtil.toWritableMap(paymentData.getExtraParams()));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
params.putMap("payment_event", event);
|
|
297
|
+
sendEvent(PAYMENT_EVENTS_EVENT_NAME, params);
|
|
298
|
+
} catch (Exception e) {
|
|
299
|
+
e.printStackTrace();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
276
302
|
}
|
package/index.d.ts
CHANGED
|
@@ -21,22 +21,21 @@ declare module '@appboxo/react-native-sdk' {
|
|
|
21
21
|
/**
|
|
22
22
|
* Set Appboxo clientId
|
|
23
23
|
* @param {string} clientId Appboxo clientId
|
|
24
|
+
* @param {boolean} sandboxMode (by default false)
|
|
24
25
|
* @param {boolean} enableMultitaskMode Enable multiscreen mode (by default true)
|
|
25
26
|
* @param {'dark' | 'light'} theme Miniapp theme (by default 'system')
|
|
26
27
|
* */
|
|
27
|
-
export function setConfig(clientId: string, enableMultitaskMode?: boolean, theme?: 'dark' | 'light'): void
|
|
28
|
+
export function setConfig(clientId: string, sandboxMode?: boolean, enableMultitaskMode?: boolean, theme?: 'dark' | 'light'): void
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Launch miniapp by id with payload and custom data
|
|
31
32
|
* @param {string} miniAppId Appboxo miniAppId
|
|
32
|
-
* @param {string} payload Appboxo payload for Appboxo miniapp
|
|
33
33
|
* @param {{ data?: object, theme?: 'dark' | 'light' | 'system', extraUrlParams?: object }} options Appboxo options: data for send to miniapp,
|
|
34
34
|
* theme Miniapp theme (by default is value of "theme" argument in setConfig function)
|
|
35
35
|
* */
|
|
36
36
|
|
|
37
37
|
export function openMiniapp(
|
|
38
38
|
miniAppId: string,
|
|
39
|
-
payload: string,
|
|
40
39
|
options?: {
|
|
41
40
|
data?: object,
|
|
42
41
|
theme?: 'dark' | 'light' | 'system',
|
package/ios/Rnappboxosdk.m
CHANGED
|
@@ -31,7 +31,7 @@ limitations under the License.
|
|
|
31
31
|
RCT_EXPORT_MODULE()
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
RCT_EXPORT_METHOD(setConfig:(NSString *)clientId multitaskMode:(BOOL)multitaskMode theme:(NSString *)theme)
|
|
34
|
+
RCT_EXPORT_METHOD(setConfig:(NSString *)clientId sandboxMode:(BOOL)sandboxMode multitaskMode:(BOOL)multitaskMode theme:(NSString *)theme)
|
|
35
35
|
{
|
|
36
36
|
NSArray *themes = @[@"dark", @"light", @"system"];
|
|
37
37
|
|
|
@@ -41,7 +41,10 @@ RCT_EXPORT_METHOD(setConfig:(NSString *)clientId multitaskMode:(BOOL)multitaskMo
|
|
|
41
41
|
globalTheme = (Theme) [themes indexOfObject:theme];
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
Config *config = [[Config alloc] initWithClientId: clientId theme: globalTheme];
|
|
45
|
+
config.sandboxMode = sandboxMode;
|
|
46
|
+
|
|
47
|
+
[[Appboxo shared] setConfig: config];
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
RCT_EXPORT_METHOD(openMiniapp:(NSString *)appId data:(nullable NSDictionary<NSString *,id> *)data theme:(nullable NSString *)theme customUrlParams:(nullable NSDictionary<NSString *,id> *)customUrlParams)
|
package/js/mSetConfig.js
CHANGED
|
@@ -3,8 +3,8 @@ import { NativeModules } from 'react-native'
|
|
|
3
3
|
/**
|
|
4
4
|
* Miniapp theme (by default 'system')
|
|
5
5
|
* */
|
|
6
|
-
const mSetConfig = (clientId, enableMultitaskMode = true, theme = 'system') => {
|
|
7
|
-
NativeModules.Rnappboxosdk.setConfig(clientId, enableMultitaskMode, theme === 'dark' || theme === 'light' ? theme : 'system')
|
|
6
|
+
const mSetConfig = (clientId, sandboxMode = false, enableMultitaskMode = true, theme = 'system') => {
|
|
7
|
+
NativeModules.Rnappboxosdk.setConfig(clientId, sandboxMode, enableMultitaskMode, theme === 'dark' || theme === 'light' ? theme : 'system')
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export default mSetConfig
|
package/package.json
CHANGED
package/types.ts
CHANGED