Skip to content

Fix/android load with keys crash on start - #146

Open
simonljus wants to merge 2 commits into
capacitor-community:masterfrom
Pushappy:fix/android-loadWithKeys-crash-on-start
Open

Fix/android load with keys crash on start#146
simonljus wants to merge 2 commits into
capacitor-community:masterfrom
Pushappy:fix/android-loadWithKeys-crash-on-start

Conversation

@simonljus

Copy link
Copy Markdown

Extending the previous PR #145

When using loadWithKeys instead of capacitor config, the app crashes on start because the params are expected.

ThIs PR will check if the values are defined and skip the initialization logic (assuming the user of the plugin will call loadWithKeys at some point).

Current workaround is catching the error.

// MainActivity.java
public class MainActivity extends BridgeActivity {

    @Override
    public void onStart() {
        try {
            super.onStart();
        } catch (IllegalStateException e) {
            if (isIntercomInitError(e)) {
                Logger.error("MainActivity", "Suppressed Intercom init crash on onStart", e);
            } else {
                throw e;
            }
        }
    }

    private boolean isIntercomInitError(IllegalStateException e) {
        // check if the error comes from Intercom plugin
        return false;
    }
}

What can be improved

For all the other plugin methods, conditionally check if initialized or not and call.reject(REASON)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant