如何将我的应用中的帖子分享到 Twitter iOS [英] How to share a post from my app to twitter iOS

查看:54
本文介绍了如何将我的应用中的帖子分享到 Twitter iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上希望用户将我的应用程序中的某些内容分享到 Twitter.我正在探索可能的不同方法并找到 SLComposeViewController 但它已被弃用.对 twitterKit 的支持也已被 twitter 正式停止.一种可能的方法似乎是在 这篇文章.还有其他更好的方法吗?我更希望用户留在应用程序本身(类似于 fb 的共享表).谢谢!

I basically want the user to share something from my app to twitter. I was exploring the different methods possible and found SLComposeViewController but it is deprecated. Support for twitterKit has also been officially stopped by twitter. One possible way to do so seems to be like given in the answers in this post. Is there some other better way to do so? I would prefer if the user stays in the app itself (something similar to sharesheet for fb). Thanks!

推荐答案

您可以使用 twitter-kit-ios.

要发布来自 文档 的推文示例代码关注

For posting a tweet sample code from documentation would be following

目标-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
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 端点.

Straight from the discontinuing blog post you can use, new api endpoints.

这篇关于如何将我的应用中的帖子分享到 Twitter iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆