Skip to content

Commit 0740cdf

Browse files
fix(SoundVolume): addVolumeListener callback have same behaviour
* Fix SoundVolume addVolumeListener callback have the same behaviour on Android and iOS * Fix c19354837#102 * Fix c19354837/issues/102
1 parent 3b276be commit 0740cdf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ios/RTCSystemSetting.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,18 @@ +(BOOL)requiresMainQueueSetup{
9696
}
9797

9898
RCT_EXPORT_METHOD(setVolume:(float)val config:(NSDictionary *)config){
99+
[self stopObserving];
100+
99101
dispatch_sync(dispatch_get_main_queue(), ^{
100102
id showUI = [config objectForKey:@"showUI"];
101103
[self showVolumeUI:(showUI != nil && [showUI boolValue])];
102104
volumeSlider.value = val;
105+
106+
__weak RCTSystemSetting *weakSelf = self;
107+
[[NSNotificationCenter defaultCenter] addObserverForName:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
108+
__strong RCTSystemSetting *strongSelf = weakSelf;
109+
[strongSelf startObserving];
110+
}];
103111
});
104112
}
105113

0 commit comments

Comments
 (0)