【问题标题】:Appstore as modal view in iOS6App Store 作为 iOS 6 中的模态视图
【发布时间】:2012-09-18 10:54:26
【问题描述】:

我注意到,当用户在 iOS6 邮件应用中点击应用商店链接时,邮件会打开代表应用商店的模式视图,而不是切换到应用商店应用程序与以前的版本一样。

Apple 是否提供对此功能的访问权限,或者是其集成程序独有的功能?


注意:如果您有 iOS 6 并想对其进行测试,只需打开应用商店并将应用通过电子邮件发送给自己。

【问题讨论】:

  • 所以我猜现在没有保密协议,任何人都会回答:)
  • 这不是 iOS6 的记录功能
  • 我相信appstore只是一个webview。如果您能找出 URL,您可能只需将其显示在 web 视图中即可。
  • endy 可能是对的:你能从你的 iOS 设备或模拟器中发布一个屏幕截图来显示你正在谈论的视图吗?
  • 我也刚刚注意到这一点。截图如下:inside Mail app,点击后即可获得AppStore modal view

标签: xcode app-store ios6


【解决方案1】:

我将此方法作为一个类别添加到 UIViewController,但您可以根据自己的需要重新调整它的用途。应用商店 ID 是应用商店 URL 中的大数字。确保导入 StoreKit 框架和头文件!

@import StoreKit;

- (void)presentAppStoreForID:(NSNumber *)appStoreID withDelegate:(id<SKStoreProductViewControllerDelegate>)delegate
{
    if(NSClassFromString(@"SKStoreProductViewController")) { // Checks for iOS 6 feature.

        SKStoreProductViewController *storeController = [[SKStoreProductViewController alloc] init];
        storeController.delegate = delegate; // productViewControllerDidFinish

        // Example App Store ID (e.g. for Words With Friends)
        // @322852954

        [storeController loadProductWithParameters:@{ SKStoreProductParameterITunesItemIdentifier: appStoreID }
                                   completionBlock:^(BOOL result, NSError *error) {
            if (result) {
                [self presentViewController:storeController animated:YES completion:nil];
            } else {
                [[[UIAlertView alloc] initWithTitle:@"Uh oh!" message:@"There was a problem opening the app store" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil] show];
            }
        }];

    } else { // Before iOS 6, we can only open the App Store URL
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/app/id%@",appStoreID]]];
    }
}

【讨论】:

  • 谢谢你,你知道有没有办法在应用商店联盟计划中使用这种方法?因为似乎没有办法将 pratnerID 和 siteID 传递给应用商店
  • 抱歉,我不太熟悉联盟计划
  • 自从我回答以来,已经有几个人看了这个。要添加更多细节,我强烈建议您在调用 loadProductWithParameters 之前启动 UIActivityIndi​​catorView ——它可能会很慢。此外,如果您只有 appStore URL,您可以在此方法中输入代码以提取 appStoreID 编号(我只将它们分开,因为我们的模型碰巧已经将它们分开存储)。最后,确保将警报视图文本替换为与您的应用程序相关的内容。
  • 感谢您的提示,但是当我在开发 iPhone 上测试时,我无法安装应用程序,是因为它还没有在 appstore 中并且可以在测试设备上运行吗?
  • @AndreiG。最新的文档说要使用NSNumber——可能是@SoftDesigner 链接到后来更正的文档? developer.apple.com/library/ios/documentation/StoreKit/…
【解决方案2】:

看起来这是在 IOS 6 中作为 StoreKit 引入的,特别是 SKITunesProductViewController,它允许您在应用中展示 iTunes 内容(应用、音乐、书籍等),供用户直接购买。

【讨论】:

    【解决方案3】:

    这里有一个处理附属链接的插件: https://github.com/adeven/AEProductController

    或者,您也可以按照 Apple 技术问答 QA1629 首先打开应用内的附属链接(就像在直接打开 iTunes Store 应用之前一样)来推出自己的产品:

    https://developer.apple.com/library/ios/#qa/qa2008/qa1629.html

    然后按照上面提到的 MaxGabriel 打开 SKStoreProductViewController。

    [编辑] 我在我的应用程序(音乐应用程序)中完成了此操作,但无论我有一个活动的 AVAudioSession 还是我完全禁用所有播放(用于测试),模态 iTunes Store 中的歌曲样本播放但没有声音。如果您没有此问题或找到解决方案,请告诉我。这可能是一个应该报告给https://bugreport.apple.com/ 的错误。

    【讨论】:

    • 你试过这个方法吗?你真的以这种方式赚取会员佣金吗? Georiot 声称 SKStoreProductViewController 无论如何都不尊重附属 cookie twitter.com/georiotdotcom/status/295764495647784960
    • SKStoreProductParameterAffiliateTokenSKStoreProductParameterCampaignToken 已正式包含在 iOS 8 中,因此它们现在应该可以使用了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-18
    • 2012-09-12
    • 2017-03-27
    • 2012-10-17
    • 1970-01-01
    • 2019-01-21
    • 1970-01-01
    相关资源
    最近更新 更多