Created
July 18, 2009 17:23
-
-
Save kishikawakatsumi/149622 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 1: Copy the URL of your full app from the App Store by right-clicking its name, which will be something like | |
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=306469222&mt=8 | |
Step 2: Replace “itunes” with “phobos”. This is so it doesn’t start Safari. | |
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=306469222&mt=8 | |
Step 3: Have the system load it. | |
NSString *iTunesLink = @"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=306469222&mt=8"; | |
[[UIApplication sharedApplication] | |
openURL:[NSURL URLWithString:iTunesLink] | |
]; | |
Ah, but what if you want to use your iTunes affiliate account? After all, no point leaving 5% off the table! Well, that’s a trifle more complicated, since there’s redirects involved. So take your big long LinkShare string, change “itunes” to “phobos” as above, and create a NSURLConnection to sort out the URL that actually needs to be loaded. Like this: | |
- (IBAction)buyFullVersion | |
{ | |
NSString *referralLink = @"http://click.linksynergy.com/yadayadayada"; | |
self.iTunesURL = [NSURL URLWithString:referralLink]; | |
NSURLRequest *referralRequest = [NSURLRequest | |
requestWithURL:self.iTunesURL | |
]; | |
NSURLConnection *referralConnection = [[NSURLConnection alloc] | |
initWithRequest:referralRequest | |
delegate:self | |
startImmediately:YES | |
]; | |
[referralConnection release]; | |
} | |
// Save the most recent URL in case multiple redirects occur | |
- (NSURLRequest *)connection:(NSURLConnection *)connection | |
willSendRequest:(NSURLRequest *)request | |
redirectResponse:(NSURLResponse *)response | |
{ | |
self.iTunesURL = [response URL]; | |
return request; | |
} | |
// No more redirects; use the last URL saved | |
- (void)connectionDidFinishLoading:(NSURLConnection *)connection | |
{ | |
[[UIApplication sharedApplication] openURL:self.iTunesURL]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment