有人知道如何使用预填充文本打开Facebook messenger应用程序吗?
例如,要在指定用户打开messenger应用程序,您可以编写以下代码:
NSURL *fbURL = [NSURL URLWithString:@"fb-messenger://user-thread/USER_ID"];
if ([[UIApplication sharedApplication] canOpenURL: fbURL]) {
[[UIApplication sharedApplication] openURL: fbURL];
}对于What应用程序来说非常简单:
NSURL *whatsappURL = [NSURL URLWithString:[NSString stringWithFormat:@"whatsapp://send?text=%@", @"String to post here"]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}发布于 2014-07-30 22:59:55
有这样一个函数,但它只存在于Facebook的SDK中。
看看这个-- https://developers.facebook.com/docs/ios/share#message-dialog
发布于 2019-10-02 16:21:02
Swift 4和5
private func inviteViaFacebook() {
let id = "akbarkhanshinwar"
// If you have User id the use this URL
let urlWithId = "fb-messenger://user-thread/\(id)"
// If you don't have User id then use this URL
let urlWithoutId = "fb-messenger://user-thread"
if let url = URL(string: urlWithId) {
// this will open your Messenger App
UIApplication.shared.open(url, options: [:], completionHandler: {
(success) in
if success == false {
// If Messenger App is not installed then it will open browser.
// If you have User id the use this URL
let urlWithIdForBrowser = "https://m.me/\(id)"
// If you don't have User id then use this URL
let urlWithoutIdForBrowser = "https://m.me"
let url = URL(string: urlWithIdForBrowser)
if UIApplication.shared.canOpenURL(url!) {
UIApplication.shared.open(url!)
}
}
})
}
}https://stackoverflow.com/questions/25040110
复制相似问题