Alex Cohn
Alex Cohn

Reputation: 57173

open in WebView instead of deep link on iOS

My iPhone app has a WebView which may sometimes show a URL registered with one of installed applications (e.g. Yelp). I want this page to open in my app. Actually, I don't care if the further links will switch to another app, but this first view should remain within our app.

I can find some app-specific workarounds, like https://stackoverflow.com/questions/29587313 for Pinterest, but I am looking fo a generic solution.

Upvotes: 1

Views: 1948

Answers (1)

Artal
Artal

Reputation: 9143

You can use the same solution suggested in the link you posted for the app-specific workarounds, but block all links that are not http or https:

NSURL *url = [request URL];
if (![url.scheme isEqual:@"http"] && ![url.scheme isEqual:@"https"])
{
    return NO;
}

If there are other schemes you would like to support, just add them to the statement.

Upvotes: 1

Related Questions