application openURL in Swift
This is fairly typical of a signature mismatch between the method signatures automatically generated by the Swift compiler and the actual signature. It happens when you try to pass nil from Objective-C into a Swift explicitly unwrapped optional. Change the annotation
parameter to be implicitly unwrapped and you should be gtg.
Method 'application:openURL:options:' is not called
Implement scene(_:openURLContexts:)
in your scene delegate.
If the URL launches your app, you will get scene(_:willConnectTo:options:)
instead and it’s in the options
.
How to open an URL in Swift?
All you need is:
guard let url = URL(string: "http://www.google.com") else {
return //be safe
}
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
application:openUrl:options not called when opening app from share sheet of another app
If your app is using scenes, then instead of application(_:open:options:)
from UIApplicationDelegate
protocol, iOS will call scene(_:openURLContexts:)
from UISceneDelegate
.
https://developer.apple.com/documentation/uikit/uiscenedelegate/3238059-scene
Also probably it's better to change com.pkware.Zip-archive
to com.pkware.zip-archive
as it's defined as lowercase in the list of System-Declared UTIs
How to debug iOS App when opened from TodayExtension with openUrl?
1) Override an initializer in your App Delegate, and add there sleep call.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
override init() {
sleep(10000)
}
...
}
2) Install this app on your device or simulator.
3) Put a breakpoint in your code.
4) From the extension, trigger the deeplink.
5) While app is opened and in sleep, connect your Xcode debugger to your app via Xcode app menu (Debug
->Attach To Process
->< your app name >
). This will instantly wake up your app and it will fall into the breakpoint immediately.
Related Topics
Can You Enforce a Typealias in Swift
Error with Parse Query Findobjectsinbackgroundwithblock
How to Make Xcode Put Starting Brace on New Line in Swift
Dismiss View from View Model [Modal Page]
Passing a Variable Through a Segue? Xcode 8 Swift 3
How to Save a Custom Class as an Attribute of a Coredata Entity in Swift 3
Extending Typed Array by Conforming to a Protocol in Swift 2
Saving Swifty JSON Array to User Defaults
Change Width of a Uibarbuttonitem in a Uinavigationbar in Swift
Swift Codable with Different Array Types
Swift Alamofire Add Custom Header to All Requests
Swift: Search Bar Created at Auto Focus
Swift: Can Not Use Array Filter in If Let Statement Condition
Swift. Is the (Absolutely) Sole Specific Advantage of Unowned Over Weak, Performance
Which Value Types in Swift Supports Copy-On-Write
What's Wrong with My #If Target_Os_Simulator Code for Realm Path Definition
How to Avoid Duplicate Key Error in Swift When Iterating Over a Dictionary