2017-06-20 77 views
0

我曾经使用fabric但没有问题,但自从新的twitterkit 3.0更新后,我跟随了所有的安装文档,但是当我使用TWTRComposer时,我得到应用程序崩溃,出现以下消息:''TWTRInvalidInitializationException',原因: '未尝试在应用设置中设置有效的Twitter工具包URL计划而尝试登录或喜欢Tweet“。似乎无法找出解决方案。在ios中发生Twitterkit 3.0'TWTRInvalidInitializationException'错误

// Swift 
    let composer = TWTRComposer() 

    composer.setText("just setting up my Twitter Kit") 
    composer.setImage(image.image) 

    // Called from a UIViewController 
    composer.show(from: self.navigationController!) { (result) in 
     if (result == .done) { 
     print("Successfully composed Tweet") 
     } else { 
     print("Cancelled composing") 
     } 
    } 

如下因素是应用程序委托didFinishLaunchingWithOptions代码

Twitter.sharedInstance().start(withConsumerKey:"xxxxxxxxxxxx", consumerSecret:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx") 

以下是我infoPlist代码

<key>CFBundleURLTypes</key> 
<array> 
    <dict> 
     <key>CFBundleURLSchemes</key> 
     <array> 
      <string>twitterkit-consumentkeyxxxxxxx</string> 
      <string>fbkeyxxxxxxxxxxxx</string> 
      <string>xxxxxxxxx</string> 
     </array> 
    </dict> 
</array> 
<key>LSApplicationQueriesSchemes</key> 
<array> 
    <string>fbapi</string> 
    <string>fb-messenger-api</string> 
    <string>fbauth2</string> 
    <string>fbshareextension</string> 
    <string>twitter</string> 
    <string>twitterauth</string> 
</array> 

不存在应用上的启动没有问题,但是当我按下按钮,即可分享微博,微博作曲家是通话和“composer.show”线应用程序崩溃。我需要使用,由于在ios11改变Twitter的SDK内置帐户功能删除

+0

您可以使用吊舱“吊舱‘TwitterKit’” –

+0

是的我添加twitterKit确实安装pod和所有代码工作正常...错误发生在应用程序共享按钮操作.... composer.show行 –

+0

您在相同的URLSchema中实现fb键和twitter键 –

回答

4

您需要单独添加关键是这样的:

<key>CFBundleURLTypes</key> 
    <array> 
     <dict> 
      <key>CFBundleTypeRole</key> 
      <string>Editor</string> 
      <key>CFBundleURLSchemes</key> 
      <array> 
       <string>fb-fbid-</string> 
      </array> 
     </dict> 
     <dict> 
      <key>CFBundleTypeRole</key> 
      <string>Editor</string> 
      <key>CFBundleURLSchemes</key> 
      <array> 
       <string>twitterkit-twitterKey</string> 
      </array> 
     </dict> 
    </array> 
+0

持有我会尝试此代码 –

+0

感谢但没有运气与上述代码以及... –

+1

问题所以LVED。问题与信息列表有关。我在主plist中添加了键,但忘记了我的另一个目标。上面的代码也起作用。傻......( –