Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(ios): allow Browser popover presentation if supported #2784

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ios/Capacitor/Capacitor/CAPPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions ios/Capacitor/Capacitor/CAPPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion ios/Capacitor/Capacitor/Plugins/Browser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down