React Native: Add custom application functionality to Native Contacts Application

937 Views Asked by At

I have tried doing some research around this, but seem to keep getting Whatsapp FAQ's.

When I install Whatsapp on my Android device, then

  • Go to my Android contacts list.
  • Select a User.

I get a Whatsapp Badge on contacts, and there is call or message action, but may need a different use case in my app. How do I achieve this on React Native? Will it be possible on iOS?

I imagine its possible since Facebook uses RN for development?

enter image description here

(edit)

I did some digging and noticed that in he event I have multiple chat apps and view "Linked Contacts" its shows all the chat apps as linked contacts of each user on their platforms not sure if this provides more clarity.

Are they just searching my contact lists and linking that contact to the same copy of the contact they have? If so how would I do this?

1

There are 1 best solutions below

3
On

This is not RN related.

Your RN app will need to include some Java components to support this, including a SyncAdapter.

Basically you need to go over the existing list of contacts on the device, and for each contact you wish to add custom-actions to, you'll create a new RawContact for your app and aggregate it with the existing contact so it'll be added to the existing one.

That new RawContact needs to include custom mimetype actions with instructions to the contacts app how to present your custom action and which intent to launch when it's clicked, see the following resources:

  1. https://stackoverflow.com/a/42642971/819355
  2. https://stackoverflow.com/a/42005334/819355
  3. https://developer.android.com/training/sync-adapters/creating-sync-adapter
  4. http://blog.udinic.com/2013/07/24/write-your-own-android-sync-adapter/
  5. http://blog.udinic.com/2013/04/24/write-your-own-android-authenticator/