Skip to content

5. Complete Example

Johann Buscail edited this page Sep 17, 2021 · 2 revisions

Here is a complete example where every prop is used:

enum CustomEvents {
    USER_LOGGED_IN = 'USER_LOGGED_IN',
    USER_LOGGED_OUT = 'USER_LOGGED_OUT'
}


<WebApp
    siteUrl="mysite.com"
    paymentPattern="sberbank.ru"

    fontName="Courrier"
    themeColor="orange"
    offlineText={{
      message: "your message",
      refreshButton: "the text on the button"
    }}

    requestNotificationPermission={true}
    onPushRegistered={({ pushToken, error }) => {
        if (error)
            return console.error("Error while push registration:", error);

        console.log("new push token", pushToken)
    }}

    customJSInjection={`
        setTimeout(() => {
        window.ReactNativeWebView.postMessage(
            JSON.stringify({
                event: "${CustomEvents.USER_LOGGED_IN}",
                jwt_token: "test123"
            })
        )
        }, 5000);
    `}

    customEvents={enumToArray(CustomEvents)}
    onCustomEvent={(event, data) => {
        console.log("Custom event", event, "with data", data);
    }}
/>
Clone this wiki locally