I want to open my app with using message app the user will receive message with link if the user pressed the link.its link need to open the app.
-
Welcome to StackOverflow. Please show what research you've undertaken, what you've already tried, what didn't work, code samples etc. Please read [ask], [mcve] and then [edit] your question showing the _minimum_ code that demonstrates the problem. – Ashley Mills Sep 07 '18 at 10:33
-
Possible duplicate of [Open app from SMS with my url scheme as a link](https://stackoverflow.com/questions/23010915/open-app-from-sms-with-my-url-scheme-as-a-link) – biloshkurskyi.ss Sep 07 '18 at 10:33
2 Answers
Using URL Scheme
URL Scheme let you define a custom protocol to let other application communicate with your application. To let other applications communicate with your App you must create an appropriately formatted URL and add support in your application. To implement URL Scheme you must tell the system to open it in your application and handle the incoming URL in your application. This URL Scheme looks like other URL Scheme like http://, ftp://, mailto://, tel:// etc. You can create your custom URL protocol like yourapp://open-home-page. Any application can open your application with this scheme by calling openURL. For Example if your custom URL is yourapp:// then following code will open your App:
let appUrl = URL(string: "youapp://page-to-open")
UIApplication.shared.openURL(appUrl!)
Register your Custom URL
To Register your application for URL Scheme support you have to include the CFBundleURLTypes key in your Info.plist file. This key will have array of dictionary with following keys:
CFBundleURLName: It is a string containing abstract name of the URL Scheme.
CFBundleURLSchemes: It is an array containing the URL Scheme names.
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>com.yourapp</string> <key>CFBundleURLSchemes</key> <array> <string>yourapp</string> </array> </dict> </array>
Handling the URL Request
When any application request your custom URL your App must handle the URL to open corresponding content. On any request to your custom URL will call AppDelegate’s method application(_:open:options:), so you have to implement this method in your AppDelegate. Refer following code snippet
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
print(url)
// Take decision according to URL
return true
}
If your application is not running (Killed) then it will first launch your application and then call the open url method.

- 6,687
- 7
- 42
- 63

- 1,071
- 13
- 28
You should look at Universal Links. Here is the answer with a very detail explanation: How to support Universal Links in iOS App and setup server for it?
Another advice. If you don't have your own backend - you can use Firebase dynamic links to have your own 'link' which will direct to your app.

- 871
- 7
- 12