Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] #134 addVolumeListener is not triggered on iOS 15 #139

Merged

Conversation

Igor-Tiukavkin
Copy link
Contributor

Issue

Number #134: iOS 15 addVolumeListener fix

The system volume observer is no longer working on iOS 15.

Steps for reproduce:

  1. Add system volume did change observer
  2. Play any media
  3. Change volume with hardware buttons at the device
  4. Change volume with volume control in the app

Expected behaviour:
Change of volume setting value is processed correctly

Current Result:
Hardware buttons volume change has no response.
NotificationCenter produces no notifications for key AVSystemController_SystemVolumeDidChangeNotification.

Problem:

There is an information on stackoverflow that observing of AVSystemController_SystemVolumeDidChangeNotification is no longer supported because it's a private API.

Solution

The solution is based on the answer: EWTDTHK2 commented on 3 Oct.
The correct approach is to add KVO observer for AVAudioSession instance for outputVolume keyPath.

@MrHjalmarsson
Copy link

Thanks for a very useful package!
Does anyone have an idea about when this PR will be merged?
Would be greatly appreciated if it could happen rather sooner than later. :)

@Shummy1991
Copy link

You can use patch-package until it is merged.

@MrHjalmarsson
Copy link

Thanks, @Shummy1991! Will try that!

@@ -37,13 +38,14 @@ @implementation RCTSystemSetting {
UISlider *volumeSlider;
}

-(void)dealloc {
Copy link

@kot331107 kot331107 Feb 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool that you introduced dealloc() and removed the subscription in it 👍 I did same in our project as a band-aid/patch-package and found your solution later. Good job!

Copy link

@kot331107 kot331107 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@c19354837 c19354837 merged commit e1d7a28 into c19354837:master Feb 16, 2022
@kolking
Copy link

kolking commented May 10, 2022

@c19354837 please publish a new release with this fix included.

1 similar comment
@buildgreatthings
Copy link

@c19354837 please publish a new release with this fix included.

@kot331107
Copy link

@awcchungster would patch-package work with you till guys won't publish it?

@arjun-mavonic
Copy link

This doesn't work if the app goes into background and then into foreground.

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

Successfully merging this pull request may close these issues.

9 participants