выполнить переход после того, как AdMob объявление уволен - PullRequest
0 голосов
/ 01 июля 2018

любая идея о том, как выполнить этот переход. Как только пользователи зарегистрируются и будут аутентифицированы, им будет показана промежуточная реклама. Однако, как только объявление сделано или отклонено. переход к следующему контроллеру представления должен быть выполнен. Я не совсем уверен, что мне не хватает в моем коде:

@IBAction func signUpBtn_TouchUpInside(_ sender: Any) {
    view.endEditing(true)
    ProgressHUD.show("Waiting...", interaction: false)
    if let profileImg = self.selectedImage, let imageData = UIImageJPEGRepresentation(profileImg, 0.1) {
        AuthService.signUp(username: usernameTextField.text!, email: emailTextField.text!, password: passwordTextField.text!, imageData: imageData, onSuccess: {
            ProgressHUD.showSuccess("Success")
            if self.interstitial.isReady {
                self.interstitial.present(fromRootViewController: self)
            } else {
                print("Ad wasn't ready")
                self.performSegue(withIdentifier: "signUpToTabbarVC", sender: nil)
            }
            self.performSegue(withIdentifier: "signUpToTabbarVC", sender: nil)
        }, onError: { (errorString) in
            ProgressHUD.showError(errorString!)
        })
    } else {
        ProgressHUD.showError("Profile Image can't be empty")
    }
}

и помощь или обратная связь всегда высоко ценится

1 Ответ

0 голосов
/ 01 июля 2018

Вы должны согласовать свой ViewController с interstitial delegate и выполнить segue, когда interstitial отклонен

extension ViewController: GADInterstitialDelegate {

    func interstitialDidDismissScreen(_ ad: GADInterstitial) {
        self.performSegue(withIdentifier: "signUpToTabbarVC", sender: nil)
    }
}

И обновить signUpBtn_TouchUpInside метод, как показано ниже,

@IBAction func signUpBtn_TouchUpInside(_ sender: Any) {
    view.endEditing(true)
    ProgressHUD.show("Waiting...", interaction: false)
    if let profileImg = self.selectedImage, let imageData = UIImageJPEGRepresentation(profileImg, 0.1) {
        AuthService.signUp(username: usernameTextField.text!, email: emailTextField.text!, password: passwordTextField.text!, imageData: imageData, onSuccess: {
            self.handleSignupSuccess()
        }, onError: { (errorString) in
            ProgressHUD.showError(errorString!)
        })
    } else {
        ProgressHUD.showError("Profile Image can't be empty")
    }
}

private func handleSignupSuccess() {
   ProgressHUD.showSuccess("Success")
   if self.interstitial.isReady {   
       self.interstitial.delegate = self          
       self.interstitial.present(fromRootViewController: self)
   } else {
      print("Ad wasn't ready"
      self.performSegue(withIdentifier: "signUpToTabbarVC", sender: nil)
   }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...