jvenegas / AffiliateRedirection

AffiliateLink in your App
8 stars 3 forks source link

Open a "transparent" webview with the redirection because the affiliation doesnt work #3

Closed RealBug closed 10 years ago

RealBug commented 10 years ago

Hi,

the idea is nice but sadly the redirection doesnt work in background. Maybe, can we open a transparent webview with the redirection ?

BR

RealBug commented 10 years ago

Example :

1) load this in a webview myURL = [NSURL URLWithString:@"http://clk.tradedoubler.com/click?p=23753&a=1611348&g=0&td_partnerId=2003&url=https://itunes.apple.com/fr/app/twitter/id333903271"]; [myWebView loadRequest:[NSURLRequest requestWithURL:myURL]];

2) TD load this : URL: http://solutions.tradedoubler.com/redirect/itunesredir/td_redirect.php?programId=23753&affId=1611348&tduid=87c0fe43ef95770e08a1329d2f5d469f&url=https%3A%2F%2Fitunes.apple.com%2Ffr%2Fapp%2Ftwitter%2Fid333903271%3FpartnerId%3D2003

3) Apple load this : URL: https://itunes.apple.com/fr/app/twitter/id333903271?partnerId=2003&tduid=87c0fe43ef95770e08a1329d2f5d469f&affId=1611348

4) Apple launch the app store and quit the webview URL: itms-appss://itunes.apple.com/fr/app/twitter/id333903271?partnerId=2003&tduid=87c0fe43ef95770e08a1329d2f5d469f&affId=1611348

I think if we cut the process of the step 4, it will be ok maybe because Apple write the affiliation line in his BDD at the step 3.

jvenegas commented 10 years ago

Hi RB,

I did the same test as you did, also I use did this the affiliate redirection class to get the URL on the step 3:

itunesURL: https://itunes.apple.com/fr/app/twitter/id333903271?partnerId=2003&tduid=87c0fe43ef95770e08a1329d2f5d469f&affId=1611348

So here it is a piece of code can be add to get a proper App Store URL.

AffiliateRedirection *aff = [[AffiliateRedirection alloc] initWithURL:MyURL];
        [aff openAffiliateRedirectionWithBlock:^(NSURL *itunesURL, NSError *error) {
            NSString *schema = [itunesURL.scheme stringByAppendingString:@"://"];
            NSRange range = [itunesURL.absoluteString rangeOfString:schema];
            if (range.location == NSNotFound) {
                //Error
                NSLog(@"string was not found");

            } else {
                NSString *noSchemaString = [itunesURL.absoluteString stringByReplacingCharactersInRange:range withString:@""];
                NSString *absoluteAppStoreURL = [NSString stringWithFormat:@"%@%@", @"itms-appss://", noSchemaString];
                NSURL *appStoreURL = [NSURL URLWithString:absoluteAppStoreURL];
                NSLog(@"%@", appStoreURL);
                if ( [[UIApplication sharedApplication] canOpenURL:appStoreURL] ) {
                    [[UIApplication sharedApplication] openURL:appStoreURL];
                }
            }
        }];

After doing this I am going to create a new method called openAffiliateRedirectionOnAppStoreWithBlock. Open the SKStoreProductViewController is still interesting but there is not way to get revenue from affiliate links, so I hope apple create a new parameters to pass to the SKStoreProductViewController.

Any idea and comment are welcome :)