Improvement: failure message shows that appID is missing #2506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Update the failure message so it is clear when appID is previously not provided.
Details
Motivation
The original failure message "Initialization failed. Cannot proceed." is vague and can potentially hide the real cause when appID is not provided as expected. We want to show this message so developers can immediately figure out the wrong usage.
Scope
OneSignalImp.kt will now save and throw a clearer error message when OneSignal is accessed before initWithContext is called with an appID.
Comparison with 5.1.x behavior
5.1.x:
Caused by: java.lang.Exception: Must call 'initWithContext' before use5.4.x:
suspendInitInternal: no appId provided or found in local storage. Please pass a valid appId to initWithContext().Testing
Unit testing
Add a new test case to assert the error message.
Manual testing
Tested on Emulator Pixel 9 API 35:
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is