我的应用程序需要 facebook 和 twitter 的许可才能发布和阅读。它目前的工作方式是每次重新启动应用程序时,它都会再次请求许可。
这个过程需要很长时间。大多数其他应用程序都不是这样工作的。他们是怎么做到的?我以为我已经有了可以使用的令牌,并且在发生这种情况时我可以保存。
我认为这个过程很快。
例如看一下这段代码
[self vSuspendAndHaltThisThreadTillUnsuspendedWhileDoing:^{
[BGHPTools vDoForeGroundAndWait:^{
PO (self.ACAccountType);
PO([self dicReadOptions]);
[self.ACAstore requestAccessToAccountsWithType:self.ACAccountType options:[self dicReadOptions] completion:^(BOOL granted, NSError *error) {
self.bPermissionToAccessStoreGranted=granted;
[self vContinue];
}];
}];
}];
大多数人都熟悉这部分代码
[self.ACAstore requestAccessToAccountsWithType:self.ACAccountType options:[self dicReadOptions] completion:^(BOOL granted, NSError *error) {
self.bPermissionToAccessStoreGranted=granted;
[self vContinue];
}];
而已。我要求帐户框架授予我阅读权限。但我不想每次应用程序重新启动时都花很长时间请求该权限。
但这需要时间。我只想使用我的令牌并使其快速。
但是,如果我已经获得许可怎么办?Account 框架不能解决这个问题并更快地授予我权限吗?
很可能我需要使用
- (void)renewCredentialsForAccount:(ACAccount *)account completion:(ACAccountStoreCredentialRenewalHandler)completionHandler
renewCredentialsForAccount 的问题是有些人可能有多个 Facebook 帐户。知道选择了哪个账户或获取 ACAccount 对象的方法是通过
requestAccessToAccountsWithType:self.ACAccountType options:[self dicReadOptions] completion:^(BOOL granted, NSError *error) {
self.bPermissionToAccessStoreGranted=granted;
[self vContinue];
}];
这是我想要避免的。