Beispiel #1
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);
     }
 }
Beispiel #2
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);
        }
Beispiel #3
0
        protected override void OnResume()
        {
            base.OnResume();

            AppEventsLogger.ActivateApp(this);

            UpdateUI();
        }
Beispiel #4
0
        //private void CreateAndShowDialog(string message, string title)
        //{
        //    AlertDialog.Builder builder = new AlertDialog.Builder(this);

        //    builder.SetMessage(message);
        //    builder.SetTitle(title);
        //    builder.Create().Show();
        //}

        protected override void OnCreate(Bundle bundle)
        {
            FormsAppCompatActivity.ToolbarResource = Resource.Layout.toolbar;

            base.OnCreate(bundle);

            Instance = this;

            App.ScreenWidth  = (int)Resources.DisplayMetrics.WidthPixels;  // real pixels
            App.ScreenHeight = (int)Resources.DisplayMetrics.HeightPixels; // real pixels

            FacebookSdk.SdkInitialize(ApplicationContext);
            AppEventsLogger.ActivateApp(Application);

            FacebookCallbackManager = CallbackManagerFactory.Create();
            //var facebookCallback = new FacebookCallback()
            //{
            //    HandleSuccess = (Xamarin.Facebook.Login.LoginResult loginResult) =>
            //    {
            //        //formsButton.LoginSuccess(loginResult.AccessToken.Token);
            //    },

            //    HandleCancel = () =>
            //    {
            //        // App code
            //    },

            //    HandleError = (FacebookException exception) =>
            //    {
            //        // App code
            //    }
            //};

            //LoginManager.Instance.RegisterCallback(FacebookCallbackManager, facebookCallback);
            //LoginManager.Instance.LogInWithReadPermissions(MainActivity.Instance, new[] { "public_profile" });


            //this.Window.AddFlags(WindowManagerFlags.Fullscreen);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            Xamarin.FormsMaps.Init(this, bundle);
            //Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
            UserDialogs.Init(() => (Activity)Forms.Context);
            ImageCircleRenderer.Init();

            LoadApplication(new App());
        }
Beispiel #5
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            FacebookSdk.SdkInitialize(this);
            AppEventsLogger.ActivateApp(this);

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

            DependencyService.Register <IFacebookManager, Droid_FacebookManager>();

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

            LoadApplication(new App());
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);


            // Create your application here

            #region Fb Implementation
            FacebookSdk.SdkInitialize(ApplicationContext);
            AppEventsLogger.ActivateApp(Application);

            fbloginButton = (Button)FindViewById(Resource.Id.LoginBtn);
            progressBar   = FindViewById <ProgressBar>(Resource.Id.progressbar);

            /*UpBger = (LinearLayout)FindViewById(Resource.Id.UpBger);
             * Whiter = (LinearLayout)FindViewById(Resource.Id.Whiter);
             * MainLinear = (RelativeLayout)FindViewById(Resource.Id.MainLinear);
             * animated_android = (ImageView)FindViewById(Resource.Id.LoadImg);*/

            /*AnimationDrawable animation = (AnimationDrawable)animated_android.Drawable;
             * animation.Start();*/

            mCallBackManager = CallbackManagerFactory.Create();
            LoginManager.Instance.RegisterCallback(mCallBackManager, this);
            fbloginButton.Click += delegate
            {
                //AnimateIris(UpBger);
                //AnimateIris2(Whiter, MainLinear);
                StartActivity(typeof(InterestSelectActivity));
                var list = new List <string>();
                list.Add("public_profile");
                list.Add("email");
                list.Add("user_birthday");
                list.Add("user_likes");

                //LoginManager.Instance.LogInWithReadPermissions(this, list);
            };
            #endregion
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            FacebookSdk.SdkInitialize(ApplicationContext);
            AppEventsLogger.ActivateApp(Application);

            callbackManager = CallbackManagerFactory.Create();
            LoginManager.Instance.RegisterCallback(callbackManager, facebookCallback);

            this.Window.AddFlags(WindowManagerFlags.Fullscreen);

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

            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();

            App.UIContext = this;
            LoadApplication(new ContosoMoments.App());

            instance = this;

#if PUSH // need to use a Google image on an Android emulator
            try {
                // Check to ensure everything's setup right
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException) {
                CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
            }
            catch (Exception e) {
                CreateAndShowDialog(e, "Error");
            }
#endif
        }
Beispiel #8
0
 public override void OnCreate()
 {
     base.OnCreate();
     FacebookSdk.SdkInitialize(ApplicationContext);
     AppEventsLogger.ActivateApp(this);
 }
 public static void OnActivated()
 {
     AppEventsLogger.ActivateApp(Android.App.Application.Context as Android.App.Application);
 }
        public static void Initialize(Activity activity)
        {
            mLogger          = AppEventsLogger.NewLogger(Android.App.Application.Context as Android.App.Application);
            mCallbackManager = CallbackManagerFactory.Create();
            CurrentActivity  = activity;

            loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult =>
                {
                    if (loginResult.AccessToken != null)
                    {
                        var fbArgs = new FBEventArgs <bool>(true, FacebookActionStatus.Completed);
                        _onLogin?.Invoke(CrossFacebookClient.Current, fbArgs);
                        _loginTcs?.TrySetResult(new FacebookResponse <bool>(fbArgs));

                        pendingAction?.Execute();

                        pendingAction = null;
                    }
                },
                HandleCancel = () =>
                {
                    var fbArgs = new FBEventArgs <bool>(false, FacebookActionStatus.Canceled, "User cancelled facebook operation");
                    _onLogin?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _loginTcs?.TrySetResult(new FacebookResponse <bool>(fbArgs));
                    //Handle any cancel the user has perform
                    Console.WriteLine("User cancelled facebook login operation");

                    pendingAction?.Execute();

                    pendingAction = null;
                },
                HandleError = loginError =>
                {
                    var fbArgs = new FBEventArgs <bool>(false, FacebookActionStatus.Error, loginError.ToString());
                    _onLogin?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _loginTcs?.TrySetResult(new FacebookResponse <bool>(fbArgs));

                    //Handle any error happends here
                    Console.WriteLine("Operation throws an error: " + loginError.ToString());

                    pendingAction?.Execute();
                    pendingAction = null;
                }
            };


            shareCallback = new FacebookCallback <SharerResult>
            {
                HandleSuccess = shareResult =>
                {
                    Dictionary <string, object> parameters = null;
                    if (shareResult.PostId != null)
                    {
                        parameters = new Dictionary <string, object>();
                        parameters.Add("postId", shareResult.PostId);
                    }
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(parameters, FacebookActionStatus.Completed);
                    _onSharing?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _shareTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                },
                HandleCancel = () =>
                {
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(null, FacebookActionStatus.Canceled, "User cancelled facebook operation");
                    _onSharing?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _shareTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                },
                HandleError = shareError =>
                {
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(null, FacebookActionStatus.Error, shareError.Message);
                    _onSharing?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _shareTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                }
            };


            gameRequestCallback = new FacebookCallback <GameRequestDialog.Result>
            {
                HandleSuccess = gameRequestResult =>
                {
                    if (!string.IsNullOrEmpty(gameRequestResult.RequestId))
                    {
                        Dictionary <string, object> parameters = new Dictionary <string, object>();

                        parameters.Add("requestId", gameRequestResult.RequestId);
                        var fbArgs = new FBEventArgs <Dictionary <string, object> >(parameters, FacebookActionStatus.Completed);
                        _onGameRequest?.Invoke(CrossFacebookClient.Current, fbArgs);
                        _gameRequestTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                    }
                },
                HandleCancel = () =>
                {
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(null, FacebookActionStatus.Canceled, "User cancelled facebook operation");
                    _onGameRequest?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _gameRequestTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                },
                HandleError = gameRequestError =>
                {
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(null, FacebookActionStatus.Error, gameRequestError.Message);
                    _onGameRequest?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _gameRequestTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                }
            };

            LoginManager.Instance.RegisterCallback(mCallbackManager, loginCallback);
        }
Beispiel #11
0
 public void PublishInstall()
 {
     AppEventsLogger.ActivateApp(Application.Context, _facebookApplicationID);
 }
 protected override void OnResume()
 {
     base.OnResume();
     AppEventsLogger.ActivateApp(Application);
 }
Beispiel #13
0
        protected override void OnPause()
        {
            base.OnPause();

            AppEventsLogger.DeactivateApp(this);
        }