每当我打开应用程序时,我都想检查自动可续订订阅状态.
这是为了确保用户仍然订阅了该服务.我该如何实现这一目标?
有什么想法吗?谢谢
PS:我正在使用 SwiftyStoreKit
我们在我们的应用程序上使用介绍价格。而且,我们只有两个QA设备(法国App Store上的iPhone 6S(11.4.1))中的一个问题可以重现。另一个是iPhone 7(法语应用商店中为12.0),该应用未崩溃。
我们正在基于SwiftyStoreKit提供的SKProduct扩展使用此扩展:
@available(iOS 11.2, *)
public extension SKProductDiscount {
public var localizedPrice: String? {
return priceFormatter(locale: priceLocale).string(from: price)
}
private func priceFormatter(locale: Locale) -> NumberFormatter {
let formatter = NumberFormatter()
formatter.locale = locale
formatter.numberStyle = .currency
return formatter
}
}
Run Code Online (Sandbox Code Playgroud)
像这样使用:
func updateWith(storeProducts: Set<SKProduct>) {
guard
let selfStoreInfo = storeProducts.filter({ $0.productIdentifier == self.id }).first else {
Logger.warn(message: "Subscription \(self.id) not found on store", .inAppPurchase)
return
}
if #available(iOS 11.2, *) {
if let promo = selfStoreInfo.introductoryPrice { …Run Code Online (Sandbox Code Playgroud) 为什么下面的代码会导致and都URLSession返回?nildataerror
let task = URLSession.shared.dataTask(with: storeRequest as URLRequest) { data, _, error -> Void in
// there is an error
if let networkError = error {
print("There was a network error")
return
}
// there is no data
guard let safeData = data else {
print("No network error, but no data either")
return
}
...
Run Code Online (Sandbox Code Playgroud)
运行此代码时,一名用户拨打了电话No network error, but no data either。
根据苹果公司的文档URLSession.dataTask:
如果请求成功完成,则完成处理程序块的 data 参数包含资源数据,并且 error 参数为零。如果请求失败,则 data 参数为 nil,error …