如何从我们的应用程序在WhatsApp中打开特定联系人的聊天屏幕? [英] How to open specific contact's chat screen in WhatsApp from our app?

查看:518
本文介绍了如何从我们的应用程序在WhatsApp中打开特定联系人的聊天屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想集成以下功能:

我正在传递一个用户的联系电话.如果该联系电话已经存在,请在我按应用程序中的WhatsApp按钮时直接打开该用户的聊天屏幕.

I am passing one contact number of a user. If that contact number already exists, directly opens that user's chat screen when I press on WhatsApp button in my app.

如果通讯录中不存在该联系人,则首先将该联系人存储在通讯录中,然后在WhatsApp中打开该联系人的聊天屏幕(带有刷新的联系人,因此我将在WhatsApp聊天屏幕上获得该人的名字).

If that contact does not exist in the address book, then first, store this contact in the address book and then open that contact's chat screen in WhatsApp (with refreshing contacts so I will get the name of that person on WhatsApp chat screen).

我已完成以下任务:

如果联系人不存在,则它将首先存储在地址簿中,然后移至WhatsApp.如果我第二次再次按WhatsApp按钮,则它将检查该联系人是否存在.如果已保存,则获取其记录标识符并通过WhatsApp URL方案传递.

If contact does not exist, then it first stored in the address book and then move to WhatsApp. If I press the WhatsApp button again for the second time, then it checks that contact if it exists or not. If it's already saved, then fetch its record identifier and passed with WhatsApp URL scheme.

主要问题是它只是移至WhatsApp的联系人列表,而没有打开用户的特定聊天屏幕.

The main problem is that it just moves to WhatsApp's contact list, but does not open specific chat screen of the user.

注意::此功能在Android上可完美运行,因此我希望也可以将其集成到iOS/Swift应用中.

Note: This thing works perfectly in Android, so I hope that it's also possible to integrate into iOS/Swift app.

推荐答案

只需在您的whatsapp网址方案中附加ABID,然后将其命名为有效.

Simply Append with ABID with your whatsapp url scheme and call this its worked.

ABID 代表地址簿记录ID,以下代码用于获取AB记录ID.它对URL本身使用分号很敏感.

ABID stands for the Address book Record ID,the code below works to get the AB Record ID. It is sensitive to the use of delimeters in the URL itself.

要将注释发送给特定用户,请使用以下网址字符串格式: whatsapp://send?abid = 12& text = Hello%20World -注意&标记第二个参数.

To send a note to a specific user use this - urlstring format: whatsapp://send?abid=12&text=Hello%20World - note the use of & to mark the second parameter.

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController    *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{   
    ARecordID  = (ABRecordID)ABRecordGetRecordID(person);
    ....
    whatsapp_string = [NSString stringWithFormat:@"whatsapp://send?abid=%d&text=%@;",ARecordID, "hello"];
    ....
}

这篇关于如何从我们的应用程序在WhatsApp中打开特定联系人的聊天屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆