[Fix] Call initWithContext on all entry points#2018
Merged
Conversation
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 commit 893381b. In this commit an issue was discovered in NotificationGenerationWorker. It almost always runs after receiving a push, but not guaranteed. It was checking for OneSignal.isInitialized but instead should always call initWithContext 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 the initWithContext behavior to be safe.
nan-li
approved these changes
Mar 12, 2024
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
initWithContexton all entry points where the app process can start, fixing the inconsistencies in initialization which addresses some rare edge cases.Details
We call
OneSignal.initWithContexton 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.isInitializedbut instead should always callinitWithContextas it can be an entry point to the app process.The
ADMMessageHandlerJobmay or may not have had an issue, but we matched up theinitWithContextbehavior 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