简体   繁体   English

React Native:向本机联系人应用程序添加自定义应用程序功能

[英]React Native: Add custom application functionality to Native Contacts Application

I have tried doing some research around this, but seem to keep getting Whatsapp FAQ's.我曾尝试对此进行一些研究,但似乎不断收到 Whatsapp 常见问题解答。

When I install Whatsapp on my Android device, then当我在 Android 设备上安装Whatsapp时,然后

  • Go to my Android contacts list.转到我的 Android 联系人列表。
  • 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.我在联系人上获得了Whatsapp 徽章,并且有callmessage操作,但我的应用程序中可能需要不同的用例。 How do I achieve this on React Native?我如何在 React Native 上实现这一点? Will it be possible on iOS?在iOS上有可能吗?

I imagine its possible since Facebook uses RN for development?我想这是可能的,因为Facebook使用 RN 进行开发?

在此处输入图片说明

(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?如果是这样,我将如何做到这一点?

This is not RN related.这与RN无关。

Your RN app will need to include some Java components to support this, including a SyncAdapter.您的 RN 应用程序需要包含一些 Java 组件来支持这一点,包括 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.基本上,您需要查看设备上现有的联系人列表,对于您希望向其添加自定义操作的每个联系人,您将为您的应用创建一个新的 RawContact 并将其与现有联系人聚合,以便添加到现有的。

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:新的 RawContact 需要包含自定义 mimetype 操作以及联系人应用程序的说明如何呈现您的自定义操作以及单击时要启动的意图,请参阅以下资源:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM