I need to open the Neshan Application (map application like Google-Map
). This is my code:
if (UIApplication.sharedApplication().canOpenURL(NSURL(string:"comgooglemaps://")!)) {
UIApplication.sharedApplication().openURL(
NSURL(string:"comgooglemaps://?saddr=&daddr=\(place.latitude),\(place.longitude)&directionsmode=driving")!
)
} else {
NSLog("Can't use comgooglemaps://");
}
This is not work? what should I do?
You'll have to declare the URL schemes, you want to use in your Info.plist. Use the key LSApplicationQueriesSchemes for that.
Add neshan key to LSApplicationQueriesSchemes.
Then using this snippet swift code to open the app with their custom schema.
if UIApplication.shared.canOpenURL(URL(string: "neshan://")!) {
// neshan is installed.
let urlStr = String(format: "neshan://")
UIApplication.shared.openURL(URL(string: urlStr)!)
} else {
// neshan is not installed.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.