自Twitter宣布他们将停止支持iOS,Android和Unity的Twitter SDK(https://blog.twitter.com/developer/en_us/topics/tools/2018/discontinuing-support-for-twitter-kit- sdk.html),我不确定继续我的申请的最佳方式.我对iOS的选项特别感兴趣.
我目前只使用完整功能的子集,主要是:
对于身份验证,OAuthSwift看起来可能是替代品. https://github.com/OAuthSwift/OAuthSwift
为了从API中获取推文,Swifter是我一直在使用并可以继续使用的库. https://github.com/OAuthSwift/OAuthSwift
但是,我目前正在使用Twitter SDK的TWTRTweetView类,并且我不知道有任何其他选项来替换它.
Twitter似乎建议使用Web视图在应用程序中显示推文,但这个选项并不适合我的用例.我正在寻找原生解决方案.
任何人都可以建议任何其他替代方法或方法来考虑这些发展吗?
我正在尝试登录用户的Twitter帐户.我已按照https://dev.twitter.com/twitterkit/ios/installation上的指南来整合Twitter.
但是,当我尝试登录时,没有任何反应:
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession * _Nullable session, NSError * _Nullable error) {
//not called
if(session && !error){
}else{
}
}];
Run Code Online (Sandbox Code Playgroud)
我也试过明确指定视图控制器:
[[Twitter sharedInstance] logInWithViewController:self completion:^(TWTRSession * _Nullable session, NSError * _Nullable error) {
//again, not called.
if(session && !error){
}else{
}
}];
Run Code Online (Sandbox Code Playgroud)
Twitter应用程序本身已登录并与我的帐户完美配合.
我究竟做错了什么?
更新:除了设备(具有Twitter应用程序和登录帐户)之外,我还尝试过模拟器(显然,它没有Twitter应用程序),在两种情况下都是一样的.
我正在使用iOS 10上的Swift 3编写应用程序.sharedInstance()当用户拒绝来自系统或帐户的帐户权限时,方法会向控制台抛出错误(例如"无法使用系统帐户进行身份验证").在进入关闭之前,控制台上会显示错误.我不会在应用程序中向用户显示此错误,例如在警报时.这是我的代码:
Twitter.sharedInstance().logIn { (session, error) in
if error != nil {
// print(error?.localizedDescription ?? " ")
return
})
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
2016-11-29 14:49:09.023 CarReview[1254:31719] [TwitterKit] did encounter error with message "Unable to authenticate using the system account.": Error Domain=TWTRLogInErrorDomain Code=2 "User allowed permission to system accounts but there were none set up." UserInfo={NSLocalizedDescription=User allowed permission to system accounts but there were none set up.}
2016-11-29 14:49:09.024 CarReview[1254:31719] [TwitterKit] No matching scheme found.
2016-11-29 14:49:09.292 CarReview[1254:31719] [TwitterKit] did encounter …Run Code Online (Sandbox Code Playgroud) 我试图通过提供的TWTRComposer类使用TwitterKit撰写推文.这是我打电话的功能:
-(void) tweet:(UIViewController *) root {
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText:@"just setting up my Twitter Kit"];
// Called from a UIViewController
[composer showFromViewController:root completion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultCancelled) {
NSLog(@"Tweet composition cancelled");
}
else {
NSLog(@"Sending Tweet!");
}
}];
}
Run Code Online (Sandbox Code Playgroud)
这有两个问题:
showFromViewController立即调用方法中的完成块,结果类型为TWTRComposerResultCancelled.我有一种感觉,这可能与Twitter的登录问题有某种关系.我正在处理的应用程序不包括使用Twitter注册/登录.但是,我的印象是TWTRComposer处理所有登录.
任何帮助都非常感谢,谢谢你的阅读!
我安装了这些pod文件.
pod 'TwitterKit'
pod 'TwitterCore'
当我尝试导入文件i时.e #import <TwitterKit/TwitterKit.h>显示未找到错误.
为什么会有任何想法?什么出错或什么都有待补充?
最近Twitter工具包将失去支持,我想知道什么是正确和推荐的方式来集成显示搜索的推文推文(使用api本地或一些新的替代品,推特套件)现在和未来.
大多数在线教程已弃用或使用Twitter工具包不能用于Twitter在您的服务上进行的某些更改并且在oAuth上失败.
问题是如何在今年将Twitter与Android Api-28上的新原生api集成
如果有人有样品或开始项目,我会对此进行评估.
我有一个UITableViewCell包含TWTRTweetView自动布局.我正在加载这样的推文:
- (void)loadTweetWithId:(NSString *)tweetId {
if (mTweetId == nil || ![mTweetId isEqualToString:tweetId]) {
mTweetId = tweetId;
[[[TWTRAPIClient alloc] init] loadTweetWithID:tweetId completion:^(TWTRTweet *tweet, NSError *error) {
if (tweet) {
NSLog(@"Tweet loaded!");
[mTweetView configureWithTweet:tweet];
[mTweetView setShowActionButtons:YES];
//[mTweetView setDelegate:self];
[mTweetView setPresenterViewController:self.viewController];
[mTweetView setNeedsLayout];
[mTweetView layoutIfNeeded];
[mTweetView layoutSubviews];
hc.constant = mTweetView.frame.size.height;
[self updateConstraints];
[self layoutIfNeeded];
[self layoutSubviews];
[self.tableView setNeedsLayout];
[self.tableView layoutIfNeeded];
[self.tableView layoutSubviews];
} else {
NSLog(@"Tweet load error: %@", [error localizedDescription]);
}
}];
}
}
Run Code Online (Sandbox Code Playgroud)
当tweet加载的单元格不调整大小,除非我将其滚动并向后滚动它.我已经尝试了几种方法,你可以在代码片段中看到.但不是这些作品.我的表视图使用全自动布局方法,该方法不实现行功能的单元格高度.我怎样才能解决这个问题?
更新:
使用:
[self.tableView …Run Code Online (Sandbox Code Playgroud) 我正在使用 TwitterKit 和 Firebase 来允许用户使用 Twitter 登录。我第一次尝试使用 Twitter 登录时失败并出现错误:
[TwitterCore] 无法验证会话凭据。2018-07-11 13:57:20.999365-0400 Social_notes[6794:1892888] [TwitterKit] 确实遇到了消息“无法保存会话”的错误:错误域=NSURLErrorDomain 代码=-1005“网络连接丢失。” UserInfo = {NSUnderlyingError = 0x1c044dcb0 {错误域= kCFErrorDomainCFNetwork代码= -1005“(null)”UserInfo = {_kCFStreamErrorCodeKey = 57,_kCFStreamErrorDomainKey = 1}},NSErrorFailingURLStringKey = https://api.twitter.com/1.1/account/verify_credentials .json、 NSErrorFailingURLKey= https://api.twitter.com/1.1/account/verify_credentials.json、 _kCFStreamErrorDomainKey=1、 _kCFStreamErrorCodeKey=57、 NSLocalizedDescription=网络连接丢失。} 2018-07-11 13:57:21.413753 -0400 Social_notes[6794:1892888] [TwitterKit] 确实遇到了错误,消息为“获取用户身份验证令牌时出错。”:Error Domain=TWTRLogInErrorDomain Code=-1“回调 URL 未批准用于此客户端应用程序。批准的回调 URL 可以在您的应用程序设置” UserInfo={NSLocalizedDescription=此客户端应用程序未批准回调 URL。可以在应用程序设置中调整批准的回调 URL} Twitter 登录错误:请求失败:禁止 (403)
但如果我再次尝试使用 Twitter 登录,它就可以正常工作。
信息表
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-XXX</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>twitter</string>
<string>twitterauth</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key> …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的应用升级到最新的iOS支持.我通过CocoaPods添加了TwitterKit,并将标题放在我的Bridge Header中.然而; 我收到一个错误说:
使用未解决的'推特' - 你的意思是'TWTRTTwitter'.
func application(_ application: UIApplication, didFinishLaunchingWithOptions lauunchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Twitter.sharedInstance().start(withConsumerKey:"MYKEY", consumerSecret:"MYSECRET")
return true
}
Run Code Online (Sandbox Code Playgroud)
这是推特推荐的代码.我也得到了:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let handled:Bool = true
Twitter.sharedInstance().application(app, open: url, options: options)
return handled
}
Run Code Online (Sandbox Code Playgroud)
有什么指针吗?
我正在尝试使用开发人员门户网站中提供的说明使用twitterkit登录,但无济于事.每次我尝试这样做,无论如何loginWithCompletion,loginWithViewController或者TWTRLoginButton我在日志中得到这个错误:
CredStore - performQuery - Error copying matching creds. Error=-25300, query={
class = inet;
"m_Limit" = "m_LimitAll";
ptcl = htps;
"r_Attributes" = 1;
sdmn = "https://api.twitter.com";
srvr = "api.twitter.com";
sync = syna;
}
[TwitterKit] did encounter error with message "Error obtaining user auth token.": Error Domain=TWTRLogInErrorDomain Code=-1 "{"errors":[{"code":32,"message":"Could not authenticate you."}]}" UserInfo={NSLocalizedDescription={"errors":[{"code":32,"message":"Could not authenticate you."}]}}
Run Code Online (Sandbox Code Playgroud)
这是我的plist的内容
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
...
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/> …Run Code Online (Sandbox Code Playgroud) 我是Xcode和swift的新手.
我已经开始使用TwitterKit,我已经使用cocoapods在我的项目上安装了它,我遵循了这个教程:https://dev.twitter.com/twitterkit/ios/installation
问题是,当我尝试在AppDelegate中初始化TwitterKit时,我无法使用Twitter.sharedInstace,因为Twitter不存在.(我已经在AppDelegate中导入了TwitterKit import TwitterKit)
这是我的App Delegete课程:
import UIKit
import TwitterKit
import Firebase
import FirebaseAuth
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Twitter.sharedInstance().start(withConsumerKey:"********", consumerSecret:"*******")
//Here I get the error: Use of unresolved identifier 'Twitter'
return true
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我使用了Fabric没有问题,但是因为新的twitterkit 3.0更新我遵循了所有的安装文档,但是当我使用TWTRComposer时,我的应用程序崩溃了下面的消息:"'TWTRInvalidInitializationException',原因:'尝试登录或者像是没有推文在应用设置中设置有效的Twitter工具包URL方案." 似乎无法找出解决方案.
// 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")
}
}
Run Code Online (Sandbox Code Playgroud)
下面是app delegate didFinishLaunchingWithOptions代码
Twitter.sharedInstance().start(withConsumerKey:"xxxxxxxxxxxx", consumerSecret:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Run Code Online (Sandbox Code Playgroud)
以下是我的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>
Run Code Online (Sandbox Code Playgroud)
不是应用程序启动没有问题,但当我按下按钮在Twitter上分享时,推特作曲家打电话,并且"composer.show"线应用程序崩溃.由于更改了ios11内置帐户功能,我需要使用twitter sdk删除