我使用以下代码进行Twitter共享。在这里,我正在检查设备中是否安装了twitter本机应用程序,然后我打开本机应用程序,否则我打开webView进行Twitter共享。使用下面的代码,我可以做Twitter分享,但问题是成功分享回调后没有来到我的应用程序,它将去推特应用程序。
NSURL *instagramURL = [NSURL URLWithString:@"twitter://post?message=hello%20world"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
} else {
// <a href="twitter://tweet?text=I share this on Twitter from a website">Share this on Twitter</a>
GenericWebViewController *gwvController=[[GenericWebViewController alloc] init];
[gwvController loadWithUrl:[NSURL URLWithString:@"https://twitter.com/intent/tweet?url=www.google.com&text=I%20am%20eating%20branston%20pickel%20right%20now&original_referer=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F9127808%2Fhow-do-you-include-hashtags-within-twitter-share-link-text"] navBarTitle:@"Twitter"];
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"" style: UIBarButtonItemStyleBordered target: nil action: nil];
[[self navigationItem] setBackBarButtonItem: newBackButton];
[self.navigationController pushViewController:gwvController animated:YES];
//WI-542:Showing the navigation bar in WebView when user user navigate from deal details.
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
成功分享后如何回到我的应用程序。
答案 0 :(得分:0)
你不能!启动外部应用程序后,您无法返回到您的应用程序,除非外部应用程序是以这种方式专门完成的(例如使用&#34;回调&#34; arg),但很少有&#34;大名称& #34; (twitter,facebook,...)以这种方式工作
如果您想使用Twitter并且仍然没有退出应用,请使用Twitter框架工作(https://developer.apple.com/library/ios/documentation/Twitter/Reference/TwitterFrameworkReference/_index.html)
它有点复杂,但您可以获得留在应用中的好处。