最近我在IAP上工作。如您所知,当您想要发送付款请求时,您应该调用
+ (id)paymentWithProduct:(SKProduct *)product但是我发现获取产品的唯一方法是使用SKProductsRequest,有没有直接生成SKProduct的方法?就像被弃用的那个一样,
+ (id)paymentWithProductIdentifier:(NSString *)identifier事实上,我想要一个直接使用产品id的新SKProduct对象。
BR,罗杰
发布于 2014-11-18 20:34:57
我使用它来购买产品,而不需要从iTunes获取所有产品:
- (void)buyProductIdentifier:(NSString *)productIdentifier
{
SKMutablePayment *payment = [[SKMutablePayment alloc] init] ;
payment.productIdentifier = productIdentifier;
[[SKPaymentQueue defaultQueue] addPayment:payment];
}发布于 2018-09-07 05:00:12
如果您想要创建一个用于单元测试的SKProduct,您可以扩展该类并设置标识符:
extension SKProduct {
convenience init(identifier: String, price: String, priceLocale: Locale) {
self.init()
self.setValue(identifier, forKey: "productIdentifier")
self.setValue(NSDecimalNumber(string: price), forKey: "price")
self.setValue(priceLocale, forKey: "priceLocale")
}
}发布于 2012-10-27 00:28:49
没有这样的机制。你必须让你的应用内购买获得苹果的批准,并使用SKProductsRequest应用程序接口来检索定价信息。
https://stackoverflow.com/questions/13090791
复制相似问题