Customization
Third-Party login
window.chatWidgetApi.thirdDIDLogin(address, thirdSignFunc, callBack)window.chatWidgetApi.thirdDIDLogin
Inject login status
address: user wallet address;
thirdSignFunc: Third party signer, eg. thirdSignFunc({ message});
callback: callback function after successful login
N/A
First, set
useThirdLoginon the widget component:<chat-component useThirdLogin={true} />.Call this API and provide the necessary parameters after the component has mounted, such as using useEffect, ComponentDidMount in React, or mounted in Vue. The
addressparameter represents the wallet address of the logged-in user (required), andthirdSignFuncis the signing function (required). When the API internally calls thethirdSignFuncsigning function, it will pass the parametermessage.thirdSignFuncshould use this message to trigger wallet signing and return the result of the signature. ThethirdDIDLoginAPI will wait forthirdSignFuncto complete and return, and then proceed with the login logic. Pseudocode example:
thirdDIDLogin(address, thirdSignFunc, callback) {
// Use address to call the the API and retrieve the corresponding DID.
const sign = await thirdSignFunc({message});
// Call didLogin(sign, ...otherParams) to perform the login.
// Upon successful login, call callback();
}The
callbackparameter is optional and can be used as needed. It will be invoked regardless of whether the login is successful or not. For a successful login, call callback(true), and for a failed login, call callback(false).
Visibility
window.chatWidgetApi.showWidget(isShow)window.chatWidgetApi.showWidget
Control Widget Visibility
isShow (required): Specifies whether the widget should be displayed. [Type]: Boolean
N/A
Last updated