[Android] Add data/background message support #876
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
[Android] Add data/background message support
Details
Motivation
Since onesignal-cordova-plugin@3 we have no possibility to send data message without showing popup like a:
To process data message with content_available=true on Android I propose to add OSRemoteNotificationReceivedHandler
according to https://documentation.onesignal.com/docs/data-notifications#android-data-notification-setup
https://documentation.onesignal.com/docs/service-extensions#android-notification-service-extension
And notify about data/background message via setNotificationWillShowInForegroundHandler. So client API is not changed.
See
#835
#865
#875
Scope
Android
OPTIONAL - Other
Testing
Unit testing
Manual testing
I subscribe on setNotificationWillShowInForegroundHandler() in application:
Run one on Android emulator from Android 7 to Android 12.
Send to application data message:
And I see in a log the following:
We get data message notification as expected.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is