user867662
user867662

Reputation: 1171

iOS to get redirected URL

In my iOS project, I need to invoke a url https://myemail.mycompany.com/?qs=23263726373273ADSD892329389DFDJFHD232323 and its redirects to another URL http://redr.mycompany.com/first/location/id/next/a/. I need to get the redirected URL in my iOS code and I will write my logic to parse it. How can I do that, can some one help me on this.

Upvotes: 0

Views: 693

Answers (1)

Umar Farooque
Umar Farooque

Reputation: 2059

From what I inferred is that you want to capture the link that redirects to the app when clicked.

If that's right, then you need to implement a method in your app delegate class

   @available(iOS 9.0, *)
    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {

          return true
    }

    @available(iOS 8.0, *)
    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {

      if url.scheme == "SOMETHING YOU WANT TO MATCH" {

           return false

      }

      if url.host == "SOMETHING YOU WANT TO MATCH" {

          return false

      }

          return true
    }

Refer this link for more detail, it describe all the scenarios and implementations as well.

Upvotes: 1

Related Questions