Make an affiliate link to the iTunes store without redirecting?

Apple explained in the β€œ launching the App Store from the iPhone app ” how to link an affiliate link to the app store and handle redirection in the background so as not to annoy the user. But it would be better not to have redirects at all. I seem to remember how I saw a way to do this, but now I can not find it anywhere.

Is it possible to make an affiliate link from an iOS application to the application store without any redirects?

EDIT: To clarify, I'm talking about Linkshare affiliate link.

EDIT 2: I'm getting closer. I have this link, which I immediately grabbed the link "text links". When using the k1th trick below, it works without any redirects to the iPad, but still has one redirect to iPod touch [and presumably the iPhone]. I guess redirection may be to switch from the best iPad apps to iPhone, but I don't know for sure.

http://click.linksynergy.com/fs-bin/click?id=sf2bW7QX/qU&offerid=146261.10005745&type=3&subid=0

+6
source share
5 answers

I believe you do not want redirects to be

  • avoid Safari browser
  • Avoid redirects inside the app store app

I would prefer the k1st solution, but if it doesn’t work out (I believe it may not work out # 2 above), I assume that the problem is that the first itms link is not "final". One solution would be to simply hardcode the URL (or provide it in other ways):

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { NSURL myAppUrl = .... if ([request.URL.scheme isEqualToString:@"itms"] && [[UIApplication sharedApplication] canOpenURL:myAppURL]) { [[UIApplication sharedApplication] openURL:myAppURL]; return NO; } return YES; // go on redirecting } 

A cleaner solution would be to read the application ID from the itms link in request.URL and format the new URL using a template that will take you directly to your application.

+3
source

Yes, you may have slashes in the parameters (this is because it is the line after the question mark starting part of the URL parameter.

As for the Mobile Safari pass for handling affiliate links:

You can configure the hidden UIWebView to handle redirects or do everything in the URL loading system yourself. This is with a hidden WebView:

 NSURLRequest *r = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://click.linksynergy.com/fs-bin/click?id=sf2bW7QX/qU&offerid=146261.431296703&type=2&subid=0"]]; testWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; testWebView.hidden = YES; testWebView.delegate = self; [testWebView loadRequest:r]; 

delegate:

 #pragma mark - UIWebViewDelegate - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if ([request.URL.scheme isEqualToString:@"itms"] && [[UIApplication sharedApplication] canOpenURL:request.URL]) { [[UIApplication sharedApplication] openURL:request.URL]; return NO; } return YES; // go on redirecting } 

testWebView must be an instance of var, and the view controller itself must be <UIWebViewDelegate> . You also need to set the webview delegate to zero somewhere (e.g. in -dealloc )

+4
source

Apple has a much cleaner solution: https://developer.apple.com/library/ios/#qa/qa1629/_index.html

And for short, here is the code from this page:

 // Process a LinkShare/TradeDoubler/DGM URL to something iPhone can handle - (void)openReferralURL:(NSURL *)referralURL { NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:referralURL] delegate:self startImmediately:YES]; [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 { self.iTunesURL = [response URL]; return request; } // No more redirects; use the last URL saved - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [[UIApplication sharedApplication] openURL:self.iTunesURL]; } 
+3
source

I found this document and I think it gave me an answer. It is always difficult for me to decipher these things, but I think this suggests that I start with the base link:

 http://itunes.apple.com 

then add partnerId of 30, plus my linkshare affiliate token, which I think

 sf2bW7QX/qU 

The result is the following:

 http://itunes.apple.com?partnerId=30&id=sf2bW7QX/qU 

I got what, in my opinion, is my id, following the instructions in the Apple document, which basically say, to grab the id parameter from an arbitrary linkshare. The link used for this purpose is as follows:

 <a href="http://click.linksynergy.com/fs-bin/click?id=sf2bW7QX/qU&offerid=146261.431296703&type=2&subid=0"><IMG border=0 src="http://a464.phobos.apple.com/us/r30/Music/b9/7f/91/mzi.kbjyfypr.170x170-75.jpg" ></a><IMG border=0 width=1 height=1 src="http://ad.linksynergy.com/fs-bin/show?id=sf2bW7QX/qU&bids=146261.431296703&type=2&subid=0" > 

I'm still not sure about that. Can my linkshare join token have a slash?

0
source

This answers your question: http://www.apple.com/itunes/affiliates/resources/documentation/linking-to-the-itunes-music-store.html#apps

By the way, I think that this whole affiliate program is too complicated. I looked into it, and I do not think that it costs 5% of the commission.

0
source

Source: https://habr.com/ru/post/904001/


All Articles