@appboxo/react-native-sdk 1.5.2 → 1.7.0
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 +9 -9
- package/android/build.gradle +1 -15
- package/android/src/main/java/com/appboxo/react/RnappboxosdkModule.kt +29 -23
- package/index.d.ts +13 -12
- package/ios/Rnappboxosdk.m +25 -11
- package/js/customEvents.js +2 -2
- package/js/lifecycleHooks.js +1 -1
- package/js/mOpenMiniapp.js +6 -1
- package/js/paymentEvents.js +2 -2
- package/package.json +8 -5
- package/react-native-appboxosdk.podspec +1 -1
- package/types.ts +5 -5
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
##
|
|
2
|
-
A react native wrapper over
|
|
1
|
+
## Boxo SDK for React Native
|
|
2
|
+
A react native wrapper over Boxo SDK for IOS and Android.
|
|
3
3
|
|
|
4
4
|
Getting started:
|
|
5
5
|
|
|
@@ -20,17 +20,17 @@ Usage:
|
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
22
|
import React from 'react';
|
|
23
|
-
import
|
|
23
|
+
import Boxo from '@appboxo/react-native-sdk';
|
|
24
24
|
import { StyleSheet, View, Button } from 'react-native';
|
|
25
25
|
|
|
26
26
|
export default function App() {
|
|
27
27
|
|
|
28
28
|
React.useEffect(() => {
|
|
29
|
-
|
|
29
|
+
Boxo.setConfig('[client_id]', false, false); //set your Boxo client_id, sandbox mode (by default is "false") and specify multitask mode (by default is "true")
|
|
30
30
|
}, [])
|
|
31
31
|
|
|
32
32
|
const handleOpenMiniapp = () => {
|
|
33
|
-
|
|
33
|
+
Boxo.openMiniapp('[miniapp_id]', {'key': 'value'}); //launch miniapp by id with data as {[key: string]: any} | undefined that is sent to miniapp.
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
return (
|
|
@@ -63,15 +63,15 @@ To listen miniapp lifecycle events:
|
|
|
63
63
|
|
|
64
64
|
```tsx
|
|
65
65
|
import React from 'react';
|
|
66
|
-
import
|
|
66
|
+
import Boxo from '@appboxo/react-native-sdk';
|
|
67
67
|
import { StyleSheet, View, Button } from 'react-native';
|
|
68
68
|
|
|
69
69
|
export default function App() {
|
|
70
70
|
|
|
71
71
|
React.useEffect(() => {
|
|
72
|
-
|
|
72
|
+
Boxo.setConfig('[client_id]', false, false); //set your Boxo client_id, sandbox mode and specify multitask mode (by default is "true")
|
|
73
73
|
|
|
74
|
-
const subscription =
|
|
74
|
+
const subscription = Boxo.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
|
|
@@ -84,7 +84,7 @@ export default function App() {
|
|
|
84
84
|
}, [])
|
|
85
85
|
|
|
86
86
|
const handleOpenMiniapp = () => {
|
|
87
|
-
|
|
87
|
+
Boxo.openMiniapp('[miniapp_id]'); //launch miniapp by id
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
return (
|
package/android/build.gradle
CHANGED
|
@@ -119,25 +119,11 @@ repositories {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
rootProject.allprojects {
|
|
123
|
-
repositories {
|
|
124
|
-
mavenCentral()
|
|
125
|
-
maven { url "https://jitpack.io" }
|
|
126
|
-
maven {
|
|
127
|
-
url "https://maven.pkg.github.com/Appboxo/android-sdk-packages"
|
|
128
|
-
credentials {
|
|
129
|
-
username = "appboxoandroidsdk"
|
|
130
|
-
password = "\u0037\u0039\u0064\u0031\u0065\u0064\u0061\u0036\u0030\u0034\u0063\u0061\u0031\u0066\u0030\u0032\u0066\u0031\u0037\u0066\u0032\u0061\u0039\u0033\u0064\u0035\u0039\u0039\u0061\u0035\u0035\u0062\u0066\u0065\u0031\u0064\u0066\u0064\u0038\u0038"
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
122
|
dependencies {
|
|
137
123
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
138
124
|
//noinspection GradleDynamicVersion
|
|
139
125
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
140
|
-
implementation('
|
|
126
|
+
implementation('io.boxo.sdk:boxo-android:1.23.0') {
|
|
141
127
|
exclude group: 'com.google.android.gms', module: 'play-services-location'
|
|
142
128
|
}
|
|
143
129
|
}
|
|
@@ -18,15 +18,16 @@ package com.appboxo.react
|
|
|
18
18
|
import android.app.Application
|
|
19
19
|
import android.os.Handler
|
|
20
20
|
import android.os.Looper
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
21
|
+
import io.boxo.data.models.MiniappData
|
|
22
|
+
import io.boxo.data.models.PageAnimation
|
|
23
|
+
import io.boxo.js.params.CustomEvent
|
|
24
|
+
import io.boxo.js.params.PaymentData
|
|
25
|
+
import io.boxo.sdk.Boxo
|
|
26
|
+
import io.boxo.sdk.Config
|
|
27
|
+
import io.boxo.sdk.Miniapp
|
|
28
|
+
import io.boxo.sdk.MiniappConfig
|
|
29
|
+
import io.boxo.sdk.MiniappListCallback
|
|
30
|
+
import io.boxo.ui.main.BoxoActivity
|
|
30
31
|
import com.appboxo.react.utils.MapUtil
|
|
31
32
|
import com.facebook.react.bridge.Arguments
|
|
32
33
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -45,7 +46,7 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
45
46
|
|
|
46
47
|
init {
|
|
47
48
|
this.reactContext = reactContext
|
|
48
|
-
|
|
49
|
+
Boxo.init(reactContext.getBaseContext() as Application)
|
|
49
50
|
handler = Handler(Looper.getMainLooper())
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -69,7 +70,7 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
69
70
|
"dark" -> Config.Theme.DARK
|
|
70
71
|
else -> Config.Theme.SYSTEM
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
Boxo
|
|
73
74
|
.setConfig(
|
|
74
75
|
Config.Builder()
|
|
75
76
|
.setClientId(clientId)
|
|
@@ -95,10 +96,11 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
95
96
|
urlSuffix: String?,
|
|
96
97
|
colors: ReadableMap?,
|
|
97
98
|
enableSplash: Boolean,
|
|
98
|
-
saveState: Boolean
|
|
99
|
+
saveState: Boolean,
|
|
100
|
+
pageAnimation: String?
|
|
99
101
|
) {
|
|
100
102
|
handler.post {
|
|
101
|
-
val miniapp: Miniapp =
|
|
103
|
+
val miniapp: Miniapp = Boxo.getMiniapp(appId)
|
|
102
104
|
.setCustomEventListener(this)
|
|
103
105
|
.setPaymentEventListener(this)
|
|
104
106
|
.setAuthListener(this)
|
|
@@ -130,6 +132,10 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
130
132
|
colors.getString("tertiaryColor") ?: "",
|
|
131
133
|
)
|
|
132
134
|
}
|
|
135
|
+
|
|
136
|
+
val animation = runCatching { PageAnimation.valueOf(pageAnimation ?: "") }
|
|
137
|
+
.getOrDefault(PageAnimation.BOTTOM_TO_TOP)
|
|
138
|
+
configBuilder.pageAnimation(animation)
|
|
133
139
|
configBuilder.enableSplash(enableSplash)
|
|
134
140
|
configBuilder.saveState(saveState)
|
|
135
141
|
miniapp.setConfig(configBuilder.build())
|
|
@@ -139,17 +145,17 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
139
145
|
|
|
140
146
|
@ReactMethod
|
|
141
147
|
fun setAuthCode(appId: String, authCode: String) {
|
|
142
|
-
|
|
148
|
+
Boxo.getMiniapp(appId)
|
|
143
149
|
.setAuthCode(authCode)
|
|
144
150
|
}
|
|
145
151
|
|
|
146
152
|
@ReactMethod
|
|
147
153
|
fun closeMiniapp(appId: String) {
|
|
148
|
-
handler.post {
|
|
154
|
+
handler.post { Boxo.getExistingMiniapp(appId)?.close() }
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
override fun handle(
|
|
152
|
-
|
|
158
|
+
boxoActivity: BoxoActivity,
|
|
153
159
|
miniapp: Miniapp,
|
|
154
160
|
customEvent: CustomEvent
|
|
155
161
|
) {
|
|
@@ -214,7 +220,7 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
214
220
|
sendEvent(MINIAPP_LIFECYCLE_EVENT_NAME, params)
|
|
215
221
|
}
|
|
216
222
|
|
|
217
|
-
override fun onAuth(
|
|
223
|
+
override fun onAuth(boxoActivity: BoxoActivity, miniapp: Miniapp) {
|
|
218
224
|
val params: WritableMap = Arguments.createMap()
|
|
219
225
|
params.putString("app_id", miniapp.appId)
|
|
220
226
|
params.putString("lifecycle", "onAuth")
|
|
@@ -232,7 +238,7 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
232
238
|
if (customEventMap.hasKey("error_type")) customEventMap.getString("error_type") else null,
|
|
233
239
|
MapUtil.toMap(customEventMap.getMap("payload"))
|
|
234
240
|
)
|
|
235
|
-
handler.post {
|
|
241
|
+
handler.post { Boxo.getExistingMiniapp(appId)?.sendEvent(event) }
|
|
236
242
|
} catch (e: Exception) {
|
|
237
243
|
e.printStackTrace()
|
|
238
244
|
}
|
|
@@ -254,7 +260,7 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
254
260
|
?.let { MapUtil.toMap(paymentEvent.getMap("extra_params")) }
|
|
255
261
|
?: mapOf()
|
|
256
262
|
)
|
|
257
|
-
handler.post {
|
|
263
|
+
handler.post { Boxo.getExistingMiniapp(appId)?.sendPaymentResult(data) }
|
|
258
264
|
} catch (e: Exception) {
|
|
259
265
|
e.printStackTrace()
|
|
260
266
|
}
|
|
@@ -262,7 +268,7 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
262
268
|
|
|
263
269
|
@ReactMethod
|
|
264
270
|
fun getMiniapps() {
|
|
265
|
-
|
|
271
|
+
Boxo.getMiniapps(object : MiniappListCallback {
|
|
266
272
|
override fun onSuccess(miniapps: List<MiniappData>) {
|
|
267
273
|
try {
|
|
268
274
|
val array: Array<Map<*, *>?> = arrayOfNulls(miniapps.size)
|
|
@@ -297,12 +303,12 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
297
303
|
|
|
298
304
|
@ReactMethod
|
|
299
305
|
fun hideMiniapps() {
|
|
300
|
-
|
|
306
|
+
Boxo.hideMiniapps()
|
|
301
307
|
}
|
|
302
308
|
|
|
303
309
|
@ReactMethod
|
|
304
310
|
fun logout() {
|
|
305
|
-
|
|
311
|
+
Boxo.logout()
|
|
306
312
|
}
|
|
307
313
|
|
|
308
314
|
private fun sendEvent(name: String, params: WritableMap) {
|
|
@@ -312,7 +318,7 @@ class RnappboxosdkModule(reactContext: ReactApplicationContext) :
|
|
|
312
318
|
}
|
|
313
319
|
|
|
314
320
|
override fun handle(
|
|
315
|
-
|
|
321
|
+
boxoActivity: BoxoActivity,
|
|
316
322
|
miniapp: Miniapp,
|
|
317
323
|
paymentData: PaymentData
|
|
318
324
|
) {
|
package/index.d.ts
CHANGED
|
@@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { BoxoCustomEvent, LifecycleHooksCallbacks, MiniappDataListCallback } from './types'
|
|
18
18
|
|
|
19
19
|
declare module '@appboxo/react-native-sdk' {
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Set
|
|
23
|
-
* @param {string} clientId
|
|
24
|
-
* @param {object} options -
|
|
22
|
+
* Set Boxo clientId
|
|
23
|
+
* @param {string} clientId Boxo clientId
|
|
24
|
+
* @param {object} options - Boxo global config
|
|
25
25
|
* userId - hostapp userId for consent management
|
|
26
26
|
* sandboxMode (by default false)
|
|
27
27
|
* enableMultitaskMode Enable multiscreen mode (by default true)
|
|
@@ -44,8 +44,8 @@ declare module '@appboxo/react-native-sdk' {
|
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Launch miniapp by id with payload and custom data
|
|
47
|
-
* @param {string} miniAppId
|
|
48
|
-
* @param {object} options
|
|
47
|
+
* @param {string} miniAppId Boxo miniAppId
|
|
48
|
+
* @param {object} options Boxo options: data for send to miniapp,
|
|
49
49
|
* theme Miniapp theme (by default is value of "theme" argument in setConfig function)
|
|
50
50
|
* */
|
|
51
51
|
|
|
@@ -58,14 +58,15 @@ declare module '@appboxo/react-native-sdk' {
|
|
|
58
58
|
urlSuffix?: string,
|
|
59
59
|
colors?: { primaryColor: string, secondaryColor: string, tertiaryColor: string },
|
|
60
60
|
enableSplash?: boolean,
|
|
61
|
-
saveState?: boolean
|
|
61
|
+
saveState?: boolean,
|
|
62
|
+
pageAnimation?: 'BOTTOM_TO_TOP' | 'TOP_TO_BOTTOM' | 'LEFT_TO_RIGHT' | 'RIGHT_TO_LEFT' | 'FADE_IN'
|
|
62
63
|
},
|
|
63
64
|
): void
|
|
64
65
|
|
|
65
66
|
export function closeMiniapp(appId: string): void
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
|
-
*
|
|
69
|
+
* Boxo custom events system for handle events from miniapp and send to miniapp.
|
|
69
70
|
* */
|
|
70
71
|
export const customEvents: {
|
|
71
72
|
|
|
@@ -76,15 +77,15 @@ declare module '@appboxo/react-native-sdk' {
|
|
|
76
77
|
* @returns {function} unsubscribe events from miniapp
|
|
77
78
|
* */
|
|
78
79
|
subscribe: <EventType extends string, Payload extends object>(
|
|
79
|
-
eventHandler: (event:
|
|
80
|
+
eventHandler: (event: BoxoCustomEvent<EventType, Payload>) => void,
|
|
80
81
|
errorHandler?: (errorType: string) => void,
|
|
81
82
|
) => () => void
|
|
82
83
|
|
|
83
84
|
/**
|
|
84
85
|
* Send events to miniapp
|
|
85
|
-
* @param {
|
|
86
|
+
* @param {BoxoCustomEvent} event to send to miniapp
|
|
86
87
|
* */
|
|
87
|
-
send(event:
|
|
88
|
+
send(event: BoxoCustomEvent<string, object>): void
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
/**
|
|
@@ -98,7 +99,7 @@ declare module '@appboxo/react-native-sdk' {
|
|
|
98
99
|
export function logout(): void
|
|
99
100
|
|
|
100
101
|
/**
|
|
101
|
-
*
|
|
102
|
+
* Boxo Miniapp lifecycle hooks listener
|
|
102
103
|
* */
|
|
103
104
|
export function lifecycleHooksListener(callbacks: Partial<LifecycleHooksCallbacks>): () => void
|
|
104
105
|
|
package/ios/Rnappboxosdk.m
CHANGED
|
@@ -16,7 +16,7 @@ limitations under the License.
|
|
|
16
16
|
|
|
17
17
|
#import "Rnappboxosdk.h"
|
|
18
18
|
#import <UIKit/UIKit.h>
|
|
19
|
-
#import
|
|
19
|
+
#import "BoxoSDK/BoxoSDK-Swift.h"
|
|
20
20
|
|
|
21
21
|
@interface Rnappboxosdk () <MiniappDelegate>
|
|
22
22
|
|
|
@@ -50,13 +50,13 @@ RCT_EXPORT_METHOD(setConfig:(NSString *)clientId userId:(NSString *)userId langu
|
|
|
50
50
|
config.showClearCache = showClearCache;
|
|
51
51
|
config.showAboutPage = showAboutPage;
|
|
52
52
|
|
|
53
|
-
[[
|
|
53
|
+
[[Boxo shared] setConfig: config];
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
RCT_EXPORT_METHOD(openMiniapp:(NSString *)appId data:(nullable NSDictionary<NSString *,id> *)data theme:(nullable NSString *)theme extraUrlParams:(nullable NSDictionary<NSString *,id> *)extraUrlParams urlSuffix:(nullable NSString *)urlSuffix colors:(nullable NSDictionary<NSString *,id> *)colors enableSplash:(BOOL)enableSplash saveState:(BOOL)saveState)
|
|
56
|
+
RCT_EXPORT_METHOD(openMiniapp:(NSString *)appId data:(nullable NSDictionary<NSString *,id> *)data theme:(nullable NSString *)theme extraUrlParams:(nullable NSDictionary<NSString *,id> *)extraUrlParams urlSuffix:(nullable NSString *)urlSuffix colors:(nullable NSDictionary<NSString *,id> *)colors enableSplash:(BOOL)enableSplash saveState:(BOOL)saveState pageAnimation:(nullable NSString *)pageAnimation)
|
|
57
57
|
{
|
|
58
58
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
59
|
-
Miniapp *miniapp = [[
|
|
59
|
+
Miniapp *miniapp = [[Boxo shared] getMiniappWithAppId: appId];
|
|
60
60
|
[miniapp setData: data];
|
|
61
61
|
[miniapp setDelegate:self];
|
|
62
62
|
|
|
@@ -65,6 +65,20 @@ RCT_EXPORT_METHOD(openMiniapp:(NSString *)appId data:(nullable NSDictionary<NSSt
|
|
|
65
65
|
[miniappConfig setExtraParams:extraUrlParams];
|
|
66
66
|
miniappConfig.saveState = saveState;
|
|
67
67
|
|
|
68
|
+
if (pageAnimation != NULL) {
|
|
69
|
+
if ([pageAnimation isEqualToString:@"TOP_TO_BOTTOM"]) {
|
|
70
|
+
miniappConfig.pageAnimation = PageAnimationTOP_TO_BOTTOM;
|
|
71
|
+
} else if ([pageAnimation isEqualToString:@"LEFT_TO_RIGHT"]) {
|
|
72
|
+
miniappConfig.pageAnimation = PageAnimationLEFT_TO_RIGHT;
|
|
73
|
+
} else if ([pageAnimation isEqualToString:@"RIGHT_TO_LEFT"]) {
|
|
74
|
+
miniappConfig.pageAnimation = PageAnimationRIGHT_TO_LEFT;
|
|
75
|
+
} else if ([pageAnimation isEqualToString:@"FADE_IN"]) {
|
|
76
|
+
miniappConfig.pageAnimation = PageAnimationFADE_IN;
|
|
77
|
+
} else {
|
|
78
|
+
miniappConfig.pageAnimation = PageAnimationBOTTOM_TO_TOP;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
if (urlSuffix != NULL) {
|
|
69
83
|
miniappConfig.urlSuffix = urlSuffix;
|
|
70
84
|
}
|
|
@@ -93,7 +107,7 @@ RCT_EXPORT_METHOD(openMiniapp:(NSString *)appId data:(nullable NSDictionary<NSSt
|
|
|
93
107
|
RCT_EXPORT_METHOD(closeMiniapp:(NSString *)appId)
|
|
94
108
|
{
|
|
95
109
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
96
|
-
Miniapp *miniapp = [[
|
|
110
|
+
Miniapp *miniapp = [[Boxo shared] getMiniappWithAppId: appId];
|
|
97
111
|
[miniapp close];
|
|
98
112
|
});
|
|
99
113
|
}
|
|
@@ -101,7 +115,7 @@ RCT_EXPORT_METHOD(closeMiniapp:(NSString *)appId)
|
|
|
101
115
|
RCT_EXPORT_METHOD(setAuthCode:(NSString *)appId code:(NSString *)code)
|
|
102
116
|
{
|
|
103
117
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
104
|
-
Miniapp *miniapp = [[
|
|
118
|
+
Miniapp *miniapp = [[Boxo shared] getMiniappWithAppId: appId];
|
|
105
119
|
[miniapp setAuthCode: code];
|
|
106
120
|
});
|
|
107
121
|
}
|
|
@@ -109,14 +123,14 @@ RCT_EXPORT_METHOD(setAuthCode:(NSString *)appId code:(NSString *)code)
|
|
|
109
123
|
RCT_EXPORT_METHOD(hideMiniapps)
|
|
110
124
|
{
|
|
111
125
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
112
|
-
[[
|
|
126
|
+
[[Boxo shared] hideMiniapps];
|
|
113
127
|
});
|
|
114
128
|
}
|
|
115
129
|
|
|
116
130
|
RCT_EXPORT_METHOD(logout)
|
|
117
131
|
{
|
|
118
132
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
119
|
-
[[
|
|
133
|
+
[[Boxo shared] logout];
|
|
120
134
|
});
|
|
121
135
|
}
|
|
122
136
|
|
|
@@ -132,7 +146,7 @@ RCT_EXPORT_METHOD(sendCustomEvent:(NSDictionary<NSString *,id> * _Nonnull)params
|
|
|
132
146
|
customEvent.errorType = customEventParams[@"error_type"] != NULL ? (NSString *) customEventParams[@"error_type"] : @"";
|
|
133
147
|
customEvent.payload = customEventParams[@"payload"] != NULL ? (NSDictionary<NSString *, id> *) customEventParams[@"payload"] : NULL;
|
|
134
148
|
|
|
135
|
-
Miniapp *miniapp = [[
|
|
149
|
+
Miniapp *miniapp = [[Boxo shared] getMiniappWithAppId:appId];
|
|
136
150
|
if (miniapp != NULL) {
|
|
137
151
|
[miniapp sendCustomEvent:customEvent];
|
|
138
152
|
};
|
|
@@ -154,7 +168,7 @@ RCT_EXPORT_METHOD(sendPaymentEvent:(NSDictionary<NSString *,id> * _Nonnull)param
|
|
|
154
168
|
paymentData.hostappOrderId = paymentEventParams[@"hostapp_order_id"] != NULL ? (NSString *) paymentEventParams[@"hostapp_order_id"] : @"";
|
|
155
169
|
paymentData.extraParams = paymentEventParams[@"extra_params"] != NULL ? (NSDictionary<NSString *, id> *) paymentEventParams[@"extra_params"] : NULL;
|
|
156
170
|
|
|
157
|
-
Miniapp *miniapp = [[
|
|
171
|
+
Miniapp *miniapp = [[Boxo shared] getMiniappWithAppId:appId];
|
|
158
172
|
if (miniapp != NULL) {
|
|
159
173
|
[miniapp sendPaymentEvent: paymentData];
|
|
160
174
|
};
|
|
@@ -164,7 +178,7 @@ RCT_EXPORT_METHOD(sendPaymentEvent:(NSDictionary<NSString *,id> * _Nonnull)param
|
|
|
164
178
|
RCT_EXPORT_METHOD(getMiniapps)
|
|
165
179
|
{
|
|
166
180
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
167
|
-
[[
|
|
181
|
+
[[Boxo shared] getMiniapps:^(NSArray<MiniappData *> * _Nonnull list, NSString * _Nullable error) {
|
|
168
182
|
if (error != NULL) {
|
|
169
183
|
[self sendEventWithName:APPBOXO_MINIAPP_LIST_EVENT body:@{@"error": error}];
|
|
170
184
|
} else {
|
package/js/customEvents.js
CHANGED
|
@@ -17,7 +17,7 @@ limitations under the License.
|
|
|
17
17
|
import { NativeEventEmitter, NativeModules } from 'react-native'
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Boxo custom events system for handle events from miniapp and send to miniapp.
|
|
21
21
|
* */
|
|
22
22
|
const customEvents = {
|
|
23
23
|
|
|
@@ -39,7 +39,7 @@ const customEvents = {
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Send events to miniapp
|
|
42
|
-
* @param {
|
|
42
|
+
* @param {BoxoCustomEvent} event to send to miniapp
|
|
43
43
|
* */
|
|
44
44
|
send: (event) => {
|
|
45
45
|
const { Rnappboxosdk: { sendCustomEvent } } = NativeModules
|
package/js/lifecycleHooks.js
CHANGED
package/js/mOpenMiniapp.js
CHANGED
|
@@ -12,7 +12,12 @@ const mOpenMiniapp = (miniAppId, options) => {
|
|
|
12
12
|
options?.urlSuffix,
|
|
13
13
|
options?.colors,
|
|
14
14
|
options?.enableSplash ?? true,
|
|
15
|
-
options?.saveState ?? true
|
|
15
|
+
options?.saveState ?? true,
|
|
16
|
+
options?.pageAnimation === 'BOTTOM_TO_TOP' ||
|
|
17
|
+
options?.pageAnimation === 'TOP_TO_BOTTOM' ||
|
|
18
|
+
options?.pageAnimation === 'LEFT_TO_RIGHT' ||
|
|
19
|
+
options?.pageAnimation === 'RIGHT_TO_LEFT' ||
|
|
20
|
+
options?.pageAnimation === 'FADE_IN' ? options.pageAnimation : null,
|
|
16
21
|
)
|
|
17
22
|
}
|
|
18
23
|
|
package/js/paymentEvents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NativeEventEmitter, NativeModules } from 'react-native'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Boxo custom events system for handle events from miniapp and send to miniapp.
|
|
5
5
|
* */
|
|
6
6
|
const paymentEvents = {
|
|
7
7
|
|
|
@@ -25,7 +25,7 @@ const paymentEvents = {
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Send events to miniapp
|
|
28
|
-
* @param {
|
|
28
|
+
* @param {BoxoPaymentEvent} event to send to miniapp
|
|
29
29
|
* */
|
|
30
30
|
send: (event) => {
|
|
31
31
|
const { Rnappboxosdk: { sendPaymentEvent } } = NativeModules
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appboxo/react-native-sdk",
|
|
3
|
-
"title": "
|
|
4
|
-
"version": "1.
|
|
5
|
-
"description": "
|
|
3
|
+
"title": "BoxoSDK for React Native",
|
|
4
|
+
"version": "1.7.0",
|
|
5
|
+
"description": "BoxoSDK plugin for react native",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"README.md",
|
|
@@ -24,9 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/Appboxo/react-native-sdk#readme",
|
|
26
26
|
"keywords": [
|
|
27
|
+
"boxo",
|
|
28
|
+
"boxoSDK",
|
|
29
|
+
"appboxo-react-native-sdk",
|
|
30
|
+
"boxo-react-native-sdk",
|
|
27
31
|
"appboxo",
|
|
28
|
-
"appboxoSDK"
|
|
29
|
-
"appboxo-react-native-sdk"
|
|
32
|
+
"appboxoSDK"
|
|
30
33
|
],
|
|
31
34
|
"author": {
|
|
32
35
|
"name": "Appboxo pte. ltd.",
|
package/types.ts
CHANGED
|
@@ -15,9 +15,9 @@ limitations under the License.
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* BoxoCustomEvent for handle events from miniapp and send to miniapp.
|
|
19
19
|
* */
|
|
20
|
-
export interface
|
|
20
|
+
export interface BoxoCustomEvent<EventType extends string, Payload extends object> {
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Miniapp id
|
|
@@ -27,13 +27,13 @@ export interface AppboxoCustomEvent<EventType extends string, Payload extends ob
|
|
|
27
27
|
/**
|
|
28
28
|
* Custom event body
|
|
29
29
|
* */
|
|
30
|
-
custom_event:
|
|
30
|
+
custom_event: BoxoCustomEventBody<EventType, Payload>
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Custom event body
|
|
35
35
|
* */
|
|
36
|
-
export interface
|
|
36
|
+
export interface BoxoCustomEventBody<EventType extends string, Payload extends object> {
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Error type if an error occurred
|
|
@@ -58,7 +58,7 @@ export interface AppboxoCustomEventBody<EventType extends string, Payload extend
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Boxo Miniapp lifecycle hooks callbacks
|
|
62
62
|
* */
|
|
63
63
|
|
|
64
64
|
export interface LifecycleHooksCallbacks {
|