0

xcode

In my Application after clicking on cancel the app navigating to home screen


in viewDidLoad

googleButton.addTarget(self, action: #selector(signInUserUsingGoogle(_:)), for:.touchUpInside)

func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {


        if let error = error{
            print("we have error sign in user ==\(error.localizedDescription)")
            }

        else{
            if let gmailUser = user{
                performSegue(withIdentifier: "login", sender: self)

            }
        }    } 
Marwen Doukh
  • 1,946
  • 17
  • 26
vamsi
  • 592
  • 1
  • 7
  • 14
  • You shouldn't terminate the app manually at all: https://developer.apple.com/library/archive/qa/qa1561/_index.html – user28434'mstep May 21 '19 at 12:44
  • you shouldn't do it, but you can throw a `fatalError()` or `exit(0)` – Alastar May 21 '19 at 12:50
  • OK I don't want to terminate but I need to close app when user clicks cancel button bcz my app navigating to home screen – vamsi May 21 '19 at 13:26
  • where I can add that fatal error? – vamsi May 21 '19 at 13:26
  • Closing app is not a good option and will not be accepted by Apple too. So you can either stop user on that screen until they grant permission for sign in, or you need to find an alternative option to it. Alternative option, would be some other form of login. – manishsharma93 May 22 '19 at 13:19
  • @manisharma thank you for your solution and can you explain me how to stop user to grant permission until sign in bcz I don't have alternate login – vamsi May 23 '19 at 09:34

1 Answers1

1

you can close the app using function exit(0), but it is not recommended, because Apple will reject your app if you did this.

please take a look here: How to fix `The user canceled the sign-in flow.` with Sign In with Google on iOS?

omartarek32
  • 179
  • 6
  • Is there any other alternate to do bcz I should close the app or anything rather than getting into app – vamsi May 22 '19 at 05:29
  • you should to change your app navigation architecture to navigate to login screen again if the user press cancel – omartarek32 May 22 '19 at 11:20