Skip to content

How do I handle Google services related errors on Android during initialization

Roman Kochkar edited this page Mar 4, 2020 · 2 revisions

SDK provides a method which you can call to display a system dialog which will help users resolve such issues. You will need to handle an error code provided by the library when initialization fails.

mobileMessaging.init({
    ...
    },
    () => {
        console.log('Init success');
    },
    error => {
        console.log('Init error', JSON.stringify(error));
        if (error.code) {
            displayErrorDialog(error.code);
        }
    }
);

function displayErrorDialog(errorCode) {
    mobileMessaging.showDialogForError(
        errorCode,
        () => {
          console.log("The issue was resolved by user");
          // re-init SDK
        },
        error => {
          console.log('User failed to resolve the issue', JSON.stringify(error));
        }
    );
}
...
Clone this wiki locally