0

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:

enter image description here

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?

CBroe
  • 91,630
  • 14
  • 92
  • 150
Gui13
  • 12,993
  • 17
  • 57
  • 104
  • 1
    Facebook is special. Facebook integration was added as part of iOS6, both across the device and in Social.framework. – Brian Nickel Jan 29 '14 at 16:56

1 Answers1

1

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.

Neru
  • 679
  • 6
  • 19