Sending message from iOS application to FB messenger app

◇◆丶佛笑我妖孽 提交于 2019-12-25 06:55:13

问题


I need to send a pre-filled message from my app to the fb messenger app. I followed the post SO Link. The custom URL just opens the fb messenger app but shows no change.

Below is the code that I have tried:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb-messenger://contacts"]];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb-messenger://share"]];

The above code just opens the fb messenger app, it does not navigate to contacts page or the compose screen.

Has anybody faced the same situation? Does anybody know the code for sending the text I want to share from the app? Examples would be appreciated.


回答1:


Go with following code its will works for you

NSURL *fbURL = [NSURL URLWithString:@"fb-messenger://user-thread/USER-ID/"];
if ([[UIApplication sharedApplication] canOpenURL: fbURL]) {
[[UIApplication sharedApplication] openURL: fbURL];
}


来源:https://stackoverflow.com/questions/26874818/sending-message-from-ios-application-to-fb-messenger-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!