diff --git a/Bark/AppDelegate.swift b/Bark/AppDelegate.swift index b9f9332..b0a2e47 100644 --- a/Bark/AppDelegate.swift +++ b/Bark/AppDelegate.swift @@ -53,65 +53,75 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let navigationController = ((self.window?.rootViewController as? BarkSnackbarController)? .rootViewController as? BarkNavigationController) - let alert = (userInfo["aps"] as? [String:Any])?["alert"] as? [String:Any] - let title = alert?["title"] as? String - let body = alert?["body"] as? String - let url:URL? = { - if let url = userInfo["url"] as? String { - return URL(string: url) + func presentController(){ + let alert = (userInfo["aps"] as? [String:Any])?["alert"] as? [String:Any] + let title = alert?["title"] as? String + let body = alert?["body"] as? String + let url:URL? = { + if let url = userInfo["url"] as? String { + return URL(string: url) + } + return nil + }() + + //URL 直接打开 + if let url = url { + if ["http","https"].contains(url.scheme?.lowercased() ?? ""){ + navigationController?.present(BarkSFSafariViewController(url: url), animated: true, completion: nil) + } + else{ + UIApplication.shared.open(url, options: [:], completionHandler: nil) + } + return } - return nil - }() - - //URL 直接打开 - if let url = url { - if ["http","https"].contains(url.scheme?.lowercased() ?? ""){ - navigationController?.present(BarkSFSafariViewController(url: url), animated: true, completion: nil) - } - else{ - UIApplication.shared.open(url, options: [:], completionHandler: nil) - } - return + + + let alertController = UIAlertController(title: title, message: body, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "复制内容", style: .default, handler: { (_) in + if let copy = userInfo["copy"] as? String { + UIPasteboard.general.string = copy + } + else{ + UIPasteboard.general.string = body + } + })) + alertController.addAction(UIAlertAction(title: "更多操作", style: .default, handler: { (_) in + var shareContent = "" + if let title = title { + shareContent += "\(title)\n" + } + if let body = body { + shareContent += "\(body)\n" + } + for (key,value) in userInfo { + if ["aps","title","body","url"].contains((key as? String) ?? "") { + continue + } + shareContent += "\(key): \(value) \n" + } + var items:[Any] = [] + items.append(shareContent) + if let url = url{ + items.append(url) + } + let controller = UIApplication.shared.keyWindow?.rootViewController + let activityController = UIActivityViewController(activityItems: items, + applicationActivities: nil) + controller?.present(activityController, animated: true, completion: nil) + })) + alertController.addAction(UIAlertAction(title: "取消", style: .cancel, handler: nil)) + + navigationController?.present(alertController, animated: true, completion: nil) } - - let alertController = UIAlertController(title: title, message: body, preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: "复制内容", style: .default, handler: { (_) in - if let copy = userInfo["copy"] as? String { - UIPasteboard.general.string = copy + if let presentedController = navigationController?.presentedViewController { + presentedController.dismiss(animated: false) { + presentController() } - else{ - UIPasteboard.general.string = body - } - })) - alertController.addAction(UIAlertAction(title: "更多操作", style: .default, handler: { (_) in - var shareContent = "" - if let title = title { - shareContent += "\(title)\n" - } - if let body = body { - shareContent += "\(body)\n" - } - for (key,value) in userInfo { - if ["aps","title","body","url"].contains((key as? String) ?? "") { - continue - } - shareContent += "\(key): \(value) \n" - } - var items:[Any] = [] - items.append(shareContent) - if let url = url{ - items.append(url) - } - let controller = UIApplication.shared.keyWindow?.rootViewController - let activityController = UIActivityViewController(activityItems: items, - applicationActivities: nil) - controller?.present(activityController, animated: true, completion: nil) - })) - alertController.addAction(UIAlertAction(title: "取消", style: .cancel, handler: nil)) - - navigationController?.present(alertController, animated: true, completion: nil) - + } + else{ + presentController() + } } diff --git a/Bark/Info.plist b/Bark/Info.plist index d150a46..1bd087b 100644 --- a/Bark/Info.plist +++ b/Bark/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.5 + 1.0.6 CFBundleVersion - 3 + 1 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/NotificationServiceExtension/Info.plist b/NotificationServiceExtension/Info.plist index 20559e8..d97bef3 100644 --- a/NotificationServiceExtension/Info.plist +++ b/NotificationServiceExtension/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 1.0.5 + 1.0.6 CFBundleVersion - 3 + 1 NSExtension NSExtensionPointIdentifier diff --git a/notificationContentExtension/Info.plist b/notificationContentExtension/Info.plist index 9e45367..9aae6c3 100644 --- a/notificationContentExtension/Info.plist +++ b/notificationContentExtension/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 1.0.5 + 1.0.6 CFBundleVersion - 3 + 1 NSExtension NSExtensionAttributes