0.3.1 • Published 10 months ago

@appboxo/capacitor-boxo-sdk v0.3.1

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

capacitor-boxo-sdk

A Capacitor wrapper over Appboxo SDK for IOS and Android.

Install

npm install @appboxo/capacitor-boxo-sdk
npx cap sync

API

setConfig(...)

setConfig(options: ConfigOptions) => Promise<void>

Set global configs

ParamType
optionsConfigOptions

openMiniapp(...)

openMiniapp(options: OpenMiniappOptions) => Promise<void>

Open miniapp with options

ParamType
optionsOpenMiniappOptions

setAuthCode(...)

setAuthCode(options: { appId: string; authCode: string; }) => Promise<void>

get AuthCode from hostapp backend and send it to miniapp

ParamType
options{ appId: string; authCode: string; }

closeMiniapp(...)

closeMiniapp(options: { appId: string; }) => Promise<void>

close miniapp by appId

ParamType
options{ appId: string; }

sendCustomEvent(...)

sendCustomEvent(customEvent: CustomEvent) => Promise<void>

send custom event to miniapp

ParamType
customEventCustomEvent

sendPaymentEvent(...)

sendPaymentEvent(paymentEvent: PaymentEvent) => Promise<void>

send payment event to miniapp

ParamType
paymentEventPaymentEvent

getMiniapps()

getMiniapps() => Promise<MiniappListResult>

Get list of miniapps

Returns: Promise<MiniappListResult>


hideMiniapps()

hideMiniapps() => Promise<void>

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()


addListener('custom_event', ...)

addListener(eventName: 'custom_event', listenerFunc: (customEvent: CustomEvent) => void) => Promise<PluginListenerHandle>

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

ParamType
eventName'custom_event'
listenerFunc(customEvent: CustomEvent) => void

Returns: Promise<PluginListenerHandle>


addListener('payment_event', ...)

addListener(eventName: 'payment_event', listenerFunc: (paymentEvent: PaymentEvent) => void) => Promise<PluginListenerHandle>
ParamType
eventName'payment_event'
listenerFunc(paymentEvent: PaymentEvent) => void

Returns: Promise<PluginListenerHandle>


addListener('miniapp_lifecycle', ...)

addListener(eventName: 'miniapp_lifecycle', listenerFunc: (lifecycle: LifecycleEvent) => void) => Promise<PluginListenerHandle>
ParamType
eventName'miniapp_lifecycle'
listenerFunc(lifecycle: LifecycleEvent) => void

Returns: Promise<PluginListenerHandle>


logout()

logout() => Promise<void>

Interfaces

ConfigOptions

PropTypeDescription
clientIdstringyour client id from dashboard
userIdstringhostapp userId, will be used for the Consent Management
languagestringlanguage value will be passed to the miniapp
sandboxModebooleanswitch to sandbox mode
enableMultitaskModebooleanEach 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
showAboutPagebooleanuse it to hide "About Page" from Miniapp menu
miniappSettingsExpirationTimenumberuse it to change miniapp settings cache time in sec. By default is 60 sec

OpenMiniappOptions

PropTypeDescription
appIdstringminiapp id
dataobject(optional) data as Map that is sent to miniapp
theme'light' | 'dark' | 'system'(optional) miniapp theme "dark" | "light" (by default is system theme)
extraUrlParamsobject(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)
colorsColorOptions(optional) provide colors to miniapp if miniapp supports
enableSplashboolean(optional) use to skip miniapp splash screen
saveStateboolean(optional) use to save state on close miniapp

ColorOptions

PropType
primaryColorstring
secondaryColorstring
tertiaryColorstring

CustomEvent

PropType
appIdstring
requestIdnumber
typestring
errorTypestring
payloadobject

PaymentEvent

PropType
appIdstring
transactionTokenstring
miniappOrderIdstring
amountnumber
currencystring
statusstring
hostappOrderIdstring
extraParamsobject

MiniappListResult

PropType
miniappsMiniappData
errorstring

MiniappData

PropType
appIdstring
namestring
categorystring
descriptionstring
logostring

PluginListenerHandle

PropType
remove() => Promise<void>

LifecycleEvent

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
0.3.1

10 months ago

0.3.0

10 months ago

0.2.8

10 months ago

0.2.7

10 months ago

0.1.8

10 months ago

0.2.6

10 months ago

0.1.6

11 months ago

0.2.4

11 months ago

0.2.3

11 months ago

0.2.1

11 months ago

0.2.0

11 months ago

0.1.4

11 months ago

0.2.2

11 months ago

0.1.3

12 months ago

0.1.5

11 months ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago