“[应用程序]"想要访问 Twitter 帐户警报未在 iOS 6 中显示 [英] "[App]" Would Like Access to Twitter Accounts alert is not shown in iOS 6

查看:33
本文介绍了“[应用程序]"想要访问 Twitter 帐户警报未在 iOS 6 中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 TWTweetComposeViewController 访问用户的 Twitter 帐户,他/她已在设置 -> Twitter 中添加了该帐户.当应用程序尝试访问 Twitter 帐户时,它应该显示一条警告,其中包含类似于以下内容的消息:

I am using TWTweetComposeViewController to access a user's twitter account(s), which he/she has added in Settings -> Twitter. When the app attempts to access a twitter account, it should presente an alert with a message similar to this:

"[AppName] Would Like Access to Twitter Accounts"

您可以点击不允许"或确定".我想这是操作系统本身显示的警报,因为点击确定"实际上可以访问 Twitter.

To which you can tap either "Don't allow" or "OK". I suppose this is an alert displayed by the OS itself, since tapping "OK" actually enables access to twitter.

在 iOS 5.x 设备上测试时会显示上述警报,但在 iOS 6 设备上测试时并非如此.我希望在发送以下消息时显示警报,但我尚未在设置中获得对 Twitter 的应用访问权限:

The above alert is displayed when I test it on an iOS 5.x device, but that is not the case when I test it on an iOS 6 device. I expect the alert to be presented when I send the following message, and I have not yet gained my app access to Twitter in settings:

[TWTweetComposeViewController canSendTweet]

如上所述,它不会发生.有谁知道这是否是 iOS 6 中的已知错误?我一直无法在 SO 上找到任何帖子,而且由于我找不到其他原因导致不同的行为,我认为这是一个错误.

As described, it does not happen. Does anyone know if this is a known bug in iOS 6? I have been unable to find any posts on SO and since I can find no other reason to the different behavior I believe it's a bug.

仅供参考,我正在以下两个设备上进行测试:

FYI, I am testing this on the following two devices:

  • 运行 iOS 5.1 的 iPhone 4
  • 装有 iOS 6.0 的 iPhone 4

更新

我使用 DETweetComposeViewController,它通过以下方式检查 iOS 5:

I use DETweetComposeViewController, which checks for iOS 5 in the following way:

+ (BOOL)de_isIOS5
{
    return (NSClassFromString(@"NSJSONSerialization") != nil);
}

但由于 NSJSONSerialization 类也在 iOS 6 中表示,这不应该是原因.

But since the NSJSONSerialization class is represented in iOS 6 as well, this shouldn't be the reason.

推荐答案

我一整天都在解决 iOS 5.1 和 iOS 6.0 上的相同问题.

I have been sorting this same thing out on iOS 5.1 vs iOS 6.0 all day.

只要在设置"中配置了 Twitter 帐户,我的应用就不再在 iOS 6.0 中要求 Twitter 访问权限,只是为了显示一个 TWTweetComposeViewController.我已经通过在 Settings > 中手动关闭我的应用程序的 Twitter 访问来验证这一点.隐私 >推特.关闭访问权限后,我无法使用 TWRequest 创建友谊,但仍然可以弹出 TWTweetComposeViewController.我每次在 iOS 5.1 中都会收到提示,直到我授予它访问权限.

As long as there is a Twitter account configured in Settings, my app no longer asks for Twitter access permission in iOS 6.0 just to display a TWTweetComposeViewController. I have verified this by manually turning off Twitter access for my app in Settings > Privacy > Twitter. With access off, I am properly denied the ability to create a friendship using TWRequest, but can still pop up the TWTweetComposeViewController. I get a prompt in iOS 5.1 every time until I grant it access.

这对我来说很有意义.TWTweetComposeViewController 所做的就是启动推文,所以如果用户已经配置了一个设备范围的 Twitter 帐户,那应该有足够的权限从任何地方发送推文.必须为每个应用授予访问权限确实是一个不必要的额外步骤.

This makes sense to me. All TWTweetComposeViewController does is initiate the tweet, so if the user already has a device-wide Twitter account configured, that should be permission enough to send tweets from anywhere. It really is an unnecessary extra step to have to grant access on a per-app basis.

如果尚未配置 Twitter 帐户,TWTweetComposeViewController 将提示此消息:

If no Twitter accounts are configured yet, TWTweetComposeViewController will prompt with this message tho:

No Twitter Accounts
There are no Twitter accounts
configured. You can add or create
a Twitter account in Settings.

带有方便的设置"和取消"按钮.

with handy buttons "Settings" and "Cancel".

对此的旁注:iOS 6 也仅在应用首次请求访问时提示 [AppName] 想要访问 Twitter 帐户" 消息.

A sidenote to this: iOS 6 also only prompts with the "[AppName] Would Like Access to Twitter Accounts" message the first time an app requests access.

之后你必须重置设置>一般>重置 >重置位置 &Privacy 以获取询问提示.即使您删除并重新安装/重建应用程序,已经询问一次"设置仍然存在.您可以在 Settings > 中手动启用访问.隐私,但重置是获得重新显示提示的唯一方法(如果这对您的测试很重要).

After that you must reset Settings > General > Reset > Reset Location & Privacy to get the ask prompt back. Even if you delete and reinstall/rebuild an app, the "already asked once" setting persists. You can manually enable access in Settings > Privacy, but that reset is the only way to get the prompt to redisplay (if that is important to your testing).

我发现了另外两件事.在[ACAccountStore requestAccessToAccountsWithType:options:completion:]的完成块中,如果granted == NO:

Two extra things I found out. In the completion block of [ACAccountStore requestAccessToAccountsWithType:options:completion:], if granted == NO:

  1. 如果 [error code] == 6,则您的用户没有定义帐户.
  2. 如果 error == nil,则您的用户拒绝访问您的应用,无论是现在还是之前.如果之前发生过,请求会被默默忽略,屏幕上不会显示警告,也不会点击不允许"按钮.
  1. If [error code] == 6, your user has no accounts defined.
  2. If error == nil, your user denied access for your app, either just now or previously. If it happened previously, the request is silently ignored with no alert displayed on the screen, no "Don't Allow" button to tap.

这篇关于“[应用程序]"想要访问 Twitter 帐户警报未在 iOS 6 中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆