如何解决在 StoreKit 中成功购买后如何关闭 UIAlertController?
我试图在购买成功后关闭警报控制器,然后人们可以进入解锁以阅读下一个故事板中的故事。
它不断弹出说“你的购买准备好买了它”并且不会让我跳到下一个故事板来阅读它。
我使用 UITableViewController 所以这里是代码结果;
func tableView(_ tableView: UITableView,didSelectRowAt indexPath: IndexPath) {
// MARK: Countdown Tracks
let getDate = Calendar.current.date(from: dateArray[indexPath.row])?.timeIntervalSince1970
let curDate = Date().timeIntervalSince1970
let dateDifference = getDate! - curDate
if dateDifference <= 0 {
sliceData.removeAll()
sliceData.append((epsoide: indexPath.row + 1,slideNum: sliceNum[indexPath.row]))
UITableViewEposides.deselectRow(at: indexPath,animated: true)
let vc = slideList()
vc.title = "Episode \(sliceData[0].epsoide)"
navigationController?.pushViewController(vc,animated: true)
} else {
let alertController = UIAlertController(title: "Early Read Pass",message: "this is test",preferredStyle: .alert)
let PaymentAction = UIAlertAction(title: "Puchase $0.99 to unlock Epsoide \(indexPath.row + 1)",style: UIAlertAction.Style.default,handler: {
(action) in
switch indexPath.row {
case 3:
IAPService.shared.purchase(product: .epsiode4non_consumable)
case 4:
IAPService.shared.purchase(product: .epsiode5non_consumable)
case 5:
IAPService.shared.purchase(product: .epsiode6non_consumable)
case 6:
IAPService.shared.purchase(product: .epsiode7non_consumable)
case 7:
IAPService.shared.purchase(product: .epsiode8non_consumable)
case 8:
IAPService.shared.purchase(product: .epsiode9non_consumable)
case 9:
IAPService.shared.purchase(product: .epsiode10non_consumable)
default:
break
}
})
let cancelAction = UIAlertAction(title: "Cancel",style: UIAlertAction.Style.cancel) {
UIAlertAction in
print("Cancel Pressed")
}
// Add the actions
alertController.addAction(PaymentAction)
alertController.addAction(cancelAction)
// Present the controller
self.present(alertController,animated: true,completion: nil)
}
}
有人知道如何解决这些问题吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。