簡體   English   中英

Parse.com Facebook登錄屏幕無法在設備上使用,但可以在模擬器上使用

[英]Parse.com Facebook Sign In Screen not working on device, but works on simulator

我有一個Parse.com登錄名,上面有我們的設計。 以及用於登錄和注冊的Facebook按鈕。

在模擬器上可以很好地進行注冊和登錄,但是我只是將其放在iPhone 5s上,當單擊該按鈕時,它詢問您希望該應用訪問您的信息的天氣,然后單擊“是”后,它就會返回到登錄屏幕。 我查看了NSlog,其說法未能登錄。

但正如我在模擬器上看到的那樣,它似乎工作正常。

.m文件:

- (void)viewDidAppear:(BOOL)animated
{ 
    [PFFacebookUtils initializeFacebook]; 
    [PFTwitterUtils initializeWithConsumerKey:@"HIDDEN" 
                               consumerSecret:@"HIDDEN"]; 

    // Check if user is logged in 
    if (![PFUser currentUser]) { 
        // Instantiate our custom log in view controller 
        MyLogInViewController *logInViewController = [[MyLogInViewController alloc] init]; 
        [logInViewController setDelegate:self]; 
        [logInViewController setFacebookPermissions:[NSArray arrayWithObjects:@"friends_about_me", nil]]; 
        [logInViewController setFields:PFLogInFieldsUsernameAndPassword 

         //| PFLogInFieldsTwitter 
         | PFLogInFieldsFacebook 
         | PFLogInFieldsSignUpButton 
         | PFLogInFieldsDismissButton]; 

        // Instantiate our custom sign up view controller 
        MySignUpViewController *signUpViewController = [[MySignUpViewController alloc] init]; 
        [signUpViewController setDelegate:self]; 
        [signUpViewController setFields:PFSignUpFieldsDefault | PFSignUpFieldsAdditional]; 

        // Link the sign up view controller 
        [logInViewController setSignUpController:signUpViewController]; 

        // Present log in view controller 
        [self presentViewController:logInViewController animated:YES completion:NULL]; 

    } 

    [super viewDidAppear:animated]; 
    self.canDisplayBannerAds = YES; 
} 

// Sent to the delegate when a PFUser is logged in. 
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user { 
    [self dismissViewControllerAnimated:YES completion:NULL]; 
} 

// Sent to the delegate to determine whether the log in request should be submitted to the server. 
- (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername:(NSString *)username password:(NSString *)password { 

    // Check if both fields are completed 
    if (username && password && username.length != 0 && password.length != 0) { 
        return YES; // Begin login process 

    } 

    [[[UIAlertView alloc] initWithTitle:@"Missing Information" 
                                message:@"Make sure you fill out all of the information!" 
                               delegate:nil 
                      cancelButtonTitle:@"ok" 
                      otherButtonTitles:nil] show]; 
    return NO; // Interrupt login process 
} 

// Sent to the delegate when the log in attempt fails. 
- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(NSError *)error { 
    NSLog(@"Failed to log in..."); 
} 

// Sent to the delegate when the log in screen is dismissed. 
- (void)logInViewControllerDidCancelLogIn:(PFLogInViewController *)logInController { 
    [self dismissViewControllerAnimated:NO completion:nil]; 
    //[self.navigationController popViewControllerAnimated:YES]; 

    [[[UIAlertView alloc] initWithTitle:@"Log In Required" 
                                message:@"Please Make Sure You Log In, Or Sign Up As A New User!" 
                               delegate:nil 
                      cancelButtonTitle:@"ok" 
                      otherButtonTitles:nil] show]; 
} 

// Sent to the delegate when a PFUser is signed up. 
- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user { 
    [self dismissViewControllerAnimated:YES completion:nil]; // Dismiss the PFSignUpViewController 

} 

// Sent to the delegate when the sign up attempt fails. 
- (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError:(NSError *)error { 
    NSLog(@"Failed to sign up..."); 
} 

// Sent to the delegate when the sign up screen is dismissed. 
- (void)signUpViewControllerDidCancelSignUp:(PFSignUpViewController *)signUpController { 
    NSLog(@"User dismissed the signUpViewController"); 
}

我只有一台iPhone,但它具有iOS 8,因此無法在該iPhone上嘗試。

2014-07-23 14:53:30.528 WeddingsAndMore[985:60b] {
    NSLocalizedFailureReason = "com.facebook.sdk:SystemLoginCancelled";
    "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}";
    "com.facebook.sdk:ErrorLoginFailedReason" = "com.facebook.sdk:SystemLoginCancelled";
    "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)>";
}

我已經刪除了friends_about_me現在我得到以下內容

NSLocalizedFailureReason = "com.facebook.sdk:SystemLoginError";
    "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>}";
    "com.facebook.sdk:ErrorLoginFailedReason" = "com.facebook.sdk:SystemLoginError";
    "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)>";
}

似乎是我擺脫了一個錯誤,我得到了另一個。

在plist中的應用名稱中有空格,我擺脫了空格,現在出現以下錯誤

 NSLocalizedFailureReason = "com.facebook.sdk:SystemLoginCancelled";
    "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}";
    "com.facebook.sdk:ErrorLoginFailedReason" = "com.facebook.sdk:SystemLoginCancelled";
    "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)>";

您正在請求一個名為“ friends_about_me”的權限。 根據 ,Facebook並不喜歡這樣。 刪除該權限,您應該可以。

多一點背景-它可以在您的模擬器上使用,因為僅當您在設備設置上登錄Facebook時,“錯誤”才會顯示出來。 因此,要解決此問題,請從“設置”應用中刪除Facebook登錄名,或者刪除“ friends_about_me”許可請求。 此外,應按此處指出的那樣分別請求讀和寫權限(即登錄時的讀權限,需要時的寫權限)。

是Facebook登錄的更新權限列表。

對於您遇到的第二個錯誤-如果應用程序處於沙箱模式,您是否確保將嘗試登錄該應用程序的人添加為Facebook應用程序中的測試人員/開發人員/管理員?

  1. 轉到developers.facebook.com
  2. 您的應用程式
  3. 角色
  4. 將Facebook ID /開發人員/管理員的名稱添加到應用中。

另外,請確保您的FB應用ID在您的iOS應用中正確。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM