protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            callbackManager = CallbackManagerFactory.Create();

            var loginCallback = new FacebookCallback <LoginResult> {
                HandleSuccess = loginResult => {
                    OnFacebookLoginSuccess();                           /// raise event
                    this.Finish();
                },
                HandleCancel = () => {
                    OnFacebookLoginCancel();                            // raise event
                    this.Finish();
                },
                HandleError = loginError => {
                    OnFacebookLoginError();                             // raise event
                    this.Finish();
                }
            };

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);

            string[] PERMISSIONS = Intent.GetStringArrayExtra("permissions");
            LoginManager.Instance.LogInWithReadPermissions(this, PERMISSIONS);
        }
Example #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            callbackManager = CallbackManagerFactory.Create();

            var loginCallback = new FacebookCallback <LoginResult> {
                HandleSuccess = loginResult => {
                    OnFacebookLoginSuccess(loginResult.AccessToken);                            /// raise event
                    this.Finish();
                },
                HandleCancel = () => {
                    OnFacebookLoginCancel(null);                        // raise event
                    this.Finish();
                },
                HandleError = loginError => {
                    OnFacebookLoginError(null);                                 // raise event
                    this.Finish();
                }
            };

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);

            string[] PERMISSIONS = Intent.GetStringArrayExtra("permissions");

            try {
                if (PERMISSIONS.Contains <string>("publish_actions"))
                {
                    LoginManager.Instance.LogInWithPublishPermissions(this, PERMISSIONS);
                }
                else
                {
                    LoginManager.Instance.LogInWithReadPermissions(this, PERMISSIONS);
                }
            } catch (Exception e) {
                System.Diagnostics.Debug.WriteLine("FacebookService Error: {0}", e.Message);
            }
        }