用戶後已經允許我的應用程序來訪問他們的Twitter帳戶,他們仍然可以進入設置應用程序,並通過敲擊開關撤銷訪問:如何檢測我的應用無法訪問iOS 6中用戶的Twitter帳戶?
我的應用程序需要以顯示正確的註銷圖形當這個情況發生時。我可以在iOS 中沒有任何問題,因爲[TWTweetComposeViewController canSendTweet]
返回NO
當我的應用程序的訪問已被撤銷。然而,即使在訪問已被撤銷後,在iOS ,canSendTweet
仍繼續返回YES
。所以在iOS 6中我的用戶界面處於錯誤的狀態。有沒有其他方法可以在iOS 6中正確檢測到這一點?
- (id) init
{
if (self = [super init]) {
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(accountStatusDidChange:)
name:ACAccountStoreDidChangeNotification object:nil];
}
return self;
}
- (void) accountStatusDidChange:(NSNotification *)notification
{
if ([TWTweetComposeViewController canSendTweet]) {
NSLog(@"app can still access Twitter account in iOS 5");
NSLog(@"always hits this path in iOS 6");
} else {
NSLog(@"app permission removed by user in iOS 5");
}
}
順便說一句,關於canSendTweet的文檔是錯誤的。關閉後,Twitter將無法再使用。
返回您是否可以發送Twitter請求。
是,如果Twitter 可以訪問並且至少建立了一個帳戶; 否則否。可用性
Available in iOS 5.0 and later.
宣佈TWTweetComposeViewController.h
我剛試過。它撤銷我的應用程序的訪問權後也返回true。 – Pwner 2013-04-08 04:56:54
經過進一步調查,當用戶從設置應用程序中刪除了所有他們的Twitter帳戶時,「isAvailableForServiceType」僅返回false。所以這似乎與撤銷對單個應用程序的訪問無關。 – Pwner 2013-04-08 05:16:34
對我而言根本不起作用 - 在iPad 6.1模擬器中始終返回true。 – 2013-06-07 04:01:14