【发布时间】:2017-01-06 22:17:39
【问题描述】:
我只想将我的 ios 应用程序中的文本分享到 Facebook Messenger。
是否可以使用 url 方案向 facebook messenger 发送消息?
例如:fb-messenger://post?text=hello
例如:fb-messenger://send?text=hello
例如:fb-messenger://messaging?text=hello
Objective-C 之类的代码
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb-messenger://"]]) {
NSString *msgString = @"Hello World";
NSString *urlString = [NSString stringWithFormat:@"fb-messenger://send?text=%@", msgString];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
} else {
NSLog(@"Failed to open fb-messenger App ");
}
搜索scheme后发现android已经解决了。 这是link
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Your message");
sendIntent.setType("text/plain");
sendIntent.setPackage("com.facebook.orca");
try {
startActivity(sendIntent);
} catch (android.content.ActivityNotFoundException ex) {
ToastHelper.show(this, "Please Install Facebook Messenger");
}
我在 google 和 stackoverflow 上进行了搜索,但没有找到任何有用的信息。
【问题讨论】:
-
你不能。根据 Facebook 平台政策,用户需要自己编写文本
-
知道了,非常感谢。
-
@DanielWeng 你得到答案了吗。
-
我们不能分享链接给 FB Messenger 收件人吗?
标签: ios iphone xcode facebook url-scheme