-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First explainer draft for Contacts Share API #844
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Share Contacts for Installed Web Apps | ||
|
||
Authors: [Diego Gonzalez](https://github.com/diekus) | ||
|
||
## Status of this Document | ||
This document is a starting point for engaging the community and standards bodies in developing collaborative solutions fit for standardization. As the solutions to problems described in this document progress along the standards-track, we will retain this document as an archive and use this section to keep the community up-to-date with the most current standards venue and content location of future work and discussions. | ||
* This document status: **Active** | ||
* Expected venue: [W3C Web Incubator Community Group](https://wicg.io/) | ||
* **Current version: this document** | ||
|
||
## Introduction | ||
|
||
For modern web applications like social networks and instant messaging, contacts are a fundamental part of the app itself. These contacts are specfic to the application, but the platform/OS can benefit from exposing them in different people related surfaces. Contact Sharing for installed web applications allows web apps to surface contacts in relevant UX on the underlying OS. One example can be sharing. Different platforms have different share UX, and some of these UXs include a list of frequent contacts that make sharing content faster with people the user interacts with frequently. | ||
|
||
## Goals | ||
|
||
* Allow installed web applications to participate in contacts/people UX across different platforms. | ||
|
||
## Non-goals | ||
|
||
* | ||
|
||
## Use Cases | ||
|
||
### Integrating with platform's Share UX | ||
|
||
A user decides to share content and opens the Share UX on the platform. They are presented with their frequent contacts on several apps. They can click on a contact to share the content with that contact. Overall, this represents a faster an easier way to share content. This is also behaviour that is present in several desktop and mobile platforms already. It saves the steps of having to open the app and look for the contact you will be sharing with. The following image shows how the share UX shows contacts on Windows and Android. Notice that each contact is associated to a specific application, as represented by a small app-icon on the bottom-right corner of the displayed contact. | ||
|
||
![Share UX on multiple platforms](contactShare.png) | ||
|
||
## Proposed solution | ||
|
||
The proposed solution is a promise-based method that works in scope of an installed web application to share a list of contacts with the underlying platform. This gets the contacts-per-app into the OS. The other part of the feature is akin to Web Share Target, except it is targeted directly at a specific contact. | ||
|
||
### Providing Contacts to the platform | ||
|
||
`navigator.shareContacts(<contacts>);` | ||
|
||
The method receives contacts as a list of JSON objects. Each object must have at least an `id`, `firstName` and `displayPicture`. Optionally, the contact can have a `lastName`, `rank` and a list of `phones` and `emails`. | ||
|
||
#### Contact detailed fields | ||
|
||
* `id`: unique id for the contact. | ||
* `firstName`: Contact's first name(s). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A firstName/lastName split only makes sense in some parts of the world, so typically we try for more generic options. What about starting with only a required 'name' field, and then additional optional variants could be added in the future if needed. For some context to reference: The Android equivalent of this API uses a ShortLabel and LongLabel. The Windows version supports FirstName and LastName, but also supports DisplayName(Override), HonorificNamePrefix/Suffix, MiddleName, Name, Nickname, YomiFamilyName, and YomiGivenName (and a slew of accessors for having the OS smartly select and combine these for you). |
||
* `displayPicture`: url to the display picture of the contact. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For versatility (and consistency with the ContactInfo object) what about a Blob instead of a url? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that was a consideration I thought about. I left it as url thinking in having a blob url with the image. I will explicitly call out the blob part in the explainer. |
||
* `lastName`: Contact's last name(s). | ||
* `rank`: integer that defines the rank or precedence that a contact has in the list. This could be used by the platform to display top contacts first. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading the Windows API I see they expose a 'rank' field much like this, but the Android equivalent takes a simpler approach of requiring the provided list of contacts to be ordered in terms of rank (without there being an explicit rank field). Though it's not called out, I expect the Windows side may also give preference to the first provided contact over the last provided contact (when no rank is specified). What about starting with the simpler approach of just declaring the Contacts list as ordered by rank, and then in the future if a need for more complex ranking arises (e.g. 2 contacts sharing a rank, or bigger gaps in rank), the API can be expanded to take an optional 'rank'. |
||
* `phones`: list of strings that represent phone numbers. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency with the ContactInfo object, what about 'tels'. Or maybe naming these singularly, and simply accepting a list? |
||
* `emails`: list of strings that represent email addresses. | ||
|
||
```json | ||
{ | ||
"id" : "contact_id_1", | ||
"firstName" : "John", | ||
"lastName" : "Doe", | ||
"displayPicture" : "https://app.com/imgs/usrs/contactPic.jpg", | ||
"rank" : 1, | ||
"phones" : ["(+44)7123456789"], | ||
"emails" : ["[email protected]", "[email protected]"] | ||
} | ||
|
||
``` | ||
|
||
### Registering the Contact as a share target for the installed app | ||
|
||
TODO: investigate how this works on the native side | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the Windows and Android versions, it seems like the appropriate approach would be a new ShareTargetParams member. Potentially https://w3c.github.io/web-share-target/#sharetargetparams-and-its-members |
||
|
||
## Considered Alternatives | ||
|
||
### Extending the Web Share API | ||
|
||
The [Web Share API](https://w3c.github.io/web-share/) allows a web site to share content to an arbitrary destination of the user's choice. At first it was considered extending the API to insclude sharing contacts, but the scope of sharing contacts to the platform's contact repository is inherently a different one from the one Web Share solves. Additionally, this API does not resolve the second part of the feature, regarding how the web app acts when a contact is invoked from the OS surface it appears. | ||
diekus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Extending the Web Share Target API | ||
|
||
The [Web Share Target API](https://w3c.github.io/web-share-target/) allows an installed web app to register itself as a Share Target on the platform. The main use case for this feature is related to exposing contacts in the Share UX of the OS. This API does not have an imperative counterpart, and is specififed through the manifest file. Additionally, this does not cover the case of sharing contacts to the platform, only registering a share target. | ||
|
||
### Extending the Contact Picker API | ||
|
||
The `contacts` interface seems like a correct location for the `share` method, but this interface is already in use by the Contact Picker API to expose the platform's `ContactsManager`. The scope of the feature also is opposite to the one of the Contact Picker API, since this is the web app sharing to the platform and not the platform sharing to a web app. Due to scope and ergonomics, the Contact Picker API is not the right home for the feature. | ||
|
||
## Privacy and Security Considerations | ||
|
||
* **Contacts are private to the installed app that shared them only:** Contacts shared by installed apps should be private to that app only. Other applications may not see other app's contacts and these should only appear on relevant platform managed UX (such as the Share Sheet present in multiple OSs). | ||
* **Contacts are dependent on the installed app:** If the web application is uninstalled, the contacts must be deleted from the platform. | ||
|
||
## Open Questions | ||
|
||
* Should we align the content of the contcts with the information provided in the Contact Picker API? | ||
diekus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Acknowledgements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to include some of the thoughts on other non-share ways these contacts will be leveraged to see how well this API design will meet those needs. In particular I'm wondering about how an app should be indicating it supports (or doesn't support) a particular way for this information to be leveraged. (e.g. Should including a telephone number implicitly mean this app supports making phone calls to it? What about supporting making phone calls, but not supporting as a Share target, because you're only a Phone app? etc.)