2013-03-03 46 views
0

我目前正在開發一個應用程序,它使用ACAccountStore訪問Twitter帳戶來獲取推文。一切正常,但我不知道我可以顯示或做什麼,如果用戶不授予對帳戶的承諾。使用「ACAccountStore」進行登錄時,我能做些什麼沒有被授予?

我的第一個想法是顯示登錄視圖或切換到iOS設置,但這不適用於iOS 5.1或更高版本?有人有另一種更好的解決方案嗎? :)

問候

編輯:我不是在尋找整個AUTH碼。僅針對這種情況,用戶不授予對帳戶的訪問權限。

回答

-1
store = [[ACAccountStore alloc] init]; 

ACAccountType *twitterType = [store accountTypeWithAccountTypeIdentifier: ACAccountTypeIdentifierTwitter]; 

// Request Access for Twitter Accounts 
[store requestAccessToAccountsWithType:twitterType 
    withCompletionHandler:^(BOOL granted, NSError *error){ 
    if(granted){ 
    // Handle Granted condition 
} else{ 
    // We didn’t get access, output why not 
    NSLog(@」%@」,[error localizedDescription]); 
    } 
}]; 

上面是請求的示例授權。

你可以在其他部分錯誤說明,這是一個好主意 顯示在警報視圖或其他 選項錯誤說明用戶是要求用戶允許通過設置應用程序訪問 應用程序。

您無法以編程方式切換到設置應用程序。

+0

喜不,謝謝對的信息,我已經有過。問題是,如果我無法訪問,我不知道要顯示什麼。你顯示一個簡單的警報..? – 2013-03-03 09:05:57

+0

是的..簡單的警報是顯示。 – Shubhank 2013-03-03 09:10:36

+0

這個答案使用了一個DEPRECATED函數。見http://stackoverflow.com/questions/13797409/ios-returns-that-there-are-no-twitter-accounts-on-phone-eventhough-there-is-one/13797575#13797575 – CReaTuS 2013-04-15 23:05:25

1

當用戶不授予您的訪問,只是顯示一個錯誤說「的應用程序被拒絕訪問Twitter的」,然後忽略它 - >假設像你沒有嘰嘰喳喳

相關問題