Я хочу сделать кнопку «snapShotButton» со счетчиком, когда я нажимаю кнопку 3 раза, я хочу сделать предупреждение, где пишут «вам нужно платить за использование этого приложения». И когда я нажимаю «хорошо», он будет платить с MKStoreKit ... У меня есть MKStoreKit, а мое приложение - Video Editor ...
func addButtons() {
let snapShotButton = UIButton(type: .system)
snapShotButton.setImage(#imageLiteral(resourceName: "snapShot").withRenderingMode(.alwaysOriginal), for: .normal)
snapShotButton.translatesAutoresizingMaskIntoConstraints = false
bottomTabBar.addSubview(snapShotButton)
snapShotButton.centerYAnchor.constraint(equalTo: bottomTabBar.centerYAnchor).isActive = true
snapShotButton.centerXAnchor.constraint(equalTo: bottomTabBar.centerXAnchor).isActive = true
snapShotButton.heightAnchor.constraint(equalToConstant: 32).isActive = true
snapShotButton.widthAnchor.constraint(equalToConstant: 32).isActive = true
snapShotButton.addTarget(self, action: #selector(snapShotButtonTapped), for: .touchUpInside)
snapShotButton.addTarget(self, action: #selector(counterAction), for: .touchUpInside)
}
func counterAction(sender:UIButton){
counter -= 1
print(counter)
if counter == 0 {
MKStoreKit.shared().initiatePaymentRequestForProduct(withIdentifier: "com.steinlogic.iapdemo.quarterly")
}
}
func snapShotButtonTapped() {
pauseVideo()
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: self.videoURL)
}) { saved, error in
if saved {
DispatchQueue.main.async { _ in
self.dismiss(animated: true, completion: nil)
}
}
else {
self.alertErrors()
}
}
//alertNotAvailable()
}