0

我正在使用 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 存储其他信息,所以这不是问题。

非常感谢您提供的任何帮助,感谢您的宝贵时间。

4

1 回答 1

0

MKStoreKit 不存储在 NSUserDefaults 中。我改用钥匙串。在方法 storeData:forKey: 中放置一个断点(直接从我的脑海中写下这个方法名称,而不看代码,搜索类似命名的方法)并尝试调试它。这是我保存您购买的地方。

请记住,即使在删除并重新安装应用程序后,购买也会被记住。

于 2012-03-20T15:26:15.697 回答