Rog*_*Lee 5 itunesconnect in-app-purchase ios
最近我在努力IAP.如您所知,当您想要发送付款请求时,您应该致电
+ (id)paymentWithProduct:(SKProduct *)product
Run Code Online (Sandbox Code Playgroud)
但我发现只有这样才能让产品正在使用SKProductsRequest,有没有办法SKProduct直接生成?就像被弃用的一样,
+ (id)paymentWithProductIdentifier:(NSString *)identifier
Run Code Online (Sandbox Code Playgroud)
事实是我想SKProduct直接使用产品ID 的新对象.
BR,罗杰
小智 16
我使用它来购买产品而不从iTunes获取所有产品:
- (void)buyProductIdentifier:(NSString *)productIdentifier
{
SKMutablePayment *payment = [[SKMutablePayment alloc] init] ;
payment.productIdentifier = productIdentifier;
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
Run Code Online (Sandbox Code Playgroud)
kev*_*inl 10
如果您想创建一个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")
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4453 次 |
| 最近记录: |