Guest User

Untitled

a guest
Feb 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. func showWazeNaviationWithUrl(_ strURL: String) {
  2. if let url = URL(string: "waze://") {
  3. if UIApplication.shared.canOpenURL(url) {
  4. if let url = URL(string: strURL) {
  5. UIApplication.shared.openURL(url)
  6. }
  7. } else {
  8. //Waze is not installed. Launch AppStore to install Waze app
  9. if let url = URL.init(string: "https://itunes.apple.com/app/id323229106") {
  10. UIApplication.shared.openURL(url)
  11. }
  12. }
  13.  
  14. func startNavigation(address: String) {
  15.  
  16. var allowedQueryParamAndKey = NSCharacterSet.urlQueryAllowed
  17. allowedQueryParamAndKey.remove(charactersIn: ";/?:@&=+$, ")
  18. let _address = address.addingPercentEncoding(withAllowedCharacters: allowedQueryParamAndKey)
  19.  
  20. let strURL = String(format: "https://waze.com/ul?ll=%@&navigate=yes", _address!)
  21. self.delegate?.showWazeNaviationWithUrl(strURL)
  22. }
  23.  
  24. "https://waze.com/ul?ll=R%20VISCONDE%20DE%20URUGUAI%20%2C%20311%20%20-%20CENTRONiter%C3%B3i%20-%20RJ&navigate=yes"
Add Comment
Please, Sign In to add comment