When the UIAlertController object is dismissed, the presentedViewController property will be set to nil. For example, when the QRScannerController object calls the present(_:animated:completion:) method to present the UIAlertController object, the presentedViewController property is set to the UIAlertController object. In iOS, when you present a view controller modally using the present(_:animated:completion:) method, the presented view controller is stored in the presentedViewController property of the current view controller. To resolve the issue, we have to check if the app has presented a UIAlertController object before calling the present(_:animated:completion:) method. So the app may present another UIAlertController when there is already a UIAlertController presented.
#SWIFT SHARE URL CODE#
The launchApp method is called every time when a barcode or QR code is scanned. Note that the app only works on a real iOS device. If you compile and run the app, you’ll have a simple QR code reader app. To start with, first download the QRCodeReader app.
![swift share url swift share url](https://media1.tenor.com/images/60b32ff34b542d62f52cf0c75c546f75/tenor.gif)
When the QR code is decoded, the app will launch the corresponding app based on the type of the URL. In this chapter, we’ll make it even better. So far, the demo app is capable of decoding a QR code and displaying the decoded message on screen. If you haven’t read the QR code tutorial, go back and read it before continuing on. We will reuse the QR code reader app that was built in the previous chapter. You’ll see what I mean in a minute.Īs usual, we will build an app to demonstrate the use of URL schemes. Additionally, you can create a custom URL scheme for your own app so that other applications can launch your app via a URL. Similarly, you can use another URL scheme to launch the Message app for sending an SMS. You can use a specific URL scheme to launch the built-in phone app and dial the number automatically. For example, let’s say your app displays a phone number, and you want to make a call whenever a user taps that number. The URL scheme is an interesting feature provided by the iOS SDK that allows developers to launch system apps and third-party apps through URLs.