To use the Profile flow you must request a JWT token with the participant-profile
permission
Web Application
Requires zh-web-sdk v2.9.0 or higher
Example using React:
import React from 'react';
import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';
const App = () => {
const sdk = new ZeroHashSDK({
zeroHashAppsURL: "https://web-sdk.cert.zerohash.com",
profileJWT: "<JWT_TOKEN_HERE>"// request a JWT with "participant-profile" permission
});
sdk.openModal({
appIdentifier: AppIdentifier.PROFILE
})
return <></>;
}
export default App;
Mobile Application (WebView)
To use our SDK on mobile apps, you don't need to install or include zh-web-sdk as a dependency in your project. We use a proxy server that calls the SDK internally to make it work for mobile applications.
Events
We forward events from the UI to the native app using the postMessage API. You can handle these events from the WebView component. Currently, these are the events we have:
Message | Meaning |
---|---|
SDK_MOBILE_READY | The SDK is ready to receive postMessage events (e.g OPEN_MODAL) |
PROFILE_APP_LOADED | The SDK is loadedSDK loaded and is visible to the customer. |
PROFILE_CLOSE_BUTTON_CLICKED | The close (X) button was clicked in the top right corner of the UI. This action hides the modal while preserving the UI state. When reopened in the same instance, the UI will display with the state it had when it was closed. |
Messages
To control the WebView, you can also send messages using the postMessage API after receiving SDK_MOBILE_READY
from WebView. Currently, the accepted messages are:
Open Modal
Opens the modal with the JWT provided for identifier provided.
{type: "OPEN_MODAL", payload: {
jwt: "<JWT_HERE>",
appIdentifier: "profile"
}}
Close Modal
Hides the modal while preserving its current state. When the modal is reopened in the same instance, the state will be maintained.
{type: "CLOSE_MODAL", payload:{appIdentifier: "profile"}}
Opening/closing the modal can be interpreted as pausing/resuming, since the UI will retain the state it had when it was closed. To restart the UI flow, a new modal instance must be created.
For more details on how to use our SDK with WebViews, please refer to Integration with Mobile Apps