簡體   English   中英

Parse.com自動用戶

[英]Parse.com Automatic user

連接到互聯網后,我可以自動讓用戶登錄。 登錄后,我可以關閉wifi並繼續使用該應用程序。 我遇到的問題是當我關閉應用程序(雙擊主頁按鈕並在應用程序上向上滑動)並嘗試再次打開備份時,出現以下錯誤消息:

"The Internet connection appears to be offline."} (Code: 100, Version: 1.4.0)
2014-09-20 22:20:02.376 LeadOff Dev[4030:5a27] Network connection failed. Making attempt 3       after sleeping for 2.470375 seconds

這是我從根視圖控制器進行的自動登錄過程:

PFUser *currentUser = [PFUser currentUser];

if ([PFUser currentUser]) {
    NSLog(@"Current user: %@", currentUser.username);

}
else {
    LoginViewController* nextViewController = [[LoginViewController alloc] init];
    nextViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:nextViewController animated:YES completion:nil];
    NSLog(@"Current User logged out");
}

初始化應用程序時,Parse必須打電話回家才能啟動。 如果應用程序在后台運行,則該初始化已經發生,您無需再次運行它-這就是為什么您可以從后台重新加載並在啟動后無需連接即可運行的原因。

但是,在第一次加載時,您必須調用[Parse setApplicationId:appID clientKey:clientKey] ,該代碼通常在AppDelegate.m文件的didFinishLaunchingWithOptions中運行。 沒有此呼叫,您將獲得:

'NSInternalInconsistencyException',原因:“您必須在Parse上調用setApplicationId:clientKey:才能配置Parse。”

底線:使用Parse啟動應用程序時,必須具有連接性。

暫無
暫無

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

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