Reputation: 1208
i defined a deep-link in info.plist like this :
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.myapp.customer</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp.com</string>
</array>
</dict>
</array>
but in Safari there's no reaction to this link and this message shows up :
Safari cannot open the page because the server can not be found
Everything is checked and i did as tutorials and still nothing happens!
Upvotes: 2
Views: 5908
Reputation: 2828
The CFBundleURLSchemes
field should be filled with a scheme, not a url. Schemes come before the url to tell the browser what action to take. For example, https://
is a scheme that tells the browser to establish a secure connection. An Apple URI scheme is simply you telling the browser that you want URLs with your custom scheme (i.e. customScheme://
) to be handled by your app. HTTP and HTTPS are reserved for Safari on iOS. To allow customScheme://example/path
to open your app. Just change that field to customScheme
.
If you would like to register normal web URLs to handle your links you will have to integrate Universal Links. These can be a pain to set up so I recommend using the Branch iOS SDK. Their deep linking is free and provides more features on top of Universal Links.
Upvotes: 2
Reputation: 1626
Make sure you have this method in AppDelegate.Swift
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if url.scheme != nil && url.scheme!.hasPrefix(""){
//Deep linking link should be like this : 'yourAppScheme'
if(url.host?.contains("page"))!{
if(url.path.contains("/yourhoststring")){
// do some work
}
}
}
//default
return false
}
Your Url scheme should be like this : [scheme]://[host]/[path]
Here is the link for detailed tutorial: http://blog.originate.com/blog/2014/04/22/deeplinking-in-ios/
Upvotes: 1