コード例 #1
0
        public Task LogoutAsync()
        {
            var loginManager = new global::Facebook.LoginKit.LoginManager();

            loginManager.LogOut();

            return(Task.CompletedTask);
        }
コード例 #2
0
        public static Task Login(params Field[] requestedFields)
        {
            IsLoginCall       = true;
            CurrentParameters = GetRequiredPermissions(requestedFields);
            LoginManager      = new SDK.LoginKit.LoginManager();
            LoginManager.LogIn(CurrentParameters, UIViewController,
                               new SDK.LoginKit.LoginManagerLoginResultBlockHandler(RequestTokenHandler));

            return(Task.CompletedTask);
        }
コード例 #3
0
        public async Task <IFacebookAccount> AuthenticateAsync(IFacebookAuthOptions options)
        {
            await LogoutAsync();

            var currentAccessToken = global::Facebook.CoreKit.AccessToken.CurrentAccessToken;

            if (currentAccessToken != null &&
                (currentAccessToken.ExpirationDate == null || ((DateTime)currentAccessToken.ExpirationDate).ToUniversalTime() > DateTime.UtcNow))
            {
                var currentProfile = global::Facebook.CoreKit.Profile.CurrentProfile;

                if (currentProfile != null)
                {
                    populateAccount(currentAccessToken, currentProfile, options.RequestedPhotoSize);
                }
            }

            var loginManager = new global::Facebook.LoginKit.LoginManager();

            var vc = global::Plugin.SocialAuth.iOS.SocialAuth.PresentingViewController;

            global::Facebook.LoginKit.LoginManagerLoginResult resp = null;

            var scopes = options?.Scopes ?? new string[] { };

            if (options?.WritePermissions ?? false)
            {
                resp = await loginManager.LogInWithPublishPermissionsAsync(scopes, vc);
            }
            else
            {
                resp = await loginManager.LogInWithReadPermissionsAsync(scopes, vc);
            }

            if (resp.IsCancelled)
            {
                return(null);
            }

            if (resp == null || resp.Token == null)
            {
                return(null);
            }

            return(populateAccount(resp.Token, global::Facebook.CoreKit.Profile.CurrentProfile, options.RequestedPhotoSize));
        }