I've been using Linkshare links in my apps for a while now. It works fine. I implemented the Apple's suggestion to absorb any redirects and call the last URL.
For those looking for it, HERE IT IS.
I have a UIButton linked to a method that calls this:
[self openReferralURL:[NSURL URLWithString:link]];
where link is a NSString with the following value (my Linkshare link)
@"http://click.linksynergy.com/fs-bin/stat?id=Jexmk6JU*OU&offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=http%253A%252F%252Fitunes.apple.com%252FWebObjects%252FMZStore.woa%252Fwa%252FviewSoftware%253Fid%253D353970672%2526partnerId%253D30"
This works fine. When I tap the button, it immediately launch App Store App without opening Safari first.
But when I change the link to the GeoRiot link below, it opens up Safari first, and then only open the App Store. I can't think of any reason why it is doing that.
@"http://target.georiot.com/Proxy.ashx?grid=5700&id=Jexmk6JU*OU&offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=http%253A%252F%252Fitunes.apple.com%252FWebObjects%252FMZStore.woa%252Fwa%252FviewSoftware%253Fid%253D353970672%2526partnerId%253D30"
Anyone can help? Can you share your geotarget link for comparison with mine? Anyway, I have 1 UIWebview that opens up a webpage with Geotarget links, and that works fine (ie. directly opens the App Store App).
I'm out of idea right now. I think the problem may lie in the GeoRiot link, but I have no idea why or what I should do since with the Linkshare link it works fine.
I've been asking questions and answering them a lot these days, but for Andrea, here goes:
For those of you who are using georiot links, these methods/functions will work well instead of the Apple Sample code.
// Process a URL to something iPhone can handle
- (void)openReferralURL:(NSURL *)referralURL
{
NSURLRequest *theRequest=[NSURLRequest requestWithURL:referralURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
[conn release];
}
// Save the most recent URL in case multiple redirects occur
// "iTunesURL" is an NSURL property in your class declaration
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response
{
if (response) {
NSMutableURLRequest *r = [[request mutableCopy] autorelease]; // original request
[r setURL: [request URL]];
self.iTunesURL = [r URL];
if ([self.iTunesURL.host hasSuffix:@"itunes.apple.com"]) {
[[UIApplication sharedApplication] openURL:self.iTunesURL];
}
return r;
} else {
return request;
}
}
And to use, just call:
[self openReferralURL:[NSURL URLWithString:@"http://target.georiot.com/Proxy.ashx?grid=5700&id=Jexmk6JU*OU&offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fiquiksplash-pro-all-in-one%252Fid378458261%253FpartnerId%253D30"]];
Probably you should also use a URL shortener tool to clean up the long URL mess, but either way it works ok.