Skip to content

Error handling ​

Rejected promises carry a code:

ts
import { ErrorCodes, login } from 'react-native-zalo-kit';

try {
  await login();
} catch (e: any) {
  if (e.code === ErrorCodes.ZALO_NOT_INSTALLED) {
    // ask the user to install Zalo
  }
}

Zalo Kit codes ​

ErrorCodes:

codeMeaning
ZALO_NOT_INSTALLEDZalo app is not installed and web fallback is disabled.
ZALO_APP_INCOMPATIBLEZalo app is installed but could not open the login screen, and web fallback is disabled.
NOT_AUTHENTICATEDNo stored session. Call login().
NO_ACTIVITYNo foreground activity / view controller to start login from.
LOGIN_SUPERSEDEDA newer login() call, or logout(), replaced this one.
NOT_CONFIGUREDThe Zalo App ID is missing from the native project.
INVALID_RESPONSEZalo answered with an unexpected payload.

Zalo SDK codes ​

Other errors keep the numeric Zalo error code, as a string. Common ones:

codeMeaning
"-7008" (Android) / "-7035" (iOS)The user cancelled. On Android, -7008 is also returned when the Zalo app is installed but not logged in.
"-8001" (Android) / "-7024", "-7025" (iOS)Network or server error; retry later.
"-124", "-216", "-220", "-5004"The access token is invalid or expired. getUserProfile() already refreshes and retries once.

Full lists: Android, iOS.

Released under the MIT License.