ios - UIApplication.shared.canOpenURL(URL(string: "comgooglemaps://")!) always returns true -


i need check whether user has installed google maps on phone . if google maps installed, open google maps, else open apple maps. when google maps not installed 'canopenurl' returns true.

here’s code,

if (uiapplication.shared.canopenurl(url(string: "comgooglemaps://")!)){         let urlstring = "comgooglemaps://?center=" + lat + "," + long + "&q=" + lat + "," + long         let url = url(string: urlstring)         uiapplication.shared.openurl(url!)     }else{         let urlstring:nsstring = nsstring(format: "http://maps.apple.com/?q=%@,%@", lat, long)         uiapplication.shared.openurl(url(string: urlstring string)!)     } 

and, have added lsapplicationqueriesschemes array , appended "comgooglemaps" it.

info.plist image here


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -