【问题标题】:Opening GeoRiot Affiliate Link from Inside App?从内部应用程序打开 GeoRiot 附属链接?
【发布时间】:2013-12-09 12:36:18
【问题描述】:

我在我的应用程序中使用 Linkshare 链接已有一段时间了。它工作正常。 我实施了 Apple 的建议以吸收任何重定向并调用最后一个 URL。

对于那些正在寻找它的人,HERE IT IS

我有一个 UIButton 链接到一个调用它的方法:

[self openReferralURL:[NSURL URLWithString:link]];

其中链接是具有以下值的 NSString(我的 Linkshare 链接)

@"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"

这很好用。当我点击按钮时,它会立即启动 App Store 应用程序,而无需先打开 Safari。

但是当我将链接更改为下面的 GeoRiot 链接时,它会先打开 Safari,然后才打开 App Store。我想不出它这样做的任何原因。

@"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"

有人可以帮忙吗?您可以分享您的地理目标链接以与我的比较吗? 无论如何,我有 1 个 UIWebview 可以打开一个带有 Geotarget 链接的网页,并且 工作正常(即直接打开 App Store 应用程序)。

我现在想不通。我认为问题可能在于 GeoRiot 链接,但我有 不知道为什么或应该做什么,因为使用 Linkshare 链接它可以正常工作。

【问题讨论】:

  • 我讨厌这种情况发生。在我发布这个问题后,我解决了它。
  • 你能告诉我们怎么做吗?我有兴趣...
  • 当然安德里亚,请参阅下面的解决方案。

标签: iphone hyperlink affiliate


【解决方案1】:

这些天我一直在问问题并回答了很多问题,但对于 Andrea,这里是:

对于那些使用 georiot 链接的人,这些方法/功能将起作用 好,而不是 Apple 示例代码。

// 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;
    }

}

要使用,只需调用:

[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"]];

也许您还应该使用 URL 缩短工具来清理冗长的 URL 混乱,但无论哪种方式都可以。

【讨论】:

  • 谢谢! Apple Q&A 中的原始代码也适用于我。只是做了一个小改动,使其与 ARC 兼容......
【解决方案2】:

你找到了 iTunes url 没问题。

您有http://itunes.apple.com 地址,那么 ssl 重定向问题呢? 因为 iTunes 门户会将您重定向到 https://itunes.apple.com 地址。 我还改进了 iTunes 检查部分的 if 分支。

// 处理 iPhone 可以处理的 URL - (void)openReferralURL:(NSURL *)referralURL { NSURLRequest *theRequest=[NSURLRequest requestWithURL:referralURL cachePolicy:NSURLRequestUseProtocolCachePolicy 超时间隔:30.0]; NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; [conn发布]; } // 保存最新的 URL,以防发生多次重定向 // "iTunesURL" 是你的类声明中的一个 NSURL 属性 - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response { 如果(响应){ NSMutableURLRequest *r = [[请求 mutableCopy] autorelease]; // 原始请求 [r setURL: [请求 URL]]; NSURL *iTunesUrl = [r URL]; NSLog(@"处理附属链接:%@", iTunesUrl); if ([[iTunesUrl absoluteString] hasPrefix:@"https"] && [iTunesUrl.host hasSuffix:@"itunes.apple.com"]) { [[UIApplication sharedApplication] openURL:iTunesUrl]; } 返回 r; } 别的 { 退货请求; } }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-10
    • 1970-01-01
    • 1970-01-01
    • 2014-04-23
    • 2012-04-14
    • 1970-01-01
    • 2014-09-02
    相关资源
    最近更新 更多