hirbod / react-native-volume-manager

React Native module which adds the ability to change the system volume on iOS and Android, listen to volume changes and supress the native volume UI to build your own volume slider or UX. It can listen to iOS mute switch and ringer mode changes on Android (and let you set the ringer mode)
MIT License
216 stars 13 forks source link

Crash on android : Receiver not registered #9

Closed farhan-spinny closed 1 year ago

farhan-spinny commented 1 year ago

On firebase I am getting this error for some devices. Implementation is working for almost all other users.

VolumeManagerModule.unregisterVolumeReceiver

Fatal Exception: java.lang.RuntimeException: Unable to pause activity {com.my.package/com.my.package.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: com.reactnativevolumemanager.VolumeManagerModule$b@8a8518c
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:5396)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:5347)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:5294)
       at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:53)
       at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2466)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:240)
       at android.os.Looper.loop(Looper.java:351)
       at android.app.ActivityThread.main(ActivityThread.java:8380)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
useEffect(() => {
  const volumeListener = VolumeManager.addVolumeListener((result) => {
    console.log(result.volume);
  });

  return function () {
    volumeListener.remove();
  }
}, []);

Any suggestions?

hirbod commented 1 year ago

I have a fix for this ready in the upcoming version

hirbod commented 1 year ago

Version 1.3.0 has been released. This issue is resolved now. Thanks for reporting!