async public void OnSuccess(Java.Lang.Object result)
        {
            var loginResult = result as LoginResult;

            if (loginResult == null)
            {
                return;
            }


            string tokenString = AccessToken.CurrentAccessToken.Token;

            if (String.IsNullOrEmpty(tokenString))
            {
                ShowAlert("3", "Token Empty");
                AppCenterManager.Report("3");
                return;
            }

            string userId = loginResult.AccessToken.UserId;


            ShowHud("Loading");

            bool sucessful = await Shared.CreateUser(tokenString);

            if (!sucessful)
            {
                HideHud();
                LoginManager.Instance.LogOut();
                RealmUserServices.Logout();
                AppCenterManager.Report("4");
                return;
            }


            HideHud();
            NextPage();
        }
Exemple #2
0
                                                                                                                         

                                                                                                                                                                                                               //make sure at least one outlet is selected
            if (!SelectedCard.Outlets.Any(c => !c.Omitted)) return;


            if (ButtonLocked) return;
            ButtonLocked = true;

            if (Sharing)
                StopSharing();
            else
                StartSharing();
        }
        async public void StartSharing()
        {
            if (DisplayPurposeOnly) return;
                                                                                                                         if (SelectedCard == null)
                                                                                                                         {
                                                                                                                             return;
                                                                                                                         }
                                                                                                                         
            if (!IsSufficentPermissionGranted())
                                                                                                                         {
                                                                                                                             return;
                                                                                                                         }
                                                                                                                         

 SharingButton.SetTitle(Strings.Sharing.authenticating, new UIControlState());

                                                                                                                         
            try
                                                                                                                         {
                                                                                                                             SessionUUID = await RealmServices.BoardcastCard(SelectedCard, SessionUUID); 
 Sharing = !String.IsNullOrEmpty(SessionUUID); 

                                                                                                                         }
                                                                                                                         catch (Exception e)
                                                                                                                         {
                                                                                                                             Sharing = false; 
 AppCenterManager.Report(e);
                                                                                                                         } 

            if (Sharing)
                                                                                                                         {
                                                                                                                             
 Timer.Start();

                                                                                                                             ApplyAnimation(); 

                                                                                                                         }
                                                                                                                         else
                                                                                                                         {
                                                                                                                             SharingButton.SetTitle(Strings.Sharing.could_not_share_card, new UIControlState());
                                                                                                                         } 

 ButtonLocked = false;
                                                                                                                     }
Exemple #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            Profile.Notifications.ObserveDidChange((sender, e) =>
            {
                if (e.NewProfile == null)
                {
                    return;
                }

                Shared.FacebookFirstName = e.NewProfile.FirstName;
                Shared.FacebookLastName  = e.NewProfile.LastName;
                Shared.FacebookUserId    = e.NewProfile.UserID;
                Shared.FacebookFullName  = e.NewProfile.Name;

                Shared.SetUserData(Shared.FacebookUserId, Shared.FacebookFirstName, Shared.FacebookLastName);
            });
            // Set the Read and Publish permissions you want to get
            loginView = new LoginButton(FacebookButtonSuperview.Bounds)
            {
                LoginBehavior   = LoginBehavior.Native,
                ReadPermissions = Shared.FacebookPermissions.ToArray()
            };

            // Handle actions once the user is logged in
            loginView.Completed += async(sender, e) =>
            {
                if (e == null)
                {
                    return;
                }
                if (e.Result != null && e.Result.IsCancelled)
                {
                    return;
                }

                if (e.Error != null)
                {
                    AppCenterManager.Report(e.Error.LocalizedDescription);
                    AppCenterManager.Report("2");
                    ShowAlert("Oops!", e.Error.LocalizedDescription);
                    return;
                }

                if (e.Result.Token == null)
                {
                    return;
                }
                string tokenString = e.Result.Token.TokenString;

                if (String.IsNullOrEmpty(tokenString))
                {
                    ShowAlert("3", "Token Empty");
                    AppCenterManager.Report("3");
                    return;
                }

                ShowHud("Loading");

                bool sucessful = await Shared.CreateUser(tokenString);

                if (!sucessful)
                {
                    HideHud();
                    new LoginManager().LogOut();
                    RealmUserServices.Logout();
                    AppCenterManager.Report("4");
                    return;
                }


                HideHud();
                NextPage();
            };

            // Handle actions once the user is logged out
            loginView.LoggedOut += (s, ev) =>
            {
                if (LogoutCancellationToken == null)
                {
                    LogoutCancellationToken = new CancellationTokenSource();
                    SettingsShared.Logout(LogoutCancellationToken.Token);
                }
            };
            FacebookButtonSuperview.AddSubview(loginView);
        }
Exemple #4
0
        public static void OpenApplicationFromOutlet(Outlet item)
        {
            if (item == null)
            {
                return;
            }
            if (String.IsNullOrEmpty(item.Type))
            {
                return;
            }
            if (item.Type.Equals(Outlet.outlet_type_github, StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            var url = "";



            if (item.Type.Equals(Outlet.outlet_type_email, StringComparison.InvariantCultureIgnoreCase))
            {
                url = "mailto:" + item.Handle;//todo untested
            }
            else if (item.Type.Equals(Outlet.outlet_type_phone, StringComparison.InvariantCultureIgnoreCase))
            {
                url = "sms:" + item.Handle;
            }

            else if (item.Type.Equals(Outlet.outlet_type_website, StringComparison.InvariantCultureIgnoreCase))
            {
                url = item.Handle;
            }

            else if (item.Type.Equals(Outlet.outlet_type_google, StringComparison.InvariantCultureIgnoreCase))
            {
                url = "gplus://plus.google.com/" + item.Handle;
            }

            else if (item.Type.Equals(Outlet.outlet_type_facebook, StringComparison.InvariantCultureIgnoreCase))
            {
                url = "fb://profile/" + item.Handle;
            }

            else if (item.Type.Equals(Outlet.outlet_type_linkedIn, StringComparison.InvariantCultureIgnoreCase))
            {
                url = "https://www.linkedin.com/in/" + item.Handle;
            }

            else if (item.Type.Equals(Outlet.outlet_type_twitter, StringComparison.InvariantCultureIgnoreCase))
            {
                url = "twitter:///user?screen_name=" + item.Handle;
            }

            else if (item.Type.Equals(Outlet.outlet_type_instagram, StringComparison.InvariantCultureIgnoreCase))
            {
                url = "instagram://user?username="******"pinterest://user/" + item.Handle;
            }

            if (UIApplication.SharedApplication.CanOpenUrl(NSUrl.FromString(url)))
            {
                UIApplication.SharedApplication.OpenUrl(NSUrl.FromString(url));
            }
            else
            {
                AppCenterManager.Report("Cannot open url: " + url);
            }
        }