Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

No notification sound when app is in foreground on Android, using forceShow: true #2749

Open
BobDankert opened this issue Apr 22, 2019 · 2 comments

Comments

@BobDankert
Copy link

Expected Behavior

My app does not play any sounds when running in the foreground and a notification is received. It vibrates and the notification is in the notification tray, however no sound.

Actual Behavior

There is no sound when the notification is received.

Reproduce Scenario (including but not limited to)

Send notification as below, using forceShow: true, and app in the notification.

Steps to Reproduce

Send notification as below, using forceShow: true, and app in the notification.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 9

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Android Pixel 2 XL

Cordova CLI version and cordova platform version

Cordova version: 8.1.2
Cordova Android version: 7.1.0

Plugin version

Push Plugin version: 2.2.3

Sample Push Data Payload

Passed to FCM:
{
notification: {
title: 'New Message',
body: "DEBUG: This is a test'
sound: "default",
soundname: "default",
color: "#e8b73f",
icon: 'aryv_icon_white',
foreground: "true"
}
}

Data object received in notification.on:
{
"sound": "default",
"title": "New Message",
"message": "DEBUG: This is a test",
"additionalData": {
"icon": "aryv_icon_white",
"color": "#e8b73f",
"dismissed": false,
"coldstart": false,
"foreground": false
}
}

Sample Code that illustrates the problem

Init code:
self.pushNotification = PushNotification.init({
android: {
senderID: window.appConfig.firebase.messagingSenderId,
sound: true,
vibrate: true,
forceShow: true,
icon: 'aryv_icon_white',
iconColor: '#E5B63D'
}
});

Logs taken while reproducing problem

04-22 11:43:02.604 1188 1188 E NotificationService: Muting recently noisy 0|com.envisionitllc.drmmessengerapp|0|Aryv Driver|10322
04-22 11:43:02.614 1713 27216 W MediaPlayer: Couldn't open android.resource://com.envisionitllc.drmmessengerapp/raw/true: java.io.FileNotFoundException: No resource found for: android.resource://com.envisionitllc.drmmessengerapp/raw/true
04-22 11:43:02.629 920 27219 E FileSource: Failed to open file 'android.resource://com.envisionitllc.drmmessengerapp/raw/true'. (No such file or directory)
04-22 11:43:02.641 1713 27216 W RingtonePlayer: error loading sound for android.resource://com.envisionitllc.drmmessengerapp/raw/true
04-22 11:43:02.715 25493 23334 W MediaPlayer: Couldn't open android.resource://com.envisionitllc.drmmessengerapp/raw/true: java.io.FileNotFoundException: No resource found for: android.resource://com.envisionitllc.drmmessengerapp/raw/true
04-22 11:43:02.718 920 27228 E FileSource: Failed to open file 'android.resource://com.envisionitllc.drmmessengerapp/raw/true'. (No such file or directory)
04-22 11:43:02.740 25493 27230 W MediaPlayer: Couldn't open android.resource://com.envisionitllc.drmmessengerapp/raw/true: java.io.FileNotFoundException: No resource found for: android.resource://com.envisionitllc.drmmessengerapp/raw/true
04-22 11:43:02.742 920 27233 E FileSource: Failed to open file 'android.resource://com.envisionitllc.drmmessengerapp/raw/true'. (No such file or directory)

@spacesuitdiver
Copy link

We are having a similar issue but maybe unrelated. One thing I notice from your logs is this seems odd I think /raw/true should be /raw/filename.

@BobDankert
Copy link
Author

I've switched to using forceShow: false and using on('notification') to play a notification, using the cordova-plugin-dialogs plugin with the navigator.notification.beep(1) function. This is working well as a workaround, though it would be ideal if forceShow: true worked with notifications sounds in the foreground.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants