Advertisement
Guest User

Untitled

a guest
Nov 30th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.29 KB | None | 0 0
  1. - (void)viewDidAppear:(BOOL)animated
  2. {
  3. [PFFacebookUtils initializeFacebook];
  4. [PFTwitterUtils initializeWithConsumerKey:@"HIDDEN"
  5. consumerSecret:@"HIDDEN"];
  6.  
  7. // Check if user is logged in
  8. if (![PFUser currentUser]) {
  9. // Instantiate our custom log in view controller
  10. MyLogInViewController *logInViewController = [[MyLogInViewController alloc] init];
  11. [logInViewController setDelegate:self];
  12. [logInViewController setFacebookPermissions:[NSArray arrayWithObjects:@"friends_about_me", nil]];
  13. [logInViewController setFields:PFLogInFieldsUsernameAndPassword
  14.  
  15. //| PFLogInFieldsTwitter
  16. | PFLogInFieldsFacebook
  17. | PFLogInFieldsSignUpButton
  18. | PFLogInFieldsDismissButton];
  19.  
  20. // Instantiate our custom sign up view controller
  21. MySignUpViewController *signUpViewController = [[MySignUpViewController alloc] init];
  22. [signUpViewController setDelegate:self];
  23. [signUpViewController setFields:PFSignUpFieldsDefault | PFSignUpFieldsAdditional];
  24.  
  25. // Link the sign up view controller
  26. [logInViewController setSignUpController:signUpViewController];
  27.  
  28. // Present log in view controller
  29. [self presentViewController:logInViewController animated:YES completion:NULL];
  30.  
  31. }
  32.  
  33. [super viewDidAppear:animated];
  34. self.canDisplayBannerAds = YES;
  35. }
  36.  
  37. // Sent to the delegate when a PFUser is logged in.
  38. - (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user {
  39. [self dismissViewControllerAnimated:YES completion:NULL];
  40. }
  41.  
  42. // Sent to the delegate to determine whether the log in request should be submitted to the server.
  43. - (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername:(NSString *)username password:(NSString *)password {
  44.  
  45. // Check if both fields are completed
  46. if (username && password && username.length != 0 && password.length != 0) {
  47. return YES; // Begin login process
  48.  
  49. }
  50.  
  51. [[[UIAlertView alloc] initWithTitle:@"Missing Information"
  52. message:@"Make sure you fill out all of the information!"
  53. delegate:nil
  54. cancelButtonTitle:@"ok"
  55. otherButtonTitles:nil] show];
  56. return NO; // Interrupt login process
  57. }
  58.  
  59. // Sent to the delegate when the log in attempt fails.
  60. - (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(NSError *)error {
  61. NSLog(@"Failed to log in...");
  62. }
  63.  
  64. // Sent to the delegate when the log in screen is dismissed.
  65. - (void)logInViewControllerDidCancelLogIn:(PFLogInViewController *)logInController {
  66. [self dismissViewControllerAnimated:NO completion:nil];
  67. //[self.navigationController popViewControllerAnimated:YES];
  68.  
  69. [[[UIAlertView alloc] initWithTitle:@"Log In Required"
  70. message:@"Please Make Sure You Log In, Or Sign Up As A New User!"
  71. delegate:nil
  72. cancelButtonTitle:@"ok"
  73. otherButtonTitles:nil] show];
  74. }
  75.  
  76. // Sent to the delegate when a PFUser is signed up.
  77. - (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user {
  78. [self dismissViewControllerAnimated:YES completion:nil]; // Dismiss the PFSignUpViewController
  79.  
  80. }
  81.  
  82. // Sent to the delegate when the sign up attempt fails.
  83. - (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError:(NSError *)error {
  84. NSLog(@"Failed to sign up...");
  85. }
  86.  
  87. // Sent to the delegate when the sign up screen is dismissed.
  88. - (void)signUpViewControllerDidCancelSignUp:(PFSignUpViewController *)signUpController {
  89. NSLog(@"User dismissed the signUpViewController");
  90. }
  91.  
  92. 2014-07-23 14:53:30.528 WeddingsAndMore[985:60b] {
  93. NSLocalizedFailureReason = "com.facebook.sdk:SystemLoginCancelled";
  94. "com.facebook.sdk:ErrorInnerErrorKey" = "Error Domain=com.apple.accounts Code=7 "The Facebook server could not fulfill this access request: Invalid permission: friends_about_me" UserInfo=0x17026b700 {NSLocalizedDescription=The Facebook server could not fulfill this access request: Invalid permission: friends_about_me}";
  95. "com.facebook.sdk:ErrorLoginFailedReason" = "com.facebook.sdk:SystemLoginCancelled";
  96. "com.facebook.sdk:ErrorSessionKey" = "<FBSession: 0x17813cca0, state: FBSessionStateClosedLoginFailed, loginHandler: 0x0, appID: 52610783371, urlSchemeSuffix: , tokenCachingStrategy:<PFFacebookTokenCachingStrategy: 0x1780319e0>, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>";
  97. }
  98.  
  99. NSLocalizedFailureReason = "com.facebook.sdk:SystemLoginError";
  100. "com.facebook.sdk:ErrorInnerErrorKey" = "Error Domain=com.apple.accounts Code=7 "The Facebook server could not fulfill this access request: Invalid application <redacted>" UserInfo=0x170273040 {NSLocalizedDescription=The Facebook server could not fulfill this access request: Invalid application <redacted>}";
  101. "com.facebook.sdk:ErrorLoginFailedReason" = "com.facebook.sdk:SystemLoginError";
  102. "com.facebook.sdk:ErrorSessionKey" = "<FBSession: 0x178125c80, state: FBSessionStateClosedLoginFailed, loginHandler: 0x0, appID: <redacted>, urlSchemeSuffix: , tokenCachingStrategy:<PFFacebookTokenCachingStrategy: 0x17003de60>, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>";
  103. }
  104.  
  105. NSLocalizedFailureReason = "com.facebook.sdk:SystemLoginCancelled";
  106. "com.facebook.sdk:ErrorInnerErrorKey" = "Error Domain=com.apple.accounts Code=7 "The Facebook server could not fulfill this access request: An unknown error occurred" UserInfo=0x17027c8c0 {NSLocalizedDescription=The Facebook server could not fulfill this access request: An unknown error occurred}";
  107. "com.facebook.sdk:ErrorLoginFailedReason" = "com.facebook.sdk:SystemLoginCancelled";
  108. "com.facebook.sdk:ErrorSessionKey" = "<FBSession: 0x1781366c0, state: FBSessionStateClosedLoginFailed, loginHandler: 0x0, appID: 6565656656565, urlSchemeSuffix: , tokenCachingStrategy:<PFFacebookTokenCachingStrategy: 0x17003a700>, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement