Could it be that canOpenURL always returns false? After starting monobudget, I came across an interesting case. The main scenario in the application is user authorization in the monobank during the first launch. This step can, of course, be skipped, but due to the specifics of the application, I refer it to the main scenario.
At first, one user wrote to me and said that by clicking on the authorization button, nothing happens. I thought “very strange” and “what could it be?”
Later, a second user slapped a one star into a review in the App Store for the same reason. Then there were more users and in the logs I began to notice that the problem was serious.
It took a long time to google, but as a result, the cause was found.
I don’t know how on iOS 13, but on iOS 14 the construction
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: , completionHandler: nil)
}
does not work i.e. canOpenURL always returns false if the default browser was changed from Safari to Chrome, for example.
Moreover, if you do not check canOpenURL, UIApplication.shared.open will successfully open the passed url.
The solution to the fact that canOpenURL always returns false was to add https & http to LSApplicationQueriesSchemes in the Info.plist file.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>http</string>
<string>https</string>
</array>