diff --git a/ios/Capacitor/Capacitor/CAPPlugin.h b/ios/Capacitor/Capacitor/CAPPlugin.h index 6956d6635..b41c4585b 100644 --- a/ios/Capacitor/Capacitor/CAPPlugin.h +++ b/ios/Capacitor/Capacitor/CAPPlugin.h @@ -34,5 +34,6 @@ -(NSString *) getString:(CAPPluginCall *)call field:(NSString *)field defaultValue:(NSString *)defaultValue; -(id)getConfigValue:(NSString *) key; -(void)setCenteredPopover:(UIViewController *) vc; +-(BOOL)supportsPopover; @end diff --git a/ios/Capacitor/Capacitor/CAPPlugin.m b/ios/Capacitor/Capacitor/CAPPlugin.m index 5e0c98479..f0fe9e14e 100644 --- a/ios/Capacitor/Capacitor/CAPPlugin.m +++ b/ios/Capacitor/Capacitor/CAPPlugin.m @@ -147,5 +147,13 @@ -(void)setCenteredPopover:(UIViewController *) vc { vc.popoverPresentationController.permittedArrowDirections = 0; } +-(BOOL)supportsPopover { + if (@available(iOS 13, *)) { + return YES; + } else { + return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad; + } +} + @end diff --git a/ios/Capacitor/Capacitor/Plugins/Browser.swift b/ios/Capacitor/Capacitor/Plugins/Browser.swift index f7be28a67..0a1a91529 100644 --- a/ios/Capacitor/Capacitor/Plugins/Browser.swift +++ b/ios/Capacitor/Capacitor/Plugins/Browser.swift @@ -23,7 +23,7 @@ public class CAPBrowserPlugin : CAPPlugin, SFSafariViewControllerDelegate { self.vc = SFSafariViewController.init(url: url!) self.vc!.delegate = self let presentationStyle = call.getString("presentationStyle") - if presentationStyle != nil && presentationStyle == "popover" && UIDevice.current.userInterfaceIdiom == .pad { + if presentationStyle != nil && presentationStyle == "popover" && self.supportsPopover() { self.vc!.modalPresentationStyle = .popover self.setCenteredPopover(self.vc) } else {