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.
Comments
Post a Comment