react-native-onesignal icon indicating copy to clipboard operation
react-native-onesignal copied to clipboard

[Bug]: Sound not playing on Android 11 / Android 13

Open jbrodriguez opened this issue 2 years ago • 7 comments

What happened?

i set up 3 emulators on my mac

  • Pixel 3a (with Android 13)
  • Pixel 5 (with Android 12)
  • Pixel 5 (with Android 11)

i then pushed a notification with a custom sound, it worked on android 12, but doesn't work on android 11 or android 13

Steps to reproduce?

1. Install react-native-onesignal v4.5.1 on React Native 0.71.12
2. Push a notification with custom sound with the app killed
3. Wait for the notification sound

What did you expect to happen?

i expected the custom sound to be played, but it doesn't on android 11 nor android 13, it does work on android 12 🤷‍♂️

please note that i've placed the custom sound in both

  • /app/res/raw
  • /app/src/main/res/raw

React Native OneSignal SDK version

4.5.1

Which platform(s) are affected?

  • [ ] iOS
  • [X] Android

Relevant log output

07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: Work [ id=c1f1f0fe-08a1-48ef-b45f-4278fa9653f7, tags={ FOCUS_LOST_WORKER_TAG, com.onesignal.OSFocusHandler$OnLostFocusWorker } ] failed because it threw an exception/error
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:311)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at java.lang.Thread.run(Thread.java:1012)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.OSUtils.packageInstalledAndEnabled(OSUtils.java:275)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.OSUtils.isGMSInstalledAndEnabled(OSUtils.java:288)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.OSUtils.supportsGooglePush(OSUtils.java:330)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.OSUtils.getDeviceType(OSUtils.java:349)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.OSUtils.isAndroidDeviceType(OSUtils.java:371)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.LocationController.isGooglePlayServicesAvailable(LocationController.java:337)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.LocationController.onFocusChange(LocationController.java:325)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.OneSignal.onAppLostFocus(OneSignal.java:1352)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.OSFocusHandler$Companion.onLostFocusDoWork(OSFocusHandler.kt:144)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at com.onesignal.OSFocusHandler$OnLostFocusWorker.doWork(OSFocusHandler.kt:123)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	at androidx.work.Worker$1.run(Worker.java:86)
07-24 15:42:00.462 10477 10511 E WM-WorkerWrapper: 	... 3 more
07-24 15:42:00.467 10477 10511 I WM-WorkerWrapper: Worker result FAILURE for Work [ id=c1f1f0fe-08a1-48ef-b45f-4278fa9653f7, tags={ FOCUS_LOST_WORKER_TAG, com.onesignal.OSFocusHandler$OnLostFocusWorker } ]

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

jbrodriguez avatar Jul 24 '23 20:07 jbrodriguez

additionally, this is the settings on an android 13, the custom sound is set, but it just doesn't play

Screenshot_1690292594

jbrodriguez avatar Jul 25 '23 13:07 jbrodriguez

Hi @jbrodriguez thank you for reaching out! We're working on reproducing this and will get back to you as soon as possible.

jennantilla avatar Jul 26 '23 23:07 jennantilla

Any updates about this one?

lucasfontinele avatar Jul 31 '23 14:07 lucasfontinele

Hello, I use react-native: 0.69.5 and react-native-onesignal: "^4.5.1"

And after testing, our team noticed that on Android version 12, push notifications come without sound, we set up custom sound, but it does not work on android version 12.

Kasik-D avatar Aug 03 '23 12:08 Kasik-D

I am also not able to play the custom notification sound on Android. On the latest version of the OneSignal RN SDK

pranshuchittora avatar Jan 18 '24 11:01 pranshuchittora

I'm having trouble too!

Janskiproducer avatar Apr 10 '24 14:04 Janskiproducer

same issue with the ionic integration. Any update on the matter?

marshall86 avatar Jul 16 '24 07:07 marshall86