I created a button to make a call from app:
@IBAction func callButton(sender: AnyObject) { if (PhoneNumber != ""){ UIApplication.sharedApplication().openURL(NSURL(string: "telprompt://\(PhoneNumber)")!) } }
and it works perfectly fine. Strange thing happens when I want to open a web page. I use nearly exactly same code
@IBAction func openWeb(sender: AnyObject) { UIApplication.sharedApplication().openURL(NSURL(string: "www.google.com")!) }
But this time button doesn't react and nothing happens. Wherever I was looking for some information about opening web pages in safari from the app, the code was written exactly this way. Do you have any idea where the problem is?
Thanks in advance!
Go to your settings, then go to chrome, then tap on the the dots (the more options button), then click on “uninstall updates”, then try again. 12:38 pm (IST): One of the affected users suggested a workaround that will possibly resolve the ‘Open web pages in the app’ function not working issue.
The usual practice with redirecting to another page on React is to use the react-router-dom package; then, we apply the Route exact path and the Link function to complete the coding process. The processes are mostly similar to the explanation above when we attempt to use the onClick event listener with the react-router-dom package.
You can render a normal html <button> with React, as usual React prop conventions apply, such as onClick, style, etc. The button's onClick prop is what allows us to add a function which fires when the user clicks on the button.
For example, the html button's text is already centered for us. We mainly want to change the background color, increase the font size, add more padding (vertical then horizontal below), add a border radius, and change the cursor to a pointer. Doing those 5 things will give you a modern looking React Button you can use:
missing url scheme
UIApplication.shared.open(URL(string: "http://www.google.com")!, options: [:], completionHandler: nil)
Swift 4, safely unwrapped optional, check if canOpenURL
if let url = URL(string: "https://www.google.com"), UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url, options: [:]) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With