void InitUI()
        {
            CreateLoginForm();

            //Submit Button
            SubmitButton = CreateButton(ResourceManager.GetString("login"),
                                        AppStyles.Red,
                                        loginForm.Frame.Bottom + 20);

            WPBButton CancelButton = CreateButton(ResourceManager.GetString("cancel"), AppStyles.DarkGray, SubmitButton.Frame.Bottom + 20);

            CancelButton.TouchUpInside += (object sender, EventArgs e) => {
                DismissViewController(true, null);
                LoginCancelled.Invoke();
            };

            //Register Button
            RegisterButton = new UIButton();
            var buttonY = WhitePaperBible.iOS.UI.Environment.DeviceScreenHeight - 60;

            RegisterButton.Frame = new RectangleF(10, buttonY, 280, 43);
            RegisterButton.CenterHorizontally();
            RegisterButton.SetTitle(ResourceManager.GetString("register"), UIControlState.Normal);
            RegisterButton.BackgroundColor = UIColor.Clear;
            RegisterButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            RegisterButton.Font = UIFont.FromName("Helvetica", 12);
            RegisterButton.SetTitleColor(AppStyles.DarkGray, UIControlState.Highlighted);
            View.AddSubview(RegisterButton);
        }
		/// <summary>
		/// See docs in <see cref="SoomlaProfile.Login"/>
		/// </summary>
		/// <param name="success">Callback function that is called if login was successful.</param>
		/// <param name="fail">Callback function that is called if login failed.</param>
		/// <param name="cancel">Callback function that is called if login was cancelled.</param>
		public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) {
			FB.LogInWithReadPermissions(this.loginPermissions, (ILoginResult result) => {
				if (result.Error != null) {
					SoomlaUtils.LogDebug (TAG, "LoginCallback[result.Error]: " + result.Error);
					fail(result.Error);
				}
				else if (!FB.IsLoggedIn) {
					SoomlaUtils.LogDebug (TAG, "LoginCallback[cancelled]");
					cancel();
				}
				else {
					success();
				}
			});
		}
Example #3
0
        /// <summary>
        /// See docs in <see cref="SoomlaProfile.Login"/>
        /// </summary>
        /// <param name="success">Callback function that is called if login was successful.</param>
        /// <param name="fail">Callback function that is called if login failed.</param>
        /// <param name="cancel">Callback function that is called if login was cancelled.</param>
        public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel)
        {
            FB.Login(this.permissionsStr, (FBResult result) => {
                if (result.Error != null)
                {
                    SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error);
                    fail(result.Error);
                }
                else if (!FB.IsLoggedIn)
                {
                    SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]");
                    cancel();
                }
                else
                {
                    checkPermissions("publish_actions", "user_birthday");

                    FB.API("/me/permissions", Facebook.HttpMethod.GET, delegate(FBResult response) {
                        // inspect the response and adapt your UI as appropriate
                        // check response.Text and response.Error
                        SoomlaUtils.LogWarning(TAG, "me/permissions " + response.Text);
                    });

                    FB.API("/me?fields=id,name,email,first_name,last_name,picture",
                           Facebook.HttpMethod.GET, (FBResult result2) => {
                        if (result2.Error != null)
                        {
                            SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Error]: " + result2.Error);

                            fail(result2.Error);
                        }
                        else
                        {
                            SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: " + result2.Text);
                            SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: " + result2.Texture);
                            string fbUserJson       = result2.Text;
                            UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson);

                            SoomlaProfile.StoreUserProfile(userProfile, true);

                            success(userProfile);
                        }
                    });
                }
            });
        }
Example #4
0
 /// <summary>
 /// See docs in <see cref="SoomlaProfile.Login"/>
 /// </summary>
 /// <param name="success">Callback function that is called if login was successful.</param>
 /// <param name="fail">Callback function that is called if login failed.</param>
 /// <param name="cancel">Callback function that is called if login was cancelled.</param>
 public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel)
 {
     FB.Login(this.loginPermissionsStr, (FBResult result) => {
         if (result.Error != null)
         {
             SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error);
             fail(result.Error);
         }
         else if (!FB.IsLoggedIn)
         {
             SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]");
             cancel();
         }
         else
         {
             success();
         }
     });
 }
        /// <summary>
        /// See docs in <see cref="SoomlaProfile.Login"/>
        /// </summary>
        /// <param name="success">Callback function that is called if login was successful.</param>
        /// <param name="fail">Callback function that is called if login failed.</param>
        /// <param name="cancel">Callback function that is called if login was cancelled.</param>
        public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel)
        {
            FB.Login(this.loginPermissionsStr, (FBResult result) => {
                if (result.Error != null)
                {
                    SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error);
                    fail(result.Error);
                }
                else if (!FB.IsLoggedIn)
                {
                    SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]");
                    cancel();
                }
                else
                {
                    this.fetchPermissions(() => {
                        FB.API("/me?fields=id,name,email,first_name,last_name,picture",
                               Facebook.HttpMethod.GET, (FBResult meResult) => {
                            if (meResult.Error != null)
                            {
                                SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Error]: " + meResult.Error);
                                fail(meResult.Error);
                            }
                            else
                            {
                                SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: " + meResult.Text);
                                SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: " + meResult.Texture);
                                string fbUserJson       = meResult.Text;
                                UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson);
                                userProfile.AccessToken = FB.AccessToken;

                                SoomlaProfile.StoreUserProfile(userProfile, true);

                                success(userProfile);
                            }
                        });
                    },
                                          (string errorMessage) => {
                        fail(errorMessage);
                    });
                }
            });
        }
		/// <summary>
		/// See docs in <see cref="SoomlaProfile.Login"/>
		/// </summary>
		/// <param name="success">Callback function that is called if login was successful.</param>
		/// <param name="fail">Callback function that is called if login failed.</param>
		/// <param name="cancel">Callback function that is called if login was cancelled.</param>
		public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) {
			FB.Login("email,publish_actions", (FBResult result) => {
				if (result.Error != null) {
					SoomlaUtils.LogDebug (TAG, "LoginCallback[result.Error]: " + result.Error);
					fail(result.Error);
				}
				else if (!FB.IsLoggedIn) {
					SoomlaUtils.LogDebug (TAG, "LoginCallback[cancelled]");
					cancel();
				}
				else {
					FB.API("/me/permissions", Facebook.HttpMethod.GET, delegate (FBResult response) {
						// inspect the response and adapt your UI as appropriate
						// check response.Text and response.Error
						SoomlaUtils.LogWarning(TAG, "me/permissions " + response.Text);
					});
					
					FB.API("/me?fields=id,name,email,first_name,last_name,picture",
					       Facebook.HttpMethod.GET, (FBResult result2) => {
						if (result2.Error != null) {
							SoomlaUtils.LogDebug (TAG, "ProfileCallback[result.Error]: " + result2.Error);
							
							fail(result2.Error);
						}
						else {
							SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: "+result2.Text);
							SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: "+result2.Texture);
							string fbUserJson = result2.Text;
							UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson);
							
							SoomlaProfile.StoreUserProfile (userProfile, true);
							
							success(userProfile);
						}
					});
				}
			});
		}
Example #7
0
 /// <summary>
 /// See docs in <see cref="SoomlaProfile.Login"/>
 /// </summary>
 public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel)
 {
 }
 /// <summary>
 /// See docs in <see cref="SoomlaProfile.Login"/>
 /// </summary>
 public abstract void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel);
		/// <summary>
		/// See docs in <see cref="SoomlaProfile.Login"/>
		/// </summary>
		public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) {}
Example #10
0
 /// <summary>
 /// See docs in <see cref="SoomlaProfile.Login"/>
 /// </summary>
 public abstract void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel);
        /// <summary>
        /// See docs in <see cref="SoomlaProfile.Login"/>
        /// </summary>
        /// <param name="success">Callback function that is called if login was successful.</param>
        /// <param name="fail">Callback function that is called if login failed.</param>
        /// <param name="cancel">Callback function that is called if login was cancelled.</param>
        public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel)
        {
            FB.Login(this.loginPermissionsStr, (FBResult result) => {
                if (result.Error != null) {
                    SoomlaUtils.LogDebug (TAG, "LoginCallback[result.Error]: " + result.Error);
                    fail(result.Error);
                }
                else if (!FB.IsLoggedIn) {
                    SoomlaUtils.LogDebug (TAG, "LoginCallback[cancelled]");
                    cancel();
                }
                else {
                    this.fetchPermissions(() => {
                        FB.API("/me?fields=id,name,email,first_name,last_name,picture",
                               Facebook.HttpMethod.GET, (FBResult meResult) => {
                            if (meResult.Error != null) {
                                SoomlaUtils.LogDebug (TAG, "ProfileCallback[result.Error]: " + meResult.Error);
                                fail(meResult.Error);
                            }
                            else {
                                SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: "+meResult.Text);
                                SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: "+meResult.Texture);
                                string fbUserJson = meResult.Text;
                                UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson);

                                SoomlaProfile.StoreUserProfile (userProfile, true);

                                success(userProfile);
                            }
                        });
                    },
                    (string errorMessage) => {
                        fail(errorMessage);
                    });
                }
            });
        }