0.4.0 • Published 9 months ago

@appboxo/expo-boxo-sdk v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

expo-boxo-sdk

Expo wrapper over Appboxo SDK for IOS and Android.

Install

npm install @appboxo/expo-boxo-sdk

Configuration in app.json/app.config.js

{
  "expo": {
    "plugins": [
      ["@appboxo/expo-boxo-sdk"]
    ]
  }
}

API

setConfig(...)

setConfig(options: ConfigOptions)

Set global configs

PropTypeDescription
clientIdstringyour client id from dashboard
userIdstringhostapp userId, will be used for the Consent Management
sandboxModebooleanswitch to sandbox mode
multitaskModebooleanEach miniapp appears as a task in the Recents screen. !It works only on android devices.
theme'light' | 'dark' | 'system'theme for splash screen and other native components used inside miniapp.
isDebugbooleanenables webview debugging
showPermissionsPagebooleanuse it to hide "Settings" from Miniapp menu
showClearCachebooleanuse it to hide "Clear cache" from Miniapp menu

openMiniapp(...)

openMiniapp(options: MiniappOptions)

Open miniapp with options

PropTypeDescription
appIdstringminiapp id
dataRecord<string, any>(optional) data as Map that is sent to miniapp
theme'light' | 'dark' | 'system'(optional) miniapp theme "dark" | "light" (by default is system theme)
extraUrlParamsRecord<string, string>(optional) extra query params to append to miniapp URL (like: http://miniapp-url.com/?param=test)
urlSuffixstring(optional) suffix to append to miniapp URL (like: http://miniapp-url.com/?param=test)
colorsRecord<string, string>(optional) provide colors to miniapp if miniapp supports
enableSplashboolean(optional) use to skip miniapp splash screen

Color options

PropType
primaryColorstring
secondaryColorstring
tertiaryColorstring

setAuthCode(...)

setAuthCode(appId: string, authCode: string)

get AuthCode from hostapp backend and send it to miniapp


closeMiniapp(...)

closeMiniapp(appId: string)

close miniapp by appId


sendCustomEvent(...)

sendCustomEvent(customEventData: CustomEventData)

send custom event to miniapp

PropType
appIdstring
requestIdnumber
typestring
errorTypestring
payloadobject

sendPaymentEvent(...)

sendPaymentEvent(paymentData: PaymentData)

send payment data to miniapp

PropType
appIdstring
transactionTokenstring
miniappOrderIdstring
amountnumber
currencystring
statusstring
hostappOrderIdstring
extraParamsobject

getMiniapps()

getMiniapps()

Get list of miniapps. To get results subscribe to


hideMiniapps()

hideMiniapps()

Miniapp opens on a native screen. To show payment processing page need to hide miniapp screen. To use this function need to enable 'enableMultitaskMode: true' in Appboxo.setConfigs()


logout()

logout()

When host app user logs out, it is highly important to clear all miniapp storage data.


AuthListener

Boxo.addAuthListener((authEvent) => {
    Boxo.setAuthCode(authEvent.appId, authCode)
});

CustomEventListener

Boxo.addCustomEventListener((customEvent) => {
  ..handle custom event
});

PaymentEventListener

Boxo.addPaymentEventListener((paymentData) => {
  Boxo.hideMiniapps();
  .. show payment page
  paymentData.status = "success";
  ..confirm payment
  Boxo.sendPaymentEvent(paymentData);
  Boxo.openMiniapp({ appId: paymentData.appId })
});

MiniappLifecycleListener

Boxo.addMiniappLifecycleListener((lifecycleData) => {
  console.log(lifecycleData);
});
PropTypeDescription
appIdstring
lifecyclestringonLaunch - Called when the miniapp will launch with Appboxo.open(...) onResume - Called when the miniapp will start interacting with the user onPause - Called when the miniapp loses foreground state onClose - Called when clicked close button in miniapp or when destroyed miniapp page onError - Called when miniapp fails to launch due to internet connection issues onUserInteraction - Called whenever touch event is dispatched to the miniapp page. onAuth - Called when the miniapp starts login and user allows it
errorstring

MiniappListListener

Boxo.addMiniappListListener((result) => {
  console.log(result.miniapps);
});

Get miniapp list

PropType
miniappsMiniappData
errorstring

MiniappData

PropType
appIdstring
namestring
categorystring
descriptionstring
logostring
0.4.0

9 months ago

0.3.0

10 months ago

0.1.2

10 months ago

0.2.0

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago