Function: login()
ts
function login(authType?, options?): Promise<IZaloAuthResponse>;Signs the user in with Zalo and stores the resulting tokens on the device.
Calling login() again while a login is in progress rejects the earlier call with LOGIN_SUPERSEDED.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
authType? | LoginMethod | Constants.AUTH_VIA_APP_OR_WEB | How to sign in. Defaults to AUTH_VIA_APP_OR_WEB. |
options? | LoginOptions | {} | See LoginOptions. |
Returns
Promise<IZaloAuthResponse>
The token pair of the new session.
Throws
ZALO_NOT_INSTALLED, ZALO_APP_INCOMPATIBLE, NO_ACTIVITY, NOT_CONFIGURED, LOGIN_SUPERSEDED, INVALID_RESPONSE, or a numeric Zalo code such as "-7008" when the user cancels.
Example
ts
const { accessToken, expiresAt } = await login(Constants.AUTH_VIA_APP_OR_WEB);
// App only, but fall back to web if the Zalo app cannot be opened
await login(Constants.AUTH_VIA_APP, { fallbackToWeb: true });