Can I reset the access rights for openURL?

I’m testing an app that opens other apps using their corresponding URL Scheme.

When opening another app the first time, the user gets prompted to whether or not my app should be allowed to do so. If the user rejects this, I have some things that should happen.

Now that I’ve been tested the positive case where the user DO allow opening the external app, is there anyway I can reset these privileges ? I.e so that when opening the external app, the user again gets prompted to allow or reject this ?

I really don’t want to re-install the external app as this requires me to order a new ID from my bank (the external app is the Swedish BankID app).

Cheers,
Niklas

Hi @nmodin, I do not have a solid answer for resetting openURL but have you tried creating a function with openURL then accessing that function in the viewDidLoad or placing the openURL inside an IBAction? For example:

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    openWebsite()
}

//Example 1     
func openWebsite() {
    if let url = URL(string: "https://www.raywenderlich.com/") {
        if #available(iOS 10.0, *) {
            UIApplication.shared.open(url, options: [:])
        } else {
            UIApplication.shared.openURL(url)
        }
    }
}

//Example 2
@IBAction func openPhone(_ sender: AnyObject) {
if let url = URL(string: “https://www.raywenderlich.com/”) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:])
} else {
UIApplication.shared.openURL(url)
}
}
}

}

Happy coding!

Best,
Gina

Hi,

The opening isn’t really the issue I am having, but rather that resetting part. :slight_smile:

Basically I need to re-create that first time run situation, where there will be a alert asking the user to accept or reject opening the target URL. This only happens the first time an app is run, and the only solution I’ve found is to actually go to Settings -> General -> Reset -> Reset all settings. This obviously isn’t very practical, so I was wondering if there was some other way.

Thanks for the reply though ! :slight_smile:

Cheers,
Niklas

This topic was automatically closed after 166 days. New replies are no longer allowed.