Добавьте оповещение, если что-то не так во время покупки в приложении в Swift - PullRequest
0 голосов
/ 21 сентября 2019

Я разработал свое первое приложение и впервые внедряю In-App Purchase.Я следил за этим постом, чтобы сделать это. Как добавить покупку из приложения в приложение для iOS?

, и она отлично работает.

Теперь я хотел бы добавить предупреждение, если что-то не так.Но я не могу добавить: Import UIKit

и self.present (alert, animated: true, extension: nil) генерируют ошибку "Тип 'RemoveAdsManager' не имеет члена 'присутствует'"

Код:

import Foundation
import StoreKit

public class RemoveAdsManager {

 //...

class func removeAdsFailure(){
    // Send the user a message explaining that the IAP
    // failed for some reason, and to try again later
    let alert  = UIAlertController(title: NSLocalizedString("Attention",comment:""), message: NSLocalizedString("L'achat In-App n'a pas fonctionné. Veuillez essayer plus tard.",comment:""), preferredStyle: .alert)
    alert.addAction(UIAlertAction(title: NSLocalizedString("OK",comment:""), style: .default, handler: nil))
    self.present(alert, animated: true, completion: nil)
    NSLog(NSLocalizedString("L'achat In-App n'a pas fonctionné. Veuillez essayer plus tard.",comment:""))
}
}

при изменении класса на

public class RemoveAdsManager : UIViewController {
//....
}

ошибка становится «Элемент экземпляра« присутствует »не может использоваться для типа« RemoveAdsManager »»

Что мне делать?

...