如何从通讯录应用程序(如Facebook)处理即时消息传递URL [英] How to handle instant messaging URL from Contacts application (like Facebook)

查看:155
本文介绍了如何从通讯录应用程序(如Facebook)处理即时消息传递URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感觉这会很困难。



在iOS7上,通过单击,Facebook应用程序可以直接从iOS Contact应用程序启动。在任何联系人的IM(即时消息)信息上:





很明显,这仅在您使Facebook能够访问您的联系人的情况下有效,但我想知道他们是如何做到的? b $ b我知道自定义URL处理,它非常完美用于处理特制URL,但在这种情况下,将自己的伪造URL( myapp://gui13@lol.com)放入IM联系人信息中不会触发功能。



我发现只有一种方法可以触发从Contact应用程序启动我的应用程序,这就是将我的URL保存到有关以下内容的链接类型信息中contact。

不好的缺点是此链接类型信息未与远程通讯簿同步...



所以我的问题是:



还是坏消息……Facebook是Apple-,我如何告诉iOS在用户单击联系人应用中的IM信息时启动我的应用?像Twitter这样受祝福的应用程序,使其能够与Apple应用程序进行这种高级交互?

解决方案

。正如您所说的,您必须为您的应用程序创建自定义URL方案(如果有人不知道如何操作,这里是教程)。



现在,您必须将 kABPersonSocialProfileProperty 添加到您的联系人(现有的或新的)。

  ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL,nil); 
ABRecordRef联系人= ABPersonCreate();

/ *实施标准的联系信息* /
/ *下面的社交部分* /

ABMultiValueRef social = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
ABMultiValueAddValueAndLabel(social,(__bridge CFTypeRef)([NSDictionary dictionaryWithObjectsAndKeys:
@您的应用服务名称,kABPersonSocialProfileServiceKey,//在联系人
@联系人名字/姓氏/标识符中可见) ,kABPersonSocialProfileUsernameKey,//将在联系人
@您的应用程序自定义URL方案中可见,kABPersonSocialProfileURLKey,//将在单击事件
nil]中打开的URL,(__bridge CFStringRef)@ your应用特殊标识符,NULL); //知道此社交所属的应用。我相信这是出于搜索目的

ABRecordSetValue(contact,kABPersonSocialProfileProperty,social,NULL);
CFRelease(社交);

/ *保存联系人* /

为了完整起见,这里< href = http://www.raywenderlich.com/63885/address-book-tutorial-in-ios rel = nofollow>教程,其中深入说明了如何创建通讯录并将其添加到通讯录。



希望它将对某人有所帮助。


I have a feeling this one's going to be hard.

On iOS7, the Facebook app has the ability to be launched directly from the iOS Contact application, by clicking on any contact's IM (instant messaging) info:

This only works if you enable Facebook to have access to your contacts, obviously, but I'm wondering how they do it?
I know of the Custom URL handling, which is perfect for handling specially crafted URLs, but in this case, putting my own forged url ( "myapp://gui13@lol.com" ) in an IM contact information doesn't trigger the functionnality.

There's only one way that I found that triggers the launch of my app from the Contact application, which is to save my URL into a "link"-type information about the contact.
The bad drawback is that this "link" type information is not synced with the remote address books...

So my question is: how can I tell iOS to launch my app when the user clicks an IM information in the Contact app.?

Or the bad news... Facebook is an Apple-blessed app, just like Twitter, which enables it to have this kind of advanced interaction with Apple's apps?

解决方案

It can be achieved. As you said you have to create custom URL scheme for you app (if someone doesn't know how to this, here is tutorial).

Now you have to add kABPersonSocialProfileProperty to your contact (existing or new one).

ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, nil);
ABRecordRef contact = ABPersonCreate();

/* implement standard contact info */
/* the social part below */

ABMultiValueRef social = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
ABMultiValueAddValueAndLabel(social, (__bridge CFTypeRef)([NSDictionary dictionaryWithObjectsAndKeys:
                                                           @"your app service name ", kABPersonSocialProfileServiceKey, //will be visible in contact
                                                           @"contact firstname / lastname / identifier", kABPersonSocialProfileUsernameKey, //will be visible in contact
                                                           @"your app custom url scheme", kABPersonSocialProfileURLKey, //url which will be open onclick event
                                                           nil]), (__bridge CFStringRef)@"your app special identifier", NULL); //to know to which app this social belongs to. I believe it is for search purposes

ABRecordSetValue(contact, kABPersonSocialProfileProperty, social, NULL);
CFRelease(social);

/* save contact */

For sake of completeness here is tutorial which explains deeply how to create and add contact to address book.

Hope it will help someone.

这篇关于如何从通讯录应用程序(如Facebook)处理即时消息传递URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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