Browse Source

URLHandler: Handle presentation of alert correctly

The presentation should at least be handled by the rootViewController.

Closes #677
Soomin Lee 5 years ago
parent
commit
05136d6b5a
1 changed files with 8 additions and 1 deletions
  1. 8 1
      Sources/URLHandler.swift

+ 8 - 1
Sources/URLHandler.swift

@@ -181,7 +181,14 @@ public class VLCCallbackURLHandler: NSObject, VLCURLHandler {
                 self.play(url: transformedURL, completion: nil)
                 self.play(url: transformedURL, completion: nil)
             }
             }
             alert.addAction(playAction)
             alert.addAction(playAction)
-            alert.show(UIApplication.shared.keyWindow!.rootViewController!, sender: nil)
+
+            var rootViewController = UIApplication.shared.keyWindow?.rootViewController
+            if let tabBarController = UIApplication.shared.keyWindow?.rootViewController
+                as? UITabBarController {
+                rootViewController = tabBarController.selectedViewController
+            }
+            rootViewController?.present(alert, animated: true, completion: nil)
+
         } else {
         } else {
             self.play(url: transformedURL, completion: nil)
             self.play(url: transformedURL, completion: nil)
         }
         }