Marking
Marking

Reputation: 184

How to open https links in objective c?

https://www.google.co.in/

https://en-gb.facebook.com/login/

I can opened above links successfully... But below link not opened in webView why? How to solve this problem?

https://itunes.apple.com/in/developer/whatsapp-inc/id310634000?mt=8&uo=2

- (void)viewDidLoad {
   [super viewDidLoad];
   // Do any additional setup after loading the view.

   UIWebView *webView = [[UIWebView alloc]init];
   webView.frame = self.view.frame;
   [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]];
   [self.view addSubview:webView]; 
   NSLog(@"%@", self.urlString);
   // https://itunes.apple.com/in/developer/whatsapp-inc/id310634000?mt=8&uo=2   
 }

This self.urlString comes from server...

Upvotes: 0

Views: 459

Answers (3)

Dishant Rajput
Dishant Rajput

Reputation: 1357

NSString *fullURL = @"https://itunes.apple.com/in/developer/whatsapp-inc/id310634000?mt=8&uo=2";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_viewWeb loadRequest:requestObj];

Upvotes: 0

karthik
karthik

Reputation: 159

In ViewController.h file create an outlet

@property (strong, nonatomic) IBOutlet UIWebView *webview;

In ViewController.m file viewDidLoad

_webview.delegate = self;

[_webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@",URLSTRING FROM SEVER]]]];

Upvotes: 0

Sunny
Sunny

Reputation: 831

From this Link.

Maybe for better user experience itunes links doesn't open in UIWebView as iTunes content does not have an "iTunes Preview" page on mobile - iOS automatically recognizes itunes.apple.com links and opens the store.

So if you want to open itunes link you should use SKStoreProductViewController. It opens you itunes item in your app. Follow these links to use SKStoreProductViewController

How to links to apps to app store

Documentation

Upvotes: 1

Related Questions