Audio still playing after closing Safari View Controller
mblistan opened this issue · comments
In case when page contains audio file, after closing the Safari View Controller and returning back to previous screen, the audio is still playing.
I guess this is an issue with the safari view rather than with this library per se
I tried the exact same link in other app (native), after dismissing Safari View audio stopped playing.
I've been running into this issue as well. Has anyone found a workaround?
Might have been solved with #85, since there the safari view is explicitly deallocated. Can you try with the current master?
@koenpunt could you release a new npm package?
What's the status on this?
@redreceipt not sure where the maintainer went but I've been using the latest commit on my project while we wait for an updated npm package:
yarn add git://github.com/naoufal/react-native-safari-view@d828e79
It looks like there's a bug in SafariViewManager.m safariViewControllerDidFinish: where the SafariViewController is never actually dismissed when the user hits the 'dismiss' button. And since that method sets _safariView = nil before notifying any onDismiss listeners, even if one of them subsequently called dismiss( ) it wouldn't help.
So the call to dismiss needs to be done as the first action in safariViewControllerDidFinish: like this:
-(void)safariViewControllerDidFinish:(nonnull SFSafariViewController *)controller
{
[_safariView dismissViewControllerAnimated:true completion:nil];
_safariView = nil;
NSLog(@"[SafariView] SafariView dismissed.");
if (hasListeners) {
[self sendEventWithName:@"SafariViewOnDismiss" body:nil];
}
}