Closed mcleodtech closed 1 year ago
I noticed one important thing. When the app is closed or in background the plugin does try to start the activity again, but for that it requires the permissions SYSTEM_ALERT_WINDOW, which is the ability to display popups, Have to manually set them. For the user to be able to permit you must have this:
Also some popular apps, do have this permitted automatically "popular apps" have that grant according to google. Maybe thats what helps to keep the notification happening.
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/uses-permission" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
</edit-config>
This will start the activity again if you data payload contains for example this:
"data" => [
"content-available" => "1",
"force-start" => "1",
],
@MiguelQueiroz Thank you so much! I'm going to test it out and let you know how it works!
This worked! Closing this out.
Bug Report
Expected Behaviour
The Cordova app is force closed, a push notification is sent to the device and the device displays the notification using the native android notification settings (the shade may show notification and notification appears in notification tray).
Actual Behaviour
A push notification is not received. Not sure if this is a bug, or just my own error.
Reproduce Scenario (including but not limited to)
I have only reproduced this on Android when force closing an app (to test the receipt of a notification when the app process is no longer running on Android). Background notifications seem to work fine, as well as foreground notifications on iOS and Android. I cannot reproduce this on iOS.
Steps to Reproduce
Build an Android App Force close app by going to Settings => Apps => {App Name} => Press "Force Stop" Send a push notification to the device
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Android 11
(Android) Device Vendor (e.g. Samsung, HTC, Sony...)
Samsung
cordova info
PrintoutCordova Packages:
Project Installed Platforms:
Project Installed Plugins:
Environment:
Project Setting Files:
<?xml version='1.0' encoding='utf-8'?>
--- Start of Cordova JSON Snippet ---
--- End of Cordova JSON Snippet ---
Sample Push Data Payload
Sample Code that illustrates the problem
Logs taken while reproducing problem
I don't have a log for a background notification.