Quote:
Originally Posted by kiancheong
oops... sorry, havent' checked this thread lately...
here's my implementation:
Code:
// Process a LinkShare/TradeDoubler/DGM 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 *)redirectResponse {
self.iTunesURL = [redirectResponse URL];
return request;
}
// No more redirects; use the last URL saved
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[[UIApplication sharedApplication] openURL:self.iTunesURL];
}
however, one thing i noted here is that the app would crash if the redirect fails... comments appreciated... thanks...
|
Hmmm... noticed the same thing too. Seems like if the website takes too long to respond, the app gets shutdown (as being non-responsive)?
(Kinda hard to expect a website to be as quick as an app, IMHO.)
---
Correction: my crash was unrelated. Seems to be running correctly now.