listentocontacts

Last updated:

0 purchases

listentocontacts Image
listentocontacts Images
Add to Cart

Description:

listentocontacts

listentocontacts #
This plugin allows you to listen to changes to the user's contacts.
It uses a ContentObserver in Android and the NotificationCenter observer in iOS.
It does not tell you what contact has been added/edited/deleted. It only tells you that some change has been made to the cotacts.
If you want to know what change has been made, then you will have to query the contacts yourself. You may also need to maintain a copy in a local database to compare to.
Getting Started #
Install the plugin #
In your pubspec.yaml:
dependencies:
listentocontacts: ^0.0.1+5
copied to clipboard
Add the required permissions #
AndroidManifest.xml
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
copied to clipboard
Info.plist
<key>NSContactsUsageDescription</key>
<string>This app requires contacts access to function properly.</string>
copied to clipboard
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();

copied to clipboard
Initialise the listener #
Listentocontacts().onContactsChanged.listen((_) {
// do what you want to do here when your contacts have changed
});
copied to clipboard
For help getting started with Flutter, view our
online documentation, which offers tutorials,
samples, guidance on mobile development, and a full API reference.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.