ios - 如何将我的应用程序中的帖子分享到 Twitter iOS

标签 ios twitter share slcomposeviewcontroller twitterkit

我基本上希望用户将我的应用程序中的内容分享到 Twitter。我正在探索可能的不同方法并找到了 SLComposeViewController 但它已被弃用。 twitterKit 的支持也已经被 twitter 正式停止。一种可能的方法似乎在 this post 中的答案中给出。 .还有其他更好的方法吗?如果用户留在应用程序本身(类似于 fb 的 sharesheet),我更愿意。谢谢!

最佳答案

您可以使用 twitter-kit-ios .

用于发布来自 documentation 的推文示例代码会关注

objective-c

// Objective-C
TWTRComposer *composer = [[TWTRComposer alloc] init];

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

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

swift

// Swift
let composer = TWTRComposer()
    
composer.setText("just setting up my Twitter Kit")
composer.setImage(UIImage(named: "twitterkit"))
    
// Called from a UIViewController
composer.show(from: self.navigationController!) { (result in
    if (result == .done) {
        print("Successfully composed Tweet")
    } else {
        print("Cancelled composing")
    }
}

直接来自您可以使用的停用博客文章,新 API endpoints .

关于ios - 如何将我的应用程序中的帖子分享到 Twitter iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53297678/

相关文章:

ios - 检查/验证文本字段只能是 1 - 80

ios - 为什么我的变量的值在Swift中恢复?

python - Twython.__init__ 中出现意外的关键字参数

python - MongoDB/PyMongo : BadValue Unsupported projection option when trying to query all dates after

iOS 共享扩展不显示我的自定义 ShareViewController

ios - iOS 中的中文文本转语音

ios - 滚动时,UICollectionView 在单元格之间闪烁 "see through"条细线

algorithm - Twitter 时间线算法是如何工作的?

javascript - Twitter意图的 'tweet'事件回调在 'click'而不是 'tweet'上触发

windows - 释放 Windows 文件共享锁