mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
修复停留在网页浏览页面时点击推送无响应的问题。
This commit is contained in:
parent
b6f31bd3dc
commit
8ae3b29bd5
@ -53,65 +53,75 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
|
|
||||||
let navigationController = ((self.window?.rootViewController as? BarkSnackbarController)?
|
let navigationController = ((self.window?.rootViewController as? BarkSnackbarController)?
|
||||||
.rootViewController as? BarkNavigationController)
|
.rootViewController as? BarkNavigationController)
|
||||||
let alert = (userInfo["aps"] as? [String:Any])?["alert"] as? [String:Any]
|
func presentController(){
|
||||||
let title = alert?["title"] as? String
|
let alert = (userInfo["aps"] as? [String:Any])?["alert"] as? [String:Any]
|
||||||
let body = alert?["body"] as? String
|
let title = alert?["title"] as? String
|
||||||
let url:URL? = {
|
let body = alert?["body"] as? String
|
||||||
if let url = userInfo["url"] as? String {
|
let url:URL? = {
|
||||||
return URL(string: 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
|
|
||||||
}()
|
|
||||||
|
let alertController = UIAlertController(title: title, message: body, preferredStyle: .alert)
|
||||||
//URL 直接打开
|
alertController.addAction(UIAlertAction(title: "复制内容", style: .default, handler: { (_) in
|
||||||
if let url = url {
|
if let copy = userInfo["copy"] as? String {
|
||||||
if ["http","https"].contains(url.scheme?.lowercased() ?? ""){
|
UIPasteboard.general.string = copy
|
||||||
navigationController?.present(BarkSFSafariViewController(url: url), animated: true, completion: nil)
|
}
|
||||||
}
|
else{
|
||||||
else{
|
UIPasteboard.general.string = body
|
||||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
}
|
||||||
}
|
}))
|
||||||
return
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let presentedController = navigationController?.presentedViewController {
|
||||||
let alertController = UIAlertController(title: title, message: body, preferredStyle: .alert)
|
presentedController.dismiss(animated: false) {
|
||||||
alertController.addAction(UIAlertAction(title: "复制内容", style: .default, handler: { (_) in
|
presentController()
|
||||||
if let copy = userInfo["copy"] as? String {
|
|
||||||
UIPasteboard.general.string = copy
|
|
||||||
}
|
}
|
||||||
else{
|
}
|
||||||
UIPasteboard.general.string = body
|
else{
|
||||||
}
|
presentController()
|
||||||
}))
|
}
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,9 +17,9 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.5</string>
|
<string>1.0.6</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>3</string>
|
<string>1</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSAppTransportSecurity</key>
|
<key>NSAppTransportSecurity</key>
|
||||||
|
|||||||
@ -17,9 +17,9 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>XPC!</string>
|
<string>XPC!</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.5</string>
|
<string>1.0.6</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>3</string>
|
<string>1</string>
|
||||||
<key>NSExtension</key>
|
<key>NSExtension</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSExtensionPointIdentifier</key>
|
<key>NSExtensionPointIdentifier</key>
|
||||||
|
|||||||
@ -17,9 +17,9 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>XPC!</string>
|
<string>XPC!</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.5</string>
|
<string>1.0.6</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>3</string>
|
<string>1</string>
|
||||||
<key>NSExtension</key>
|
<key>NSExtension</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSExtensionAttributes</key>
|
<key>NSExtensionAttributes</key>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user