Skip to content

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

Željko Brcković edited this page May 17, 2023 · 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(
    { ... },
    function (error) {
        console.log('Init error: ' + error.description);
        if (error.code) {
            displayErrorDialog(error.code);
        }
    }
);

function displayErrorDialog(errorCode) {
    MobileMessaging.showDialogForError(errorCode, function () {
          console.log('The issue was resolved by user');
          // re-init SDK
      }, function (error) {
          console.log('User failed to resolve the issue: " + error.description);
      });
};
...
expand to see Ionic code

MobileMessaging.init(
    { ... },
    function (error) {
        console.log('Init error: ' + error.description);
        if (error.code) {
            displayErrorDialog(error.code);
        }
    }
);

function displayErrorDialog(errorCode) {
    MobileMessaging.showDialogForError(errorCode).then(function () {
        console.log("The issue was resolved by user");

        // re-init SDK
    }, function(error) {
        console.log("User failed to resolve the issue: " + error.description);
    });
};
...
Clone this wiki locally