user3115014
user3115014

Reputation: 697

Open and install iOS app from UIwebview

I have an apps link using link maker from AppStore . I have a UIWebView in my app and I am trying to load the link in UIWebView but each time I load that link it opens the inbuilt AppStore instead of showing the content in the UIWebView. I want to open the link in UIWebView instead of opening the inbuilt iOS AppStore.

This what i tried

- (void)viewDidLoad
{
    str = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa";
    str = [NSString stringWithFormat:@"%@/wa/viewContentsUserReviews?", str];
    str = [NSString stringWithFormat:@"%@type=Purple+Software&id=", str];

    // Here is the app id from itunesconnect
    str = [NSString stringWithFormat:@"%@289382458", str];

   [webOpenApp loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
}

-(BOOL) webView:(UIWebView *)inWeb
shouldStartLoadWithRequest:(NSURLRequest *)inRequest
 navigationType:(UIWebViewNavigationType)inType
{
    if (inType == UIWebViewNavigationTypeOther) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
        return NO;
    }

    return YES;
}

Upvotes: 0

Views: 1134

Answers (1)

sunkehappy
sunkehappy

Reputation: 9101

The itms-apps:// is an special protocol that when iOS system read this it will launch the App Store to show that app. Apparently this is not what you want.

You should build the UI yourself to display the information of the app. And when user click the buy button you have to redirect user to App Store. Because App Store is the only place user could buy and download an app.

Upvotes: 1

Related Questions