推特套件 - 授权后重定向不适用于iOS 11测试版

推特套件 - 授权后重定向不适用于iOS 11测试版

问题描述:

登录成功后总是得到低于错误的重定向未被重定向到我的app.it将继续加载。推特套件 - 授权后重定向不适用于iOS 11测试版

"Redirecting you back to the application.This may take a few moments." 

[TwitterKit]做了与消息遭遇错误“无法使用该系统的帐户进行认证。”:错误域= TWTRLogInErrorDomain代码= 0“用户拒绝访问系统帐户”的UserInfo = {NSLocalizedDescription =用户拒绝访问系统帐户,NSLocalizedRecoverySuggestion =授予该用户对系统的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; 
} 

enter image description here

从iOS 11开始,Apple已从iOS中删除社交帐户。

您应该使用Twitter Kit 3 for iOS。

参考Twitter的博客https://dev.twitter.com/twitterkit/ios/migrate-social-framework

UPDATE

的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 
} 

的ViewController

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> 
+0

是啊引用链接只是没有得到重定向 – Ravindhiran

+0

我试图使用Twitter的登录方法与ViewController和登录成功和重定向成功。在iPhone 7 Plus/iOS 11模拟器上测试。 (void)logInWithViewController:(可为空的UIViewController *)viewController完成:(TWTRLogInCompletion)完成; – Basheer

+0

你能分享我的代码吗? – Ravindhiran