2017-06-20 118 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中添加了鍵,但忘記了我的另一個目標。上面的代碼也起作用。傻......( –