Twitter工具包-授权后重定向在iOS 11 beta版上不起作用

Twitter工具包-授权后重定向在iOS 11 beta版上不起作用,ios,twitter-oauth,Ios,Twitter Oauth,登录成功后总是出现以下错误,未重定向到我的应用。它将继续加载 "Redirecting you back to the application.This may take a few moments." [TwitterKit]在消息“无法使用系统帐户进行身份验证”时遇到错误。错误域=TWTRLogInErrorDomain代码=0“用户拒绝访问系统帐户”。UserInfo={NSLocalizedDescription=用户拒绝访问系统帐户,NSLocalizedRecoverysSugge

登录成功后总是出现以下错误,未重定向到我的应用。它将继续加载

"Redirecting you back to the application.This may take a few moments."
[TwitterKit]在消息“无法使用系统帐户进行身份验证”时遇到错误。错误域=TWTRLogInErrorDomain代码=0“用户拒绝访问系统帐户”。UserInfo={NSLocalizedDescription=用户拒绝访问系统帐户,NSLocalizedRecoverysSuggestion=授予此用户访问系统Twitter帐户的权限。}

ViewController.m

     [[Twitter sharedInstance] startWithConsumerKey:@"1diEEBruGq9X5HKr0FyK3vFGF" consumerSecret:@"YIOD1rPx1tEuYJRLRYpl8ApT8YdWQpilnApJ8R67VaD3KePAU3"];
    [[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
        if (session) {

            TWTRComposer *composer = [[TWTRComposer alloc] init];

            [composer setText:@"just setting up my Twitter Kit"];
            [composer setImage:[UIImage imageNamed:@"twitterkit"]];

            // Called from a UIViewController
            [composer showFromViewController:delegate.window.rootViewController completion:^(TWTRComposerResult result) {
                if (result == TWTRComposerResultCancelled) {
                    NSLog(@"Tweet composition cancelled");
                }
                else {
                    NSLog(@"Sending Tweet!");
                }
            }];

        } else {
            NSLog(@"error: %@", [error localizedDescription]);
        }
    }];
AppDelegate.m

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
        options:(NSDictionary *) options
 {

[[Twitter sharedInstance] application:application openURL:url options:options];
return YES;
 }

从iOS 11开始,苹果已经从iOS中删除了社交账户

你应该在iOS上使用Twitter工具包3

参考推特博客

更新

AppDelegate

import TwitterKit

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Intialize Twitter Kit
        Twitter.sharedInstance().start(withConsumerKey:consumer_key, consumerSecret:consumer_secret)
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        if Twitter.sharedInstance().application(app, open: url, options: options) {
            return true
        }

 return false
}
视图控制器

import TwitterKit

override func viewDidLoad() {
        super.viewDidLoad()

        Twitter.sharedInstance().logIn(with: self, completion: { (session, error) in

            if let sess = session {
                print("signed in as \(sess.userName)");
            } else {
                print("error: \(String(describing: error?.localizedDescription))");
            }
        })

    }
Info.plis

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>twitterkit-{your consumer key}</string>
            </array>
        </dict>
    </array>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>twitter</string>
        <string>twitterauth</string>
    </array>
CbundleUrlTypes
循环流化床锅炉方案
twitterkit-{您的消费者密钥}
LSApplicationQueriesSchemes
啁啾
twitterauth

我知道这很旧,但这可能会对某些人有所帮助,因为在iOS 13中我们有scenedelegate文件,所以我也遇到了同样的问题。我的解决方案是通过下面twitter的委托方法来管理scenedelegate文件中的方法

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    if let openURLContext = URLContexts.first {
        let url = openURLContext.url
        let options: [AnyHashable : Any] = [
            UIApplication.OpenURLOptionsKey.annotation : openURLContext.options.annotation as Any,
            UIApplication.OpenURLOptionsKey.sourceApplication : openURLContext.options.sourceApplication as Any,
            UIApplication.OpenURLOptionsKey.openInPlace : openURLContext.options.openInPlace
        ]
        TWTRTwitter.sharedInstance().application(UIApplication.shared, open: url, options: options)
    }
}
func场景(scene:UIScene,openURLContexts:Set){
如果让openURLContext=URLContexts.first{
让url=openURLContext.url
let选项:[AnyHashable:Any]=[
UIApplication.OpenURLOptionsKey.annotation:openURLContext.options.annotation如有,
UIApplication.OpenURLOptionsKey.sourceApplication:openURLContext.options.sourceApplication(如有),
UIApplication.OpenUrlOptionKey.openInPlace:openURLContext.options.openInPlace
]
TWTRTwitter.sharedInstance().application(UIApplication.shared,打开:url,选项:选项)
}
}

yeah提到链接没有重定向。我尝试了使用ViewController的Twitter登录方法,登录成功并成功重定向。在iPhone 7 Plus/iOS 11模拟器上测试。-(void)logInWithViewController:(可为空的UIViewController*)viewController完成:(TWTRLogInCompletion)完成;我在模拟器里试过。所以twitter应用程序没有安装。你能给我分享一下你所做的示例项目链接吗?