简体   繁体   English

iOS - 带有 SLComposeViewController 的 Twitter 帖子回调

[英]iOS - Twitter post callback with SLComposeViewController

Our app has sharing options with Twitter that was implemented with third party libraries and I'm trying to re-implement them.我们的应用程序具有与 Twitter 共享的选项,这些选项是通过第三方库实现的,我正在尝试重新实现它们。 Before, we used MGTwitterEngine, SA_OAuthTwitterController and REComposeViewController to link and post message to Twitter.之前,我们使用 MGTwitterEngine、SA_OAuthTwitterController 和 REComposeViewController 将消息链接和发布到 Twitter。 Everything works fine but I don't like the fact that we started getting problems as we started supporting new iOS version and dropping old ones.一切正常,但我不喜欢这样一个事实,即我们开始支持新的 iOS 版本并放弃旧版本时开始出现问题。

I decided to stay away from those third party libraries and already implemented with Social framework.我决定远离那些已经使用 Social 框架实现的第三方库。 Considering the post, it looks pretty good and the implementation itself become quite simple but there's a PROBLEM.考虑到这篇文章,它看起来很不错,实现本身也变得很简单,但有一个问题。 SLComposeViewController's completion block doesn't tell you that the post was successful or not. SLComposeViewController 的完成块不会告诉您帖子是否成功。 I need to know if the post was successful or not because I'm making extra api call to our server to keep tracks of user's posts if the post is successful.我需要知道帖子是否成功,因为我正在对我们的服务器进行额外的 api 调用,以在帖子成功时跟踪用户的帖子。

Here are my questions:以下是我的问题:

Should I give up the SLComposeViewController and make the post call manually or it's better just use third party libraries for this particular case?我应该放弃 SLComposeViewController 并手动进行 post 调用,还是最好在这种特殊情况下使用第三方库? Is there any way I can get around while still taking advantage of using SLComposeViewController?有什么办法可以在仍然利用使用 SLComposeViewController 的同时绕过吗?

Thanks for any inputs/idea from you guys in advance.提前感谢你们的任何意见/想法。

This is old, but heres an answer for anyone who stumbles upon it like I did.这是旧的,但对于像我一样偶然发现它的人来说,这是一个答案。

Reference: Tutorial for SLComposeViewController sharing参考: SLComposeViewController 分享教程

You first set a completion handler for the SlComposeViewController:首先为 SlComposeViewController 设置一个完成处理程序:

SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
    [tweetSheet setInitialText:@"put your #tag"];
    [tweetSheet addImage:self.imageToSend];

    [tweeter setCompletionHandler:^(SLComposeViewControllerResult result) {

        switch (result) {
            case SLComposeViewControllerResultCancelled:
            NSLog(@"Post Canceled");
            break;
            case SLComposeViewControllerResultDone:
            NSLog(@"Post Sucessful");
            break;

            default:
            break;
        }
    }];

Then present it with that completion handler already set:然后用已经设置的完成处理程序呈现它:

    [self tweeter animated:YES completion:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用SLComposeViewController在iOS中回复Twitter帖子? - How to use SLComposeViewController for reply twitter post in iOS? iOS SLComposeViewController - 不显示Twitter帖子的网址 - iOS SLComposeViewController - url not displaying for twitter post 使用SLComposeViewController在Twitter上发布动画gif - Post animated gif on Twitter with SLComposeViewController 如何通过隐藏SLComposeViewController * tweetSheettweet实例在Twitter上发布 - How to post on twitter by hiding SLComposeViewController *tweetSheettweet instance 用于Twitter的SLComposeViewController现在在iOS 8.3中崩溃 - SLComposeViewController for Twitter now crashing in iOS 8.3 SLComposeViewController setInitialText在iOS 11中的Twitter上不起作用 - SLComposeViewController setInitialText not working on Twitter in iOS 11 使用SLComposeViewController在Facebook / Twitter上发布多个图像? - Post multiple images using SLComposeViewController on Facebook/ Twitter? SLComposeViewController发布了image和url ios9 - SLComposeViewController post both image and url ios9 SLComposeViewController在ios7上的facebook上发布图像 - SLComposeViewController to post image on facebook in ios7 如何使用SLComposeViewController检索Facebook或Twitter帖子的帖子URL? - How to retrieve the post URL for a Facebook or Twitter post using SLComposeViewController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM