contacts

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package contacts reads and changes the phone's contacts.

nimbus native plugin add contacts

c, err := contacts.Pick(ctx)                // no permission: they choose one
saved, err := contacts.Add(ctx, cafe)       // no permission: they see it first

ok, err := contacts.Request(ctx)
all, err := contacts.List(ctx)
id, err := contacts.Create(ctx, cafe)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(ctx context.Context, c Contact) (bool, error)

Add opens the system's new contact screen, filled in. It needs no permission, because they see it and save it themselves. It's true if they saved it; Android can't always tell, so there it's true once the screen closes.

func Create

func Create(ctx context.Context, c Contact) (string, error)

Create saves a new contact with no screen. Call Request first, and tell them: it's their address book.

func Delete

func Delete(ctx context.Context, id string) error

Delete removes a contact.

func Request

func Request(ctx context.Context) (bool, error)

Request asks to read and change the contacts, once.

func Update

func Update(ctx context.Context, c Contact) error

Update replaces a contact's name, phones and emails. Anything else about them is kept.

Types

type Contact

type Contact struct {
	ID     string   `json:"id"`     // for Update and Delete; set by List
	Name   string   `json:"name"`   // their full name
	Phones []string `json:"phones"` // their phone numbers
	Emails []string `json:"emails"` // their email addresses
}

Contact is a person.

func List

func List(ctx context.Context) ([]Contact, error)

List returns every contact. Call Request first.

func Pick

func Pick(ctx context.Context) (Contact, error)

Pick opens the system's contact picker. It needs no permission, because the app only gets the one chosen. It fails with plugin.Cancelled if they back out.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL