ios - 以编程方式恢复购买 swift 4
问题描述
我遇到了这个问题:通过带锁的电影购买订阅。我点击相机按钮。订阅视图打开。我进行购买:我显示一条错误消息(但购买仍然成功)。
func subscribe(sub: SubscriptionType) {
DispatchQueue.main.async { let _ = MBProgressHUD.standardHud(over: self.managedView) }
FS2Recipes.subscribe(sku: sub.sku()).then { _ in
self.subscribed()
}.catch { error in
debugPrint("Error \(error.localizedDescription)")
let alert = UIAlertController(title: "Ooops", message: "There was an error processing your purchase. Try again later!", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { [weak self] _ in
self?.dismiss()
}))
self.present(alert, animated: true, completion: nil)
}.always {
DispatchQueue.main.async { let _ = MBProgressHUD.hide(for: self.managedView, animated: true) }
}
}
解决方案
推荐阅读
- c - C - 如何将扩展字符序列与函数 strcmp() 进行比较?
- xquery - 如何基于集合获取计数并在 XQuery 中使用多个元素词查询?
- sqlite - SQLite IFNULL 在公式中不起作用
- c++ - c++ SDL2-ld||找不到-lmingw32|
- c++ - 为什么WinAPI控件大小改变后不调用WM_NCCALSIZE?
- java - Java Riak“操作正在进行时通道关闭”错误
- python - Python ImportError:没有名为“funds”的模块
- terraform - 在“s3”后端检查状态时出错:NoSuchBucket:指定的存储桶不存在
- git - “git fetch && git checkout”与“git checkout”有什么区别?
- javascript - 遍历数组时应该使用 for-of 还是 forEach?