2

I am making an app for a charity and Apple's review guidelines state that all donations must be made outside of the app in Safari, except for SMS donations, which we're not doing anyway. How do I make a button, that when tapped, goes to a specific URL in Safari? Thanks for your help!

Jack Humphries
  • 12,636
  • 14
  • 79
  • 121

2 Answers2

5
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"your.website.here"]]; 

And put it in an IBAction for your button.

There might be a problem connecting to your site try this:

NSURL *url = [NSURLWithString:@"your.website.here"];
if (![[UIApplication sharedApplication] openURL:url])

NSLog(@"%@%@",@"Failed to open url:",[url description]);

They actually have a post on it here:

How can I launch Safari from an iPhone app?

Community
  • 1
  • 1
Dair
  • 15,412
  • 8
  • 59
  • 104
3

You can use this code in button click event

[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"your url"]];

it automatically opens in safari

Nipin Varma
  • 384
  • 1
  • 7