-
-
Save SotoiGhost/61c3bbf5256616b768d81133cfeb62d9 to your computer and use it in GitHub Desktop.
Use of ISignInDelegate interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class ViewController : UIViewController, ISignInUIDelegate, ISignInDelegate | |
{ | |
public ViewController (IntPtr handle) : base (handle) | |
{ | |
} | |
public override void ViewDidLoad () | |
{ | |
base.ViewDidLoad (); | |
// TODO(developer) Configure the sign-in button look/feel | |
SignIn.SharedInstance.Delegate = this; | |
SignIn.SharedInstance.UIDelegate = this; | |
// Automatically sign in the user. | |
SignIn.SharedInstance.SignInUserSilently (); | |
ToggleAuthUI (); | |
statusText.Text = "Google Sign in\niOS Demo"; | |
} | |
partial void didTapSignOut (NSObject sender) | |
{ | |
SignIn.SharedInstance.SignOutUser (); | |
ToggleAuthUI (); | |
} | |
partial void didTapDisconnect (NSObject sender) | |
{ | |
SignIn.SharedInstance.DisconnectUser (); | |
} | |
void ToggleAuthUI () | |
{ | |
if (SignIn.SharedInstance.CurrentUser == null || SignIn.SharedInstance.CurrentUser.Authentication == null) { | |
// Not signed in | |
statusText.Text = "Google Sign in\niOS Demo"; | |
signInButton.Hidden = false; | |
signOutButton.Hidden = true; | |
disconnectButton.Hidden = true; | |
} else { | |
// Signed in | |
signInButton.Hidden = true; | |
signOutButton.Hidden = false; | |
disconnectButton.Hidden = false; | |
} | |
} | |
public override UIStatusBarStyle PreferredStatusBarStyle () | |
{ | |
return UIStatusBarStyle.LightContent; | |
} | |
#region Sign In Delegate | |
public void DidSignIn (SignIn signIn, GoogleUser user, NSError error) | |
{ | |
if (user != null && error == null) { | |
statusText.Text = string.Format ("Signed in user: {0}", user.Profile.Name); | |
ToggleAuthUI (); | |
} | |
} | |
[Export ("signIn:didDisconnectWithUser:withError:")] | |
public void DidDisconnect (SignIn signIn, GoogleUser user, NSError error) | |
{ | |
statusText.Text = "Disconnected user"; | |
ToggleAuthUI (); | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment