【发布时间】:2016-12-02 08:28:53
【问题描述】:
我正在尝试在 fb messenger 上向我的朋友发送包含 URL 的短信,但没有任何方法可以发送。
我试过了
let result = FBSDKMessengerSharer.messengerPlatformCapabilities().rawValue & FBSDKMessengerPlatformCapability.Image.rawValue
if result != 0 {
let content: FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: Urls().WEONE_ITUNES_TINYURL)
content.contentDescription = "Dscription"
content.contentTitle = "Title"
let facebookSendButton: FBSDKSendButton = FBSDKSendButton()
facebookSendButton.shareContent = content
facebookSendButton.sendActionsForControlEvents(UIControlEvents.TouchUpInside)
} else {
Utils().alertView(self, title: "Cannot Send Message", message: "Your device is not able to send Facebook Messenger messages.")
}
但这仅用于共享链接
我也尝试使用 urlscheme 发送消息,但它只是打开了 fb messenger:
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "fb-messenger-api://")!) {
var msgString = "Hello World: https://randomurl.com"
let urlStringEncoded = msgString.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())
var urlString = "fb-messenger://messaging?text=\(urlStringEncoded!)"
UIApplication.sharedApplication().openURL(NSURL(string: urlString)!)
}
else {
print("Failed to open fb-messenger App ")
}
在android中这是可能的
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");
}
这是从android发送的
任何帮助将不胜感激
提前致谢
【问题讨论】:
-
urlscheme 只会打开 FBMessenger,如果它打开了,你可以点击那里的任何一个并发送消息,或者你想直接从你的应用程序发送消息给特定的人?首先澄清这一点
-
@ShobhakarTiwari 我想向我在 FBmessenger 上选择的朋友发送邀请消息。
-
再澄清一点,尽量搞清楚
-
我有特定的文本,其中包含指向我的应用程序的链接和一个带有一些文本的唯一推荐 ID,我需要在 FBmessenger 上将其发送给我选择的朋友
-
所有朋友还是您要在Messenger上选择的特定朋友?
标签: ios swift facebook sendmessage