這是需要驗證的測試用例之一。如何檢測是否有人已從Facebook刪除應用程序,並重新訪問該應用程序?
- 有人通過應用程序設置從Facebook上移除您的應用程序並重新訪問您的應用程序。您的應用程序應檢測到此信息並提示 重新登錄。轉到您的應用程序並點擊「使用Facebook登錄」 按鈕點擊確定以接受讀取權限(再次確認以接受 寫入權限(如果適用)轉到應用程序設置在Facebook和 您的應用重複步驟1-2,並確認Facebook的登錄工作
我發現沒有辦法做到這一點。當我刪除應用程序在Facebook中,我的iOS依舊相信會話是有效的。在這裏Stackoverflow似乎有一個discussion這一點。但提供的解決方案似乎並沒有工作。
這是我到目前爲止登錄的內容。但是我無法檢測到用戶何時在Facebook上刪除了應用程序。有什麼建議嗎?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
NSLog(@"Found a cached session");
// If there's one, just open the session silently, without showing the user the login UI
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile"]
allowLoginUI:NO
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
// Handler for session state changes
// This method will be called EACH time the session state changes,
// also for intermediate states and NOT just when the session open
[self sessionStateChanged:session state:state error:error];
}];
// If there's no cached session, we will show a login button
} else {
UIButton *loginButton = [self.customLoginViewController loginButton];
[loginButton setTitle:@"Log in with Facebook" forState:UIControlStateNormal];
}
}
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
{
// If the session was opened successfully
if (!error && state == FBSessionStateOpen){
NSLog(@"Session opened");
// Show the user the logged-in UI
[self userLoggedIn];
return;
}
if (state == FBSessionStateClosed || state == FBSessionStateClosedLoginFailed){
// If the session is closed
NSLog(@"Session closed");
// Show the user the logged-out UI
[self userLoggedOut];
}
}
這個 – hariszaman 2017-10-20 22:04:02