我正在使用MKStoreKit在我的应用程序中实现一个IAP。在购买产品时,一切都按预期进行,没有任何错误消息。产品是使用以下代码购买的。
[[MKStoreManager sharedManager] buyFeature:@"pro_upgrade"
onComplete:^(NSString* purchasedFeature)
{
NSLog(@"Purchased: %@", purchasedFeature);
// provide your product to the user here.
// if it's a subscription, allow user to use now.
// remembering this purchase is taken care of by MKStoreKit.
}
onCancelled:^
{
// User cancels the transaction, you can log this using any analytics software like Flurry.
}];在购买产品之后,我会收到确认购买的通知(通过下面的代码)。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector (subscriptionPurchased:)
name: kSubscriptionsPurchasedNotification
object:nil];购买后,我执行以下代码(如文档所示)以确定产品是否已购买。
if([MKStoreManager isFeaturePurchased:@"pro_upgrade"]) {
NSLog(@"This feature is purchased.");
} else {
NSLog(@"This feature is not purchased");
}对于产品ID,总是返回NO。当在购买产品时的同一实例中运行应用程序,以及关闭应用程序并打开应用程序时,就会发生这种情况。使用开发或分发证书运行应用程序根本不会有任何区别。此外,我找不到MKStoreKit购买的BOOL产品的确切存储位置(它在代码中很深,所以我不是说它有或没有,我只是找不到它)。我的应用程序使用NSUserDefaults存储其他信息,所以这不是问题所在。
如果您能提供任何帮助,我们将不胜感激,感谢您的宝贵时间。
发布于 2012-03-20 23:26:16
MKStoreKit不存储在NSUserDefaults中。我使用keychain代替。在方法storeData:forKey:中放置一个断点(不看代码,直接从我的头上写出这个方法名,搜索类似命名的方法),并尝试调试它。这是我帮你存东西的地方。
请记住,即使在删除并重新安装应用程序后,购买也会被记住。
https://stackoverflow.com/questions/9786771
复制相似问题