[Fix] Call initWithContext on all entry points #2018
Merged
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
Call
initWithContext
on all entry points where the app process can start, fixing the inconsistencies in initialization which addresses some rare edge cases.Details
We call
OneSignal.initWithContext
on most entry points but some were missed. Consistency is important as differences can lead to edge case bugs that are hard to reproduce and debug.One recent example of this was with
ReceiveReceiptWorker
, its inconsistency lead to a hard to debug issue that was uncovered by PR #2012In this PR an issue was discovered in
NotificationGenerationWorker
. It almost always runs after receiving a push, but not guaranteed. It was checking forOneSignal.isInitialized
but instead should always callinitWithContext
as it can be an entry point to the app process.The
ADMMessageHandlerJob
may or may not have had an issue, but we matched up theinitWithContext
behavior to be safe.Related issues
Should fix #1282
Motivation
Initialization consistency is important as differences can lead to edge case bugs that are hard to reproduce and debug.
Scope
Only effects initialization on internal entry points for OneSignal events.
Testing
Unit testing
No unit test coverage exists on these entry points, to test such code these would have to be abstracted out which is out of scope of this PR.
Manual testing
Ensure notifications are displayed on an Android 6 emulator, both when the app process is in the background when it it was stopped.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is