Start a Project

Custom URL Scheme

Custom URL schemes provide a way to reference inside your app. Users can open a custom URL in the browser or tap in any link. Other apps can also trigger your app to launch with specific context data; for example, a photo library app might display a specified image.

Custom URL scheme is one of the ways of deep linking, but apple strongly recommended universal deep linking. For more information on universal links, see Allowing Apps and Websites to Link to Your Content. Custom URL schemes are also being used to check if the application is installed or not.

Apple also supports common schemes associated with system apps, such as mailtotelsms, and facetime. You can define your own custom scheme and register your app to support it. URLs must start with your custom scheme name. Add parameters for any options your app supports.

To support a custom URL scheme:

Register Custom URL Scheme in the Project

URL scheme registration specifies which URLs to redirect to your app. Just follows below steps to add URL scheme:

  1. Open the project and then select the target.
  2. Select Info and go to the URL Types and click on ‘+’
  3. Now in the ‘URL Schemes’ field enter your custom URL in small letters and don’t use space.
    Let’s suppose the example and app name is “CustomURLBlog” and use the “customurlblog” as a custom URL scheme.

Handle Incoming URLs

When the user click on the link or open it in any other broswer, it launches your app on the device in the foreground.

From iOS 13 and later below function will no longer work.

Deep linking will work even your application is killed. This function will get called “openURLContexts”.

Let’s add changes in the SceneDelegate class file as:

Now just run the app and then open Safari and type your URL scheme “customurlblog://”. It works as


Now also check with passing parameters as:

Conclusion

I hope this blog will help you in understanding the behaviour of pan gestures, if you have any comments, questions, or recommendations, feel free to post them in the comment section below!

For other blogs, please click here.

Exit mobile version