protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.login_activity);
            //return base.OnOptionsItemSelected(item);

            FirebaseApp.InitializeApp(this);
            _auth = FirebaseAuth.Instance;

            GoogleButton        = FindViewById <SignInButton>(Resource.Id.gButton);
            GoogleButton.Click += (object sender, System.EventArgs e) =>
            {
                var signGoogleintent = Auth.GoogleSignInApi.GetSignInIntent(_googleApiClient);

                StartActivityForResult(signGoogleintent, Constants.ActionResult.GoogleLoginResul);
            };

            FacebookButton = FindViewById <LoginButton>(Resource.Id.fButton);
            FacebookButton.SetReadPermissions("email", "public_profile");

            callbackManager = CallbackManagerFactory.Create();
            FacebookButton.RegisterCallback(callbackManager, this);

            _googleApiClient = LoginHelper.ConfigureGoogleSignIn(this);
        }
        //CognitoAccessTokenTracker tracker;

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

            callbackManager = CallbackManagerFactory.Create();

            LoginManager.Instance.RegisterCallback(callbackManager, new FacebookCallback <LoginResult>()
            {
                HandleSuccess = loginResult =>
                {
                    var accessToken = loginResult.AccessToken;
                    CognitoSyncUtils.UpdateCredentials(accessToken.Token);
                    Intent todoActivity = new Intent(this, typeof(TodoActivity));
                    StartActivity(todoActivity);
                },
                HandleCancel = () =>
                {
                    CognitoSyncUtils.UpdateCredentials(string.Empty);
                },
                HandleError = loginError =>
                {
                    CognitoSyncUtils.UpdateCredentials(string.Empty);
                }
            });
            LoginManager.Instance.LogInWithReadPermissions(this, new List <string> {
                "public_profile"
            });

            CognitoSyncUtils.Initialize();
        }
Пример #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            TabLayoutResource = Resource.Layout.tabs;
            ToolbarResource   = Resource.Layout.toolbar;

            CachedImageRenderer.Init();
            global::Xamarin.Forms.Forms.Init(this, bundle);

            if (callbackManager == null)
            {
                callbackManager = CallbackManagerFactory.Create();
            }

            if (IsPlayServicesAvailable())
            {
                var intent = new Intent(this, typeof(RegistrationIntentService));
                StartService(intent);
            }

            var userId   = Intent.GetStringExtra("userId");
            var token    = Intent.GetStringExtra("token");
            var userName = Intent.GetStringExtra("userName");

            LoadApplication(new App(new AndroidInitializer(), token));
        }
Пример #4
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            ////Per ottenere la hash key da inserire in facebook
            //PackageInfo info = this.PackageManager.GetPackageInfo("it.trilogik.AppFocGenova", PackageInfoFlags.Signatures);
            //foreach (Android.Content.PM.Signature signature in info.Signatures)
            //{
            //    MessageDigest md = MessageDigest.GetInstance("SHA");
            //    md.Update(signature.ToByteArray());

            //    string keyhash = Convert.ToBase64String(md.Digest());
            //    Console.WriteLine("KeyHash:", keyhash);
            //}


            FacebookSdk.SdkInitialize(ApplicationContext);
            callbackManager = CallbackManagerFactory.Create();



            LoginManager.Instance.RegisterCallback(callbackManager, new facebookCallBack());
            LoadApplication(new App());
        }
Пример #5
0
        /*****************************************************************/
        // CONSTRUCTOR
        /*****************************************************************/
        #region Constructor

        public AndroidFacebookService()
        {
            Activity = MainActivity.Instance;
            // Create callback manager using CallbackManagerFactory
            CallbackManager = CallbackManagerFactory.Create();
            LoginManager.Instance.RegisterCallback(CallbackManager, this);
        }
Пример #6
0
        /**
         * Init Facebook
         */
        public void Init()
        {
            FacebookSdk.SdkInitialize(activity.ApplicationContext);
            FacebookSdk.ApplicationId = activity.Resources.GetString(Resource.String.facebook_app_id);
            callbackManager           = CallbackManagerFactory.Create();
            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult =>
                {
                    token = loginResult.AccessToken;
                    (Xamarin.Forms.Application.Current as Hauynite).OnLogin(token.UserId);
                    var intent = new Intent(FacebookLoginReceiver.ActionKey);
                    intent.PutExtra(FacebookLoginReceiver.ExtraResult, (int)Result.Success);
                    intent.PutExtra(FacebookLoginReceiver.ExtraUserId, token.UserId);
                    activity.SendBroadcast(intent);
                },
                HandleCancel = () =>
                {
                    var intent = new Intent(FacebookLoginReceiver.ActionKey);
                    intent.PutExtra(FacebookLoginReceiver.ExtraResult, (int)Result.Cancel);
                    activity.SendBroadcast(intent);
                },
                HandleError = loginError =>
                {
                    var intent = new Intent(FacebookLoginReceiver.ActionKey);
                    intent.PutExtra(FacebookLoginReceiver.ExtraResult, (int)Result.Error);
                    activity.SendBroadcast(intent);
                }
            };

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);
        }
Пример #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            Window.RequestFeature(WindowFeatures.NoTitle);
            Com.Pixate.Freestyle.PixateFreestyle.Init(this);

            FacebookSdk.SdkInitialize(this.ApplicationContext);

            mProfileTracker = new MyProfileTracker();
            mProfileTracker.mOnProfileChanged += mProfileTracker_mOnProfileChanged;
            mProfileTracker.StartTracking();
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);



            Button btnFacebook = FindViewById <Button>(Resource.Id.btnFacebook);

            mBtnCriar      = FindViewById <Button>(Resource.Id.btnCriarConta);
            mTxtLogarEmail = FindViewById <TextView>(Resource.Id.logarEmail);

            mBtnCriar.Click      += MBtnCriar_Click;
            mTxtLogarEmail.Click += mTxtLogarEmail_Click;


            if (AccessToken.CurrentAccessToken != null)
            {
                //The user is logged in through Facebook
                btnFacebook.Text = "Sair";
            }


            // LoginButton button = FindViewById<LoginButton>(Resource.Id.btnFacebook);
            //  button.SetReadPermissions("user_friends");

            mCallBackManager = CallbackManagerFactory.Create();
            // button.RegisterCallback(mCallBackManager, this);

            LoginManager.Instance.RegisterCallback(mCallBackManager, this);



            btnFacebook.Click += (o, e) =>
            {
                if (AccessToken.CurrentAccessToken != null)
                {
                    //The user is logged in through Facebook
                    LoginManager.Instance.LogOut();
                    btnFacebook.Text = "Logue com Facebook";
                }
                else
                {
                    //The user is not logged in
                    LoginManager.Instance.LogInWithReadPermissions(this, new List <string> {
                        "public_profile", "user_friends"
                    });
                    btnFacebook.Text = "Sair";
                }
            };
        }
Пример #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);



            //PackageInfo info = PackageManager.GetPackageInfo();
            //      "Package name",  //Replace your package name here
            //      PackageManager.GET_SIGNATURES);
            //for (Signature signature : info.signatures)
            //{
            //    MessageDigest md = MessageDigest.getInstance("SHA");
            //    md.update(signature.toByteArray());
            //    Log.e("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
            //}

            FacebookSdk.SdkInitialize(this.ApplicationContext);
            mprofileTracker = new MyProfileTracker();
            mprofileTracker.mOnProfileChanged += mProfileTracker_mOnProfileChanged;
            mprofileTracker.StartTracking();
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            BtnFBLogin   = FindViewById <LoginButton>(Resource.Id.fblogin);
            TxtFirstName = FindViewById <TextView>(Resource.Id.TxtFirstname);
            TxtLastName  = FindViewById <TextView>(Resource.Id.TxtLastName);
            TxtName      = FindViewById <TextView>(Resource.Id.TxtName);
            mprofile     = FindViewById <ProfilePictureView>(Resource.Id.ImgPro);

            BtnFBLogin.SetReadPermissions(new List <string> {
                "user_friends", "public_profile"
            });
            mFBCallManager = CallbackManagerFactory.Create();
            BtnFBLogin.RegisterCallback(mFBCallManager, this);
        }
Пример #9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            //FacebookSdk.ApplicationId should be set before LoginManager.Instance.LogInWithReadPermissions is called, otherwise
            //the application will crash
            FacebookSdk.ApplicationId   = Constants.FB_APP_ID;
            FacebookSdk.ApplicationName = Constants.FB_APP_NAME;
            FacebookSdk.SdkInitialize(this.ApplicationContext);

            LoadApplication(new App());

            callbackManager = CallbackManagerFactory.Create();

            LoginManager.Instance.RegisterCallback(callbackManager, new FacebookCallback <LoginResult>()
            {
                HandleSuccess = loginResult =>
                {
                    var accessToken = loginResult.AccessToken;
                    App.OnFacebookAuthSuccess(accessToken.Token);
                },
                HandleCancel = () =>
                {
                    App.OnFacebookAuthFailed();
                },
                HandleError = loginError =>
                {
                    App.OnFacebookAuthFailed();
                }
            });
        }
Пример #10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            //FacebookSDK Config
            FacebookSdk.SdkInitialize(this.ApplicationContext);
            CallbackManager = CallbackManagerFactory.Create();

            //AWS SDK Config
            var loggingConfig = AWSConfigs.LoggingConfig;

            loggingConfig.LogMetrics       = true;
            loggingConfig.LogResponses     = ResponseLoggingOption.Always;
            loggingConfig.LogMetricsFormat = LogMetricsFormatOption.JSON;
            loggingConfig.LogTo            = LoggingOptions.SystemDiagnostics;
            AWSConfigs.AWSRegion           = "eu-west-1";

            //Google Maps Config
            Xamarin.FormsMaps.Init(this, bundle);

            ActionBar.SetIcon(Android.Resource.Color.Transparent);
            LoadApplication(new App());
        }
Пример #11
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            //((DroidLoginProvider)DependencyService.Get<ILoginProvider>()).Init(this);

            FacebookSdk.SdkInitialize(ApplicationContext);
            callbackManager = CallbackManagerFactory.Create();


            //var loginCallback = new FacebookCallback<LoginResult>
            //{
            //    HandleSuccess = loginResult => {
            //        var tck =AccessToken.CurrentAccessToken.Token;
            //        //CoffeeCups.Helpers.Settings.FacebookAccessToken = AccessToken.CurrentAccessToken.Token;
            //        App.GoToMainPage();
            //    },
            //    HandleCancel = () => {

            //    },
            //    HandleError = loginError => {

            //    }
            //};



            LoginManager.Instance.RegisterCallback(callbackManager, new facebookCallBack());
            LoadApplication(new App());
        }
Пример #12
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);
            global::Xamarin.Forms.Forms.Init(this, bundle);

            //facebook implementation
            callbackManager = CallbackManagerFactory.Create();

            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = (loginResult) =>
                {
                    //proceed next page
                    App.ProceedToHome();
                },
                HandleCancel = () =>
                {
                    //handle cancel
                },
                HandleError = (loginError) =>
                {
                    //handle error
                }
            };

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);

            LoadApplication(new App());
            FirebaseApp.InitializeApp(this);
        }
        private void InitializedFB()
        {
            activity = this.Context as Activity;
            view     = activity.LayoutInflater.Inflate(Resource.Layout.FacebookLayout, this, false);

            FacebookSdk.SdkInitialize(this.Context);
            NativeFacebookPageRenderer.callbackManager = CallbackManagerFactory.Create();

            #region CHECKING IF ALREADY LOGGED IN TO FACEBOOK
            profile = Profile.CurrentProfile;

            if (profile != null)
            {
                firstname = profile.FirstName;
                lastname  = profile.LastName;
                GetUserInfoViaGraphRequest();
            }

            #endregion

            LoginManager.Instance.RegisterCallback(NativeFacebookPageRenderer.callbackManager, this);
            var buttonFB = view.FindViewById <Button>(Resource.Id.buttonFB);
            buttonFB.Click    += ButtonFB_Click;
            profilePictureView = view.FindViewById <ProfilePictureView>(Resource.Id.profilePicture);

            this.AddView(view);
            NativeView = view;
        }
        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);
        }
Пример #15
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            FacebookSdk.SdkInitialize(this.ApplicationContext);

            LoadApplication(new App());

            callbackManager = CallbackManagerFactory.Create();

            LoginManager.Instance.RegisterCallback(callbackManager, new FacebookCallback <LoginResult>()
            {
                HandleSuccess = loginResult =>
                {
                    var accessToken = loginResult.AccessToken;
                    App.OnFacebookAuthSuccess(accessToken.Token);
                },
                HandleCancel = () =>
                {
                    App.OnFacebookAuthFailed();
                },
                HandleError = loginError =>
                {
                    App.OnFacebookAuthFailed();
                }
            });
        }
Пример #16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Facebook API initialization
            FacebookSdk.SdkInitialize(this.ApplicationContext);
            AppEventsLogger.ActivateApp(this.Application);

            _masterProfileTracker = new FBProfileTracker();
            _masterProfileTracker.mOnProfileChanged += MasterProfileTracker_mOnProfileChanged;
            _masterProfileTracker.StartTracking();

            // Create your application here
            SetContentView(Resource.Layout.FacebookLoginView);

            _fullNameTextView    = FindViewById <TextView>(Resource.Id.fullNameTextView);
            _facebookLoginButton = FindViewById <LoginButton>(Resource.Id.facebookLoginButton);

            _facebookLoginButton.SetReadPermissions(new List <string> {
                "user_friends",
                "public_profile"
            });
            _masterFBCallManager = CallbackManagerFactory.Create();
            _facebookLoginButton.RegisterCallback(_masterFBCallManager, this);
        }
Пример #17
0
        /// <summary>
        /// Ons the create.
        /// </summary>
        /// <param name="savedInstanceState">Saved instance state.</param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            #region [ Facebook ]

            FacebookSdk.SdkInitialize(ApplicationContext);
            callbackManager = CallbackManagerFactory.Create();

            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult => {
                    var facebookToken = AccessToken.CurrentAccessToken.Token;
                },
                HandleCancel = () => {
                },
                HandleError  = loginError => {
                }
            };

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);

            #endregion



            LoadApplication(new App());
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_login);

            this.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            this.Window.ClearFlags(WindowManagerFlags.TranslucentStatus);
            this.Window.SetStatusBarColor(Color.ParseColor("#204060"));
            progressBar           = FindViewById <ProgressBar>(Resource.Id.progressBar);
            googlebutton          = FindViewById <Button>(Resource.Id.googlebutton);
            googlebutton.Click   += Googlebutton_Click;
            facebookbutton        = FindViewById <Button>(Resource.Id.facebookbutton);
            facebookbutton.Click += Facebookbutton_Click;
            fb_dummybuttton       = FindViewById <LoginButton>(Resource.Id.fb_dummybuttton);
            fb_dummybuttton.SetReadPermissions(new List <string> {
                "public_profile", "email"
            });
            callbackManager = CallbackManagerFactory.Create();
            fb_dummybuttton.RegisterCallback(callbackManager, this);


            gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn).RequestIdToken("787402240794-prndui4ntngl1je2lglu46lev1esogsi.apps.googleusercontent.com")
                  .RequestEmail().Build();
            googleApiClient = new GoogleApiClient.Builder(this).AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build();
            googleApiClient.Connect();
            firebaseAuth         = AppDataHelper.GetFirebaseAuth();
            prefs                = PreferenceManager.GetDefaultSharedPreferences(this);
            AppDataHelper.editor = prefs.Edit();
        }
Пример #19
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            Window.RequestFeature(WindowFeatures.NoTitle);

#pragma warning disable CS0618 // Type or member is obsolete
            FacebookSdk.SdkInitialize(this.ApplicationContext);
#pragma warning restore CS0618 // Type or member is obsolete


            SetContentView(Resource.Layout.Main);

            //LoginButton button = FindViewById<LoginButton>(Resource.Id.login_button);

            //button.SetReadPermissions("user_friends");
            mCallBackManager = CallbackManagerFactory.Create();

            //button.RegisterCallback(mCallBackManager, this);

            LoginManager.Instance.RegisterCallback(mCallBackManager, this);

            FindViewById <Button>(Resource.Id.button).Click += (o, e) =>
            {
                LoginManager.Instance.LogInWithReadPermissions(this, new List <string> {
                    "public_profile", "user_friends"
                });
            };
        }
Пример #20
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data)
 {
     try
     {
         FacebookSdk.SdkInitialize(this);
         // FacebookSdk.ApplicationId = "444917649791842"; //pune el id de la app de facebook
         AppEventsLogger.ActivateApp(Application); //no se que hace esta linea
         mprofileTracker = new MyProfileTracker();
         mprofileTracker.mOnProfileChanged += MprofileTracker_mOnProfileChanged;
         mprofileTracker.StartTracking();
         // Set our view from the "main" layout resource
         // SetContentView(Resource.Layout.configCuenta);
         //BtnFBLogin = FindViewById<LoginButton>(Resource.Id.fb_btn);
         BtnFBLogin.SetReadPermissions(new List <string> {
             "public_profile", "user_friends", "email", "user_birthday"
         });
         mFBCallManager = CallbackManagerFactory.Create();
         BtnFBLogin.RegisterCallback(mFBCallManager, this);
         //base.OnActivityResult(requestCode, resultCode, data);
         mFBCallManager.OnActivityResult(requestCode, (int)resultCode, data);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         Console.WriteLine(e); Console.WriteLine(e);
         Console.WriteLine(e); Console.WriteLine(e);
         Console.WriteLine(e); Console.WriteLine(e);
         Console.WriteLine(e); Console.WriteLine(e);
         Console.WriteLine(e);
         Console.WriteLine(e);
     }
 }
Пример #21
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.LoginView);

            if (Profile.CurrentProfile != null && AccessToken.CurrentAccessToken?.Token != null)
            {
                ChangeActivity();
            }

            var button = FindViewById <LoginButton>(Resource.Id.login_button);

            mCallBackManager = CallbackManagerFactory.Create();

            button.SetReadPermissions("user_friends");

            button.RegisterCallback(mCallBackManager, this);



            // resolve keyHash

            //var info = this.PackageManager.GetPackageInfo("com.test.PartyOrganizer", Android.Content.PM.PackageInfoFlags.Signatures);

            //foreach (var signature in info.Signatures)
            //{
            //    var md = MessageDigest.GetInstance("SHA");
            //    md.Update(signature.ToByteArray());

            //    var keyHash = Convert.ToBase64String(md.Digest());

            //}
        }
Пример #22
0
        public static void RegisterFacebookCallbacks()
        {
            CallbackManager = CallbackManagerFactory.Create();

            LoginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult =>
                {
                    FacebookSdk.ClientToken = AccessToken.CurrentAccessToken.Token;
                    FacebookProfileTracker.StartTracking();
                    FacebookLoggedIn = true;
                },

                HandleCancel = () =>
                {
                },

                HandleError = loginError =>
                {
                    Console.WriteLine("fb login error");
                },

                HandleLogout = () =>
                {
                }
            };

            LoginManager.Instance.RegisterCallback(CallbackManager, LoginCallback);
        }
Пример #23
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.AuthActivity);
            DroidDAL.HockeyAppRegister(this);

            _view = FindViewById <AuthView>(Resource.Id.auth_view);

            InitStatusBar();

            ThemeHolder.Init(DataService.RepositoryController.RepositoryThemes);
            _interactor = new InteractorAuth(new AuthController(ConnectionController.GetInstance(), WebMsgParser.ParseResponseAuth), new ValidationRA());
#if MOCK
            _presenter = new PresenterAuthMOCK(_view, _interactor, new RouterAuth(this), FacebookCallLoginAction, GoogleCallLoginAction, VkCallLoginAction, OkCallLoginAction,
                                               new AuthStylesHolderDroid <GlobalControlsTheme>(new ThemeParser <GlobalControlsTheme>()), DataService.RepositoryController.RepositoryRA.LangRA);
#else
            _presenter = new PresenterAuth(_view, _interactor, new RouterAuth(this), FacebookCallLoginAction, GoogleCallLoginAction, VkCallLoginAction, OkCallLoginAction,
                                           new AuthStylesHolderDroid <GlobalControlsTheme>(new ThemeParser <GlobalControlsTheme>()), DataService.RepositoryController.RepositoryRA.LangRA);
#endif
            _presenter.SetConfig();

            _callbackManager  = CallbackManagerFactory.Create();
            _facebookCallback = new FacebookCallback(_interactor);
            LoginManager.Instance.RegisterCallback(_callbackManager, _facebookCallback);
            _interactor.OnSocialLogOut += SocialLogOut;
        }
        public async Task <IFacebookAccount> AuthenticateAsync(IFacebookAuthOptions options)
        {
            await LogoutAsync();

            //Check if we have a cached login already that's still good

            var currentAccessToken = AccessToken.CurrentAccessToken;

            if (currentAccessToken != null && (currentAccessToken.Expires == null || ToManagedDateTime(currentAccessToken.Expires) > DateTime.UtcNow))
            {
                // If we also have a profile, we have enough information to return a good account
                // without actuall doing the sign in flow
                var currentProfile = Profile.CurrentProfile;
                if (currentProfile != null)
                {
                    return(populateAccount(currentAccessToken, currentProfile, options.RequestedPhotoSize));
                }
            }

            var activity = Plugin.SocialAuth.Droid.SocialAuth.CurrentActivity;

            if (callbackManager == null)
            {
                callbackManager = CallbackManagerFactory.Create();
            }
            var loginManager = LoginManager.Instance;
            var fbHandler    = new FbCallbackHandler();

            loginManager.RegisterCallback(callbackManager, fbHandler);

            fbHandler.Reset();

            if (options?.WritePermissions ?? false)
            {
                loginManager.LogInWithPublishPermissions(activity, options?.Scopes);
            }
            else
            {
                loginManager.LogInWithReadPermissions(activity, options?.Scopes);
            }

            LoginResult result = null;

            try
            {
                result = await fbHandler.Task;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (result == null || result.AccessToken == null)
            {
                return(null);
            }

            return(populateAccount(result.AccessToken, Profile.CurrentProfile, options.RequestedPhotoSize));
        }
Пример #25
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            FacebookSdk.SdkInitialize(this);
            SetContentView(Resource.Layout.Main);

            FindViewById <LoginButton>(Resource.Id.login_button).SetReadPermissions("email");
            callbackManager = CallbackManagerFactory.Create();

            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = SignInWithFacebookToken,
                HandleCancel  = () => Log.Debug(
                    Application.PackageName,
                    "Canceled"),
                HandleError = error => Log.Error(
                    Application.PackageName,
                    Java.Lang.Throwable.FromException(error),
                    "No access")
            };

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);

            carService   = new CarService();
            tokenTracker = new FacebookTokenTracker(carService)
            {
                HandleLoggedIn  = UpdateButtons,
                HandleLoggedOut = UpdateButtons
            };

            tokenTracker.StartTracking();

            if (carService.GetLoginStatus() == CarService.LoginStatus.NeedsWebApiToken)
            {
                await SignInWithFacebookToken(AccessToken.CurrentAccessToken.Token);
            }

            UpdateButtons();

            searchCar         = FindViewById <AutoCompleteTextView>(Resource.Id.searchCar);
            findCar           = FindViewById <Button>(Resource.Id.findCar);
            showAvailableCars = FindViewById <Button>(Resource.Id.showAvailableCars);

            findCar.Click         += findCar_Click;
            findCar.Enabled        = false;
            searchCar.TextChanged += (sender, e) =>
            {
                if (searchCar.Text.Length > 4)
                {
                    findCar.Enabled = true;
                }
                else
                {
                    findCar.Enabled = false;
                }
            };

            showAvailableCars.Click += (sender, args) => StartActivity(typeof(allAvailableActivity));
        }
        public FacebookService(Activity activity)
        {
            _activity = activity;

            _callbackManager = CallbackManagerFactory.Create();

            LoginManager.Instance.RegisterCallback(_callbackManager, new FacebookCallback(this));
        }
Пример #27
0
 private void botonFB(object sender, EventArgs e)
 {
     btnFacebook.SetReadPermissions(new List <string> {
         "public_profile", "user_friends", "email"
     });
     mCallBackManager = CallbackManagerFactory.Create();
     btnFacebook.RegisterCallback(mCallBackManager, this);
 }
        private void InitSocialLogins()
        {
            try
            {
                //#Facebook
                if (AppSettings.ShowFacebookLogin)
                {
                    //FacebookSdk.SdkInitialize(this);

                    ProfileTracker = new FbMyProfileTracker();
                    ProfileTracker.MOnProfileChanged += ProfileTrackerOnMOnProfileChanged;
                    ProfileTracker.StartTracking();

                    BtnFbLogin            = FindViewById <LoginButton>(Resource.Id.fblogin_button);
                    BtnFbLogin.Visibility = ViewStates.Visible;
                    BtnFbLogin.SetPermissions(new List <string>
                    {
                        "email",
                        "public_profile"
                    });

                    MFbCallManager = CallbackManagerFactory.Create();
                    BtnFbLogin.RegisterCallback(MFbCallManager, this);

                    //FB accessToken
                    var accessToken = AccessToken.CurrentAccessToken;
                    var isLoggedIn  = accessToken != null && !accessToken.IsExpired;
                    if (isLoggedIn && Profile.CurrentProfile != null)
                    {
                        LoginManager.Instance.LogOut();
                    }

                    string hash = Methods.App.GetKeyHashesConfigured(this);
                    Console.WriteLine(hash);
                }
                else
                {
                    BtnFbLogin            = FindViewById <LoginButton>(Resource.Id.fblogin_button);
                    BtnFbLogin.Visibility = ViewStates.Gone;
                }

                //#Google
                if (AppSettings.ShowGoogleLogin)
                {
                    MGoogleSignIn        = FindViewById <Button>(Resource.Id.Googlelogin_button);
                    MGoogleSignIn.Click += GoogleSignInButtonOnClick;
                }
                else
                {
                    MGoogleSignIn            = FindViewById <Button>(Resource.Id.Googlelogin_button);
                    MGoogleSignIn.Visibility = ViewStates.Gone;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 void IFacebookApiClient.SetFacebookAppID(string appID)
 {
     FacebookSdk.ApplicationId           = appID;
     FacebookSdk.AutoLogAppEventsEnabled = false;
     FacebookSdk.SdkInitialize(Forms.Context.ApplicationContext);
     CallbackManager = CallbackManagerFactory.Create();
     LoginManager.Instance.RegisterCallback(CallbackManager, this);
     LoginManager.Instance.SetLoginBehavior(LoginBehavior.WebOnly);
 }
Пример #30
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     sessionManager  = SessionManager.GetInstance();
     mAuth           = sessionManager.GetFirebaseAuth();
     mainActivity    = MainActivity.Instance;
     callbackManager = CallbackManagerFactory.Create();
     // Create your fragment here
 }