listentocontacts 0.0.1+3 copy "listentocontacts: ^0.0.1+3" to clipboard
listentocontacts: ^0.0.1+3 copied to clipboard

outdated

Listen to changes to the user's contacts. This uses a ContentObserver on Android and a NotificationCenter observer on iOS. It does NOT query your contacts; only listen to changes to them.

listentocontacts #

This plugin allows you to listen to changes to the user's contacts.

It uses a ContentObserver in Android and the NotificationCenter in iOS.

Getting Started #

Install the plugin #

In your pubspec.yaml:

dependencies:  
    listentocontacts: ^0.0.1+3

Add the required permissions in the AndroidManifest.xml and Info.plist file #

<uses-permission android:name="android.permission.READ_CONTACTS" />  
<uses-permission android:name="android.permission.WRITE_CONTACTS" />  
<key>NSContactsUsageDescription</key>  
<string>This app requires contacts access to function properly.</string>  

Ask for permission #

This example uses permission_handler but you can do this however you want.

Future<PermissionStatus> _getPermission() async {
    final PermissionStatus permission = await Permission.contacts.status;
    if (permission != PermissionStatus.granted &&
        permission != PermissionStatus.denied) {
      final Map<Permission, PermissionStatus> permissionStatus =
      await [Permission.contacts].request();
      return permissionStatus[Permission.contacts] ??
          PermissionStatus.undetermined;
    } else {
      return permission;
    }
  }

final PermissionStatus permissionStatus = await _getPermission();

Initialise the listener #

Listentocontacts().onContactsChanged.listen((_) {
      // do what you want to do here when your contacts have changed
    });

Note that this plugin does not query your contacts. You can use one of the other available packages for this.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

10
likes
0
pub points
52%
popularity

Publisher

unverified uploader

Listen to changes to the user's contacts. This uses a ContentObserver on Android and a NotificationCenter observer on iOS. It does NOT query your contacts; only listen to changes to them.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on listentocontacts