如何使用MKStoreKit实现两个消耗品?如果我有两个消耗品,例如“一把硬币”(10枚硬币)和“带硬币的袋子”(100枚硬币)。我有两个问题:
我看过官方MKStoreKit博客上的教程,但我还是搞不懂。
附注:我使用的是MKStoreKit 3.1,不能更新到更新的版本,因为有了它(我的项目不支持它)
发布于 2012-07-15 08:04:59
你的胶布的消耗品钥匙应该是这样的。
<key>Consumables</key>
<dict>
<key>com.yourcompany.yourapp.handfulofcoins</key>
<dict>
<key>Count</key>
<integer>10</integer>
<key>Name</key>
<string>CoinsInMyApp</string>
</dict>
<key>com.yourcompany.yourapp.bagofcoins</key>
<dict>
<key>Count</key>
<integer>100</integer>
<key>Name</key>
<string>CoinsInMyApp</string>
</dict>
</dict>
我匹配字符串"CoinsInMyApp“来计算购买硬币的数量,不管它们来自哪一种消耗品。在上面的示例中,如果用户购买1袋硬币和2枚手扶硬币,MKStoreManager为密钥CoinsInMyApp存储120。
方法,
- (BOOL) canConsumeProduct:(NSString*) productIdentifier
- (BOOL) canConsumeProduct:(NSString*) productIdentifier quantity:(int) quantity
会告诉你是否有足够的产品。
当玩家使用硬币时,您应该通过调用MKStoreKit来让它知道这一点
- (BOOL) consumeProduct:(NSString*) productIdentifier quantity:(int) quantity
你可以通过打电话得到硬币的数量。
[[MKStoreManager numberForKey:@"CoinsInMyApp"] intValue];
PS:您可以在非arc项目中使用MKStoreKit最新版本,方法是使用-fobjc-圆弧标志编译它。
我在这里写的http://blog.mugunthkumar.com/articles/migrating-your-code-to-objective-c-arc/
https://stackoverflow.com/questions/11431420
复制