Opening an app based on its URL scheme
suggest changeTo open an app with defined URL scheme todolist://:
Objective-C
openURL: still compiles. It was deprecated in iOS 10 in favor of openURL:options:completionHandler:.
NSURL *myURL = [NSURL URLWithString:@"todolist://there/is/something/to/do"];
[[UIApplication sharedApplication] openURL:myURL];
Swift
let stringURL = "todolist://there/is/something/to/do"
if let url = URL(string: stringURL) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
HTML
<a href="todolist://there/is/something/to/do">Open the to-do list</a>
Note: Check whether the link can be opened, and otherwise show an appropriate message.
canOpenURLreturns false for a custom scheme unlessLSApplicationQueriesSchemeslists that scheme.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents