-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fix] Network Delayed Activity Trampoline #1583
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand the phone offline -> tap notification fix.
I can't comprehend the Xiaomi part of the fix. Is it something like handleNotificationOpen
is added to the task queue, but it's removed before it gets to run?
I added a new section " Xiaomi - Background Restrictions" above to explain the Xiaomi limitation in more detail. The task queue is ok, you can call |
Ahhhh got it, thanks! |
41c6ab8
to
1c3e69e
Compare
We mock fail the network request to reproduce the issue where the app does not get foregrounded.
If the app process is shutting down we don't want to keep retrying the remote params network request. No real world problem have been discovered but it's possible it could be create some unexpected states while the app process is being shutdown. In the context of our tests, this also fixes an issue where this retrying does not stop when we mock fail this network request. This oddly enough didn't seem to be an issue for the one pre-existing test using failGetParams but became a consistent test carry over issue when a 2nd test used this, which was added in the last commit.
This fixes a bug where the app would not be brought to the foreground when tapping on a notification if the app could not connect to onesignal.com or was offline during the full life time of the app process. This also fixes another a compatibility issue with Xiaomi devices where the app would not foreground if the app process was dead and also no task exists in the recent list. It is critical we don't wait for a network call for the notification open logic this method does the work to bring the app to the foreground. This get params network call isn't needed before we handle the notification open logic anyway. This network wait was present in 4.0.0 through 4.4.x but was not an issue in 4.5.0 when a "Reverse Activity Trampoline" was setup. However in PR #1581 we are switching back to a standard Activity Trampoline and we don't want to reintroduce this bug. A failing test was added for this in a previous commit, which now passes.
3f6712b
to
23cc934
Compare
This branch is based on
|
Description
One Line Summary
Removes a network call dependency on notification open logic which effects foregrounding the app.
Details
Motivation
Scope
Target scope is the fix the bug noted above.
A secondary fix was made to improve the app shutdown process to stop retrying to get remote params when its thread is interrupted. This fix was only required in this PR to resolve a test carry over issue with the test added in this PR.
Background
The fixes in this PR fixes a discovered issue in 4.0.0 to 4.4.x, but is not an issue in 4.5.0 to 4.7.2. However this fix needs to be shipped with #1581 as it reverts most of the changes in #1377 that was shipped in 4.5.0.
Xiaomi - Background Restrictions
The following was observed through testing on a Xiaomi Redmi 6A running Android 9 on MIUI Global 11.0.8 | Stable 11.0.8.0 (PCBMIXM):
PendingIntent
to start anActivity
and then you trampoline to anotherActivity
you MUST callstartActivity
BEFORE finishing the firstActivity
. Otherwise thestartActivity
is ignored.Testing
Unit testing
Manual testing
Tested on:
Test both offline and online.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is