我在从我的 plist 中获取 App Store ID 并将其与 Appirater 一起使用时遇到问题。我 NSLogged 是用户按下“Rate Now”时所使用的 URL,并且 App Store ID 与我在 Info.plist 中设置的 App Store ID 截然不同。不知道这些数字是从哪里得到的——它们每次都是不同的 9 个数字组。这实在是太奇怪了。

Appirater.m 中用于获取 App Store ID 并在链接中使用它的代码如下所示: NSString *const kAppiraterAppIdBundleKey = @"AppStoreId";

NSString *templateReviewURL = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=APP_ID";

....

+ (NSString*)appStoreAppID {

    NSString* value = [[[NSBundle mainBundle] infoDictionary] objectForKey:kAppiraterAppIdBundleKey];

    NSAssert1(value, @"Error - you have not specified %@ property in your info.plist", kAppiraterAppIdBundleKey);

    return value;

}
//...

+ (void)rateApp {
    //...
    NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", [self appStoreAppID]]];
    //...
}

我在 plist 中添加了一个名为“AppStoreId”的字段,并输入了 9 位代码。我把它做成了字符串类型。现在,当我将“APP_ID”替换为上面 iTunes 链接中的实际 9 位代码时,代码可以完美运行,但是当我将其保留为 APP_ID 时,我收到错误“无法连接到 iTunes Store。”,并且 NSLog 输出在链接中有 9 个随机数,而且它们每次都是不同的。

这可能是一个简单的解决方法,但我似乎无法弄清楚。

有帮助吗?

解决方案

随机数?您正在使用:

[NSString stringWithFormat:@"%d", [self appStoreAppID]]

在哪里 appStoreAppID 是一个 NSString.

因此,您将“APP_ID”替换为指向 NSString, ,而不是内容 NSString.

只需使用 %@ 代替 %d.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top