Skip to content

Commit

Permalink
use popup controller to make share work on ipads
Browse files Browse the repository at this point in the history
  • Loading branch information
claptimes5 committed Mar 25, 2020
1 parent 0ee3cb6 commit fa62160
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/Classes/SwiftFlutterSharePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ public class SwiftFlutterSharePlugin: NSObject, FlutterPlugin {
activityViewController.setValue(title, forKeyPath: "subject");
}

// For iPads, fix issue where Exception is thrown by using a popup instead
if UIDevice.current.userInterfaceIdiom == .pad {
activityViewController.popoverPresentationController?.sourceView = UIApplication.topViewController()?.view
if let view = UIApplication.topViewController()?.view {
activityViewController.popoverPresentationController?.permittedArrowDirections = []
activityViewController.popoverPresentationController?.sourceRect = CGRect(x: view.bounds.midX, y: view.bounds.midY, width: 0, height: 0)
}
}

DispatchQueue.main.async {
UIApplication.topViewController()?.present(activityViewController, animated: true, completion: nil)
}
Expand Down

0 comments on commit fa62160

Please sign in to comment.