img

Software Development Blog

Back

How to open a web site or phone from my iOS Swift app?

How to open a web site?

Like on the code above, you just need to create a non-optional URL to a needed website (google.com for example), with function canOpenURL(url) check if your application can open this resource. If canOpenURL(url) returns true - you can call the open function with your URL.

(If a website, which you are trying to open, has Universal links, then the open function will open another application associated with this website. For example website, "https://youtube.com/" will open the Youtube app (If you have this app on your device of course).

How to make a phone call?

Like on the code above, you just need to create a non-optional URL with your needed phone which needs to have "tel://" on the start. With function canOpenURL(url) check if your application can open this resource. If canOpenURL(url) returns true - you can call the open function with your URL.

Recent Posts

What are UUID identifiers in Swift?

READ MORE

How to use Comparable protocol

READ MORE