Whatsapp URL方案中的ABID [英] ABID in Whatsapp URL schemes

查看:260
本文介绍了Whatsapp URL方案中的ABID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天Whatsapp更新了他们的iOS应用程序并发布了官方URL方案(api hooks)。

Yesterday Whatsapp updated their iOS application and released official URL scheme (api hooks).

我想用它玩一点,我现在面临的问题我不明白这整个abid的事情?!我从哪里获得联系人ID?那么我该如何使用呢?

I wanted to play a little with it and I'm now facing the problem that I don't understand this whole "abid" thing?! Where do I get the contact ID from? And how do I have to use it then?

提前致谢:)

推荐答案

ABID代表地址簿记录ID,下面的代码用于获取AB记录ID。它对URL本身中的分隔符的使用很敏感。所以最初的试验没有奏效。要向特定用户发送备注,请使用以下命令:urlstring格式:
whatsapp:// send?abid = 123& text = What%20a%20nice%20day - 请注意使用&标记第二个参数。

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. So the initial trials were not working. To send a note to a specific user use this - urlstring format: whatsapp://send?abid=123&text=What%20a%20nice%20day - note the use of & to mark the second parameter.

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

这可以在不使用人的情况下编码选择器只需打开地址簿:

this can be coded without using the people picker simply open the address book:

逐个查看记录,比较姓名或姓名和号码 -

go through the records one by one comparing the name or name and number -

ABAddressBookRef addressBook = ABAddressBookCreateWithOptions (NULL, error);
int len = (int)ABAddressBookGetPersonCount(addressBook);
for(int i = 1; i < (len + 1); i++) {
    ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, (ABRecordID)i);
    NSString *first, *last;
    if (!person) {
        continue;
    }
    CFStringRef firstc = (CFStringRef)ABRecordCopyValue(person, kABPersonFirstNameProperty);
    if (firstc) {
        CFStringRef lastc =(CFStringRef) ABRecordCopyValue(person, kABPersonLastNameProperty);
        if (lastc) {
            first = [NSString stringWithFormat:@"%@",firstc];
            last =[NSString stringWithFormat:@"%@",lastc];
            CFRelease(lastc);
        }
        CFRelease(firstc);
    }
    if ([[first lowercaseString] isEqualToString:[firstname lowercaseString]] && [[last lowercaseString] isEqualToString:[surname lowercaseString]]) {
        alreadyExists = YES;
        ABID = ABRecordGetRecordID(person);
        break;
    }
}

这篇关于Whatsapp URL方案中的ABID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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