Git Product home page Git Product logo

flutter_contact's Introduction

flutter_contact

pub package Coverage Status

A Flutter plugin to access and manage the device's native contacts.

Usage

To use this plugin, add flutter_contact as a dependency in your pubspec.yaml file.
For example:

dependencies:  
    flutter_contact: ^0.6.1

Permissions

Android

Add the following permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_CONTACTS" />  
<uses-permission android:name="android.permission.WRITE_CONTACTS" />  

iOS

Set the NSContactsUsageDescription in your Info.plist file

<key>NSContactsUsageDescription</key>  
<string>Your description of why you are requesting permissions.</string>  

Note
flutter_contact does not handle the process of asking and checking for permissions. To check and request user permission to access contacts, try using the following plugins: flutter_simple_permissions or permission_handler.

If you do not request user permission or have it granted, the application will fail. For testing purposes, you can manually set the permissions for your test app in Settings for your app on the device that you are using. For Android, go to "Settings" - "Apps" - select your test app - "Permissions" - then turn "on" the slider for contacts.

Unified vs Single contacts

There are two main entry points into the application: SingleContacts and UnifiedContacts. These share the same API and most of the underlying code, however:

  • SingleContacts will interact with the unlinked raw contacts on each platform
  • UnifiedContacts will interact with linked/aggregated contacts on each platform.

Memory Efficiency

This plugin tries to be memory and cpu friendly. It avoid loading your entire address book into memory, but rather provides some ways to iterate over contacts in a more memory friendly way:

Stream

import 'package:flutter_contact/contact.dart';  

// By default, this will loop through all contacts using a page size of 20.
await Contacts.streamContacts().forEach((contact) {
    print("${contact.displayName}");
});

// You can manually adjust the buffer size
Stream<Contact> contacts = await Contacts.streamContacts(bufferSize: 50);

Paging List

The second option is a paging list, which also uses an underlying page buffer, but doesn't have any subscriptions to manage, and has some other nice features, like a total count

import 'package:flutter_contact/contact.dart';

final contacts = Contacts.listContacts();
final total = await contacts.length;

// This will fetch the page this contact belongs to, and return the contact
final contact = await contacts.get(total - 1);

while(await contacts.moveNext()) {
    final contact = await contacts.current;
}

Example

// Import package  
import 'package:flutter_contact/contact.dart';  
  
// Get all contacts on device as a stream
Stream<Contact> contacts = await Contacts.streamContacts();  

// Get all contacts without thumbnail(faster)
Iterable<Contact> contacts = await Contacts.streamContacts(withThumbnails: false);
  
// Get contacts matching a string
Stream<Contact> johns = await Contacts.streamContacts(query : "john");

// Add a contact  
// The contact must have a firstName / lastName to be successfully added  
await Contacts.addContact(newContact);  
  
// Delete a contact
// The contact must have a valid identifier
await Contacts.deleteContact(contact);  

// Update a contact
// The contact must have a valid identifier
await Contacts.updateContact(contact);

/// Lazily fetch avatar data without caching it in the contact instance.
final contact = Contacts.getContact(contactId);
final Uint8List avatarData = await contact.getOrFetchAvatar();

Credits

This plugin was originally a fork of the https://pub.dev/packages/flutter_contact plugin, but has effectively been mostly rewritten (in part because it was ported to kotlin)

flutter_contact's People

Contributors

deepak786 avatar emekalites avatar ericmartineau avatar gwxtr avatar mrharcombe avatar rmortes avatar sami-kouatli-act avatar suztomo avatar tkeithblack avatar worldbucks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_contact's Issues

Error

Hi,

Nice work. Really appreciate your work.

I am getting below dump when trying to update a contact.

Attempt to invoke interface method 'int org.joda.time.format.InternalParser.parseInto(org.joda.time.format.DateTimeParserBucket, java.lang.CharSequence, int)' on a null object reference, java.lang.NullPointerException: Attempt to invoke interface method 'int org.joda.time.format.InternalParser.parseInto(org.joda.time.format.DateTimeParserBucket, java.lang.CharSequence, int)' on a null object reference, null))

PlatformException was thrown: PlatformException(notFound, in method getContact: Expected a single result for

I/flutter ( 4900): Flutter error caught by Crashlytics plugin:
I/flutter ( 4900): ══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════
I/flutter ( 4900): The following PlatformException was thrown:
I/flutter ( 4900): PlatformException(notFound, in method getContact: Expected a single result for contact 824, but
I/flutter ( 4900): instead found 0, co.sunnyapp.flutter_contact.MethodCallException: notFound: in method getContact:
I/flutter ( 4900): Expected a single result for contact 824, but instead found 0)
I/flutter ( 4900):
I/flutter ( 4900): When the exception was thrown, this was the stack:
I/flutter ( 4900): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
I/flutter ( 4900): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
I/flutter ( 4900):
I/flutter ( 4900): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
I/flutter ( 4900): #3 ContactService.addContact (package:flutter_contact/contacts.dart:180:32)
I/flutter ( 4900): #4 addContact (package:barcodeapp/utils/utils.dart:414:29)
I/flutter ( 4900):
I/flutter ( 4900): #5 ContactCodeListTile.build. (package:barcodeapp/widget/qr_barcode/qrcode_valuetype/common_widget.dart:257:33)
I/flutter ( 4900):
I/flutter ( 4900): #6 ContactCodeListTile.build. (package:barcodeapp/widget/qr_barcode/qrcode_valuetype/common_widget.dart)
I/flutter ( 4900): #7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
I/flutter ( 4900): #8 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:862:36)
I/flutter ( 4900): #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
I/flutter ( 4900): #10 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
I/flutter ( 4900): #11 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
I/flutter ( 4900): #12 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:254:7)
I/flutter ( 4900): #13 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
I/flutter ( 4900): #14 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
I/flutter ( 4900): #15 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
I/flutter ( 4900): #16 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
I/flutter ( 4900): #17 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
I/flutter ( 4900): #18 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
I/flutter ( 4900): #22 _invoke1 (dart:ui/hooks.dart:275:10)
I/flutter ( 4900): #23 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)
I/flutter ( 4900): (elided 3 frames from dart:async)
I/flutter ( 4900): ════════════════════════════════════════════════════════════════════════════════════════════════════
E/CrashlyticsPlugin( 4900): Unable to generate stack trace element from Dart side error.
I/flutter ( 4900): firebase_crashlytics: Error reported to Crashlytics.

contact is added but plugin is throwing exception

trying to add Contact using Contacts.addContact(contact); using flutter_contact: ^0.6.4

  var contact =
      Contact(givenName: 'HHH', displayName: 'dd', identifier: '234234');
      Contacts.addContact(contact);

getting below error but contact is being added see below screen pls fix it

{identifier: 234234, displayName: dd, givenName: HHH, middleName: null, familyName: null, lastModified: null, unifiedContactId: null, singleContactId: null, otherKeys: {}, prefix: null, suffix: null, company: null, jobTitle: null, emails: [], phones: [], dates: [], socialProfiles: [], urls: [], postalAddresses: [], avatar: null, note: null}

I/flutter ( 5100): ══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════
I/flutter ( 5100): The following PlatformException was thrown:
I/flutter ( 5100): PlatformException(notFound, in method getContact: Expected a single result for contact
I/flutter ( 5100): ContactKeys(mode=UNIFIED, unifiedContactId=1226, singleContactId=null, lookupKey=null), but instead
I/flutter ( 5100): found 0, co.sunnyapp.flutter_contact.MethodCallException: notFound: in method getContact: Expected a
I/flutter ( 5100): single result for contact ContactKeys(mode=UNIFIED, unifiedContactId=1226, singleContactId=null,
I/flutter ( 5100): lookupKey=null), but instead found 0)

image

Compile failed

run flutter pub upgrade then flutter build apk --profile --flavor offical

flutter_contact: 0.8.1+2
Flutter Version: Any version.


/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart:306:12: Error: The argument type 'Iterable<Item>' can't be assigned to the parameter type 'List<Item>?'.
 - 'Iterable' is from 'dart:core'.
 - 'Item' is from 'package:flutter_contact/contact.dart' ('/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart').
 - 'List' is from 'dart:core'.
          .notNull(),
           ^
/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart:308:12: Error: The argument type 'Iterable<Item>' can't be assigned to the parameter type 'List<Item>?'.
 - 'Iterable' is from 'dart:core'.
 - 'Item' is from 'package:flutter_contact/contact.dart' ('/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart').
 - 'List' is from 'dart:core'.
          .notNull(),
           ^
/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart:313:12: Error: The argument type 'Iterable<Item>' can't be assigned to the parameter type 'List<Item>?'.
 - 'Iterable' is from 'dart:core'.
 - 'Item' is from 'package:flutter_contact/contact.dart' ('/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart').
 - 'List' is from 'dart:core'.
          .notNull(),
           ^
/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart:316:9: Error: The argument type 'Iterable<ContactDate>' can't be assigned to the parameter type 'List<ContactDate>?'.
 - 'Iterable' is from 'dart:core'.
 - 'ContactDate' is from 'package:flutter_contact/contact.dart' ('/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart').
 - 'List' is from 'dart:core'.
      ].notNull(),
        ^
/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart:320:9: Error: The argument type 'Iterable<PostalAddress>' can't be assigned to the parameter type 'List<PostalAddress>?'.
 - 'Iterable' is from 'dart:core'.
 - 'PostalAddress' is from 'package:flutter_contact/contact.dart' ('/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart').
 - 'List' is from 'dart:core'.
      ].notNull(),
        ^
/C:/Users/Dylan/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_contact-0.8.1+2/lib/contact.dart:561:7: Error: A value of type 'Iterable<Map<String, String>>' can't be returned from a function with return type 'List<Map<Stri
ng, String>>'.
 - 'Iterable' is from 'dart:core'.
 - 'Map' is from 'dart:core'.
 - 'List' is from 'dart:core'.
    ].notNull();
      ^


FAILURE: Build failed with an exception.

* Where:
Script 'D:\Development\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildOfficalProfile'.
> Process 'command 'D:\Development\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1


Add contacts through native form

Thank you for a great package! ❤️
Does it support adding contacts via device form?
See pull request #69 in flutter_contacts package for reference.
It would be awesome to have such feature.

"withThumbnails: false" doesn't work

We are using flutter_contact: ^0.8.1+2 as follows:

var contacts = Contacts.streamContacts(
    withThumbnails: false,
    withHiResPhoto: false,
    withUnifyInfo: false,
    bufferSize: CONTACTS_BUFFER_SIZE,
  );

But returns contacts still return the thumbnail data.

Are we missing something here or is it a bug?

Error reporting on unexpected format of the contact data

When thinking about #31, this library treats the unexpected data as null. I dug the source code and identified that it was value key that was unexpected to this library when I use BlackBerry Priv (Android 6.0.1). This can be fixed by checking the value key in the map in addition to existing date key.

However, this fix only applies to the devices that return value and date for the dates. There could be other type of devices that return data in a different format. If I'm lucky, my user who suffer from the glitch would communicate to me about the glitch and I happen to have the same device as them to debug further to find the unexpected data. It's very unlikely.

I need a way to troubleshoot the unexpected data from my users' devices, without requiring them a special effort. Here are few options I thought of:

Option 1: Throw an exception upon unexpected data

Currently it return null for unexpected date map (see the screenshot in #31). I thought about throwing an exception rather than returning null. I can catch the exception from the library and send some message to me via Firebase Crashlytics.

However, this option might crash apps that use this library, even when the unexpected data is unused. Furthermore, one unexpected data prevents a user of app from listing contacts.

Option 2: Add a handler for unexpected data

How about this library taking a handler for error reporting on unexpected format of the contract data? I have an opportunity to report error while the library continue to work only except the unexpected data..

The idea is when initializing ContactService in this library, it would optionally take a handler (a function) with type void Function(Exception unexpectedDataException). When this library hits an unexpected data, it calls the handler and continues processing next data. I would pass a call to Firebase Crashlytics. This way, the library continues to work for users and I can get understanding of unexpected format of users data and devices.

final ContactService _contactService = UnifiedContacts(errorReporting: (Exception exception) {
    try {
      throw exception;
    } on Exception catch (error, stacktrace) {
      FirebaseCrashlytics.instance.recordError(error, stacktrace);
    }
  })

Get modified contacts information

Hi All,

I'm looking for an efficient way get the modified contact when a ContactsChangedEvent is fired, along with its row number.

  1. Can the modified contact and its row number be added to the ContactsChangedEvent instance? (I'm assuming it can't)

-- or --

  1. Can functionality be added to sort contacts by ContactSortOrder wrapped in a ROW_NUMBER() OVER() clause, and then sorted by lastModified? - For example: https://sqliteonline.com/#fiddle=90427c060a1f2405ee1671e59ff0eb6491b5b16b2faa95704f70535a8449c234

Thanks,
Dere

label for dates on Android

Hello, on Android when using Contacts.updateContact(contact); , the labels for dates are changed / duplicated ( see the screenshot). The plugin update function after deletion and at insertion is done with date.label (.withTypeAndLabel(ItemType.event, date.label), this seems to modify the existing labels for birthday , even when the string is passed as 'Birthday' with an upper case 'B', this is still perceived by Android as a user custom label text.

Also if the contact had an anniversary event date already set, after update the anniversary duplicates the event due to the label mismatch.
This can be reproduced by updating a field for an existing contact ( any field) which already has a date set for an event on android 10 or 11 emulator.

According to the link ,it seems that the type of data needs to be passed as an integer ( like EVENT.LABEL.TYPE_BIRTHDAY for instance).

Screenshot 2021-04-08 at 12 24 40

Please update dependencies for compatibility with Flutter 2.0/null safety packages

I've been upgrading many packages to the null safety versions. I ran across a couple of dependencies in flutter_contacts that cause conflicts. I think these would be very easy to bump.

First, there is uuid ^2.2.2 which needs to update to uuid: ^3.0.1.
NOTE: I noticed in the code that the only reference to UUID is in your test code, so you can probably move it out of the main dependencies section.

Second is updating from sunny_dart: ^0.5.8+5 to sunny_dart: ^0.6.0+4

Thanks for providing this very useful package!

Modify Readme Documentation

Readme specifies ->
import 'package:flutter_contact/flutter_contact.dart';
it should be
import 'package:flutter_contact/contact.dart';

'package:sunny_dart/time/date_components.dart': Failed assertion: line 48 pos 12: 'input != null': Input must not be null

         final contacts = Contacts.listContacts(
          sortBy: ContactSortOrder.firstName(),
          withHiResPhoto: false,
          withThumbnails: false,
          // bufferSize: 20
        );
        final total = await contacts.length;
        int counter = 1;
        while (counter < total - 1) {
          // print(counter);
          try {
            final contact = await contacts?.get(counter) ?? null;
            print((contact?.identifier ?? "") + ":" + contact?.displayName);
          } catch (error) {
            print(error);
          }
          counter++;
        }

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: 'package:sunny_dart/time/date_components.dart': Failed assertion: line 48 pos 12: 'input != null': Input must not be null

I am getting the error randomly, irrespective of how I sort it or what function I use (streamContacts).

There is no issue with the permission. I used permission_handler to get the contact permission. I have update AndroidMainfest.xml file but still getting the error.

What am I missing?

Block contact

Hi,

I need to block contact.
Any way to do this?

Thank you!

openContactInsertForm only parsing phone number

image
WhatsApp Image 2021-02-24 at 04 52 36
When i call "openContactInsertForm " and i pass it my contact object, it only parse the phone number and the email, other fields (displayName, givenName , familyName...) are not parsed, even with your library's example project.

Socialprofiles not working

Hi, i try to write social profiles,

Future buildContact() async {
Contact internal = new Contact();
PostalAddress address = PostalAddress(label: 'Home');
address.street = AddressController.value.text;
address.city = CityController.value.text;
internal.emails = [
Item(label: 'Personal', value: EmailController.value.text)
];
internal.socialProfiles = [
Item(label: 'newsocial', value: IDController.value.text)
];
internal.givenName = NameController.value.text;
internal.familyName = SurnameController.value.text;
internal.phones = [
Item(label: 'Mobile', value: TelephoneController.value.text)
];
address.country = StateController.value.text;
internal.urls = [
Item(label: 'Website', value: WebsiteController.value.text)
];
internal.postalAddresses = [address];
return internal;
}

it write ALL fields, but not the social profiles into phone, and, if you write a social profile into contact, the get method have all fields, but social profile... in empty!

Contacts are returned in random order

Hello. I tried to use ordering but it returns contacts with some unpredictable order for me. Finally, I changed in ContentResolver.queryContacts query to

return query(ContactsContract.Data.CONTENT_URI, projections, selection, selectionArgs, "upper("+ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + ") ASC")

copied from https://stackoverflow.com/a/24489525/716027
I think ordering by display name is the most common case. Can you add it?

A compilation error

When I'm adding plugin to my project I received a compilation error.
flutter_contact-0.6.4+2/android/src/main/kotlin/co/sunnyapp/flutter_contact/FlutterContactPlugin.kt: (177, 47): Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Uri?

I changed string 177 to
val contactId = saveResult.first().uri?.lastPathSegment?.toLong() locally.

Please make changes in repo.
FYI. I use Kotlin 1.3.50

flutter_contact adds un-necessary api bindings

After adding the flutter_contact package when uploading my app to the App Store it was rejected with the following messages:

Dear Developer,

We identified one or more issues with a recent delivery for your app, "Share vCard" 1.1.2 (29). Please correct the following issues, then upload again.

ITMS-90683: Missing Purpose String in Info.plist - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSCalendarsUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

ITMS-90683: Missing Purpose String in Info.plist - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSAppleMusicUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

ITMS-90683: Missing Purpose String in Info.plist - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSMotionUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

ITMS-90683: Missing Purpose String in Info.plist - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSSpeechRecognitionUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

ITMS-90683: Missing Purpose String in Info.plist - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSLocationWhenInUseUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

None of these messages I got prior to adding the library. While I can fix the problems by adding the required strings, IMHO the library should not use these APIs in the first place as they are not needed for the library to work.

UIKit.UIActivityIndicatorView:6:12: note: 'init(style:)' was introduced in Swift 4.2

Installed flutter_contact 0.5.2 and received Swift compile error:

UIKit.UIActivityIndicatorView:6:12: note: 'init(style:)' was introduced in Swift 4.2
public init(style: UIActivityIndicatorViewStyle)

To address this I manually opened my xCode project and updated flutter_contact to use Swift Language 4.2. Probably need to update the flutter_contact.podspec file.

Why iOS 12?

Why is iOS 12 the deployment minimum requirement?

Incompatibility with flutter_driver due to conflict with intl version

flutter_driver on stable branch is expecting intl 0.16.0, and flutter_contact is expecting ^0.16.1.

Because every version of flutter_driver from sdk depends on intl 0.16.0 and flutter_contact >=0.5.1 depends on intl ^0.16.1, flutter_driver from sdk is in
compatible with flutter_contact >=0.5.1.
So, because contax depends on both flutter_contact ^0.5.3 and flutter_driver any from sdk, version solving failed.
Running "flutter pub upgrade" in contax...
pub upgrade failed (1; So, because contax depends on both flutter_contact ^0.5.3 and flutter_driver any from sdk, version solving failed.)

ios contact note don't show as expect.

edit a contact with note:

image

and not show on contact info written by flutter_contact.

image

flutter code similar to flutter_contact sample demo.

expect way to solve it or the reason about it?

no callback on Contacts.addContact(contact);

In my project, when I call Contacts.addContact(contact), it is working ,but whether I use await or then, the code below / call back funtion is not being called. Also, no message is given in the console

I wounder if you could check it.

void xxx() async {
 print('start');
await Contacts.addContact(contact);
print('success');
}

Duplicate imports due to linked contacts for android

Since flutter_contact (and contact_service) both use just the contact id on android they will pull in multiple contacts with the same id when contacts are linked. Are there any issues using the lookupKey instead? Anyone else here interested in this that would be willing to cooperate with me on a fix and a PR?

ContactDate not working in Android ("value" field v.s. "date" field)

Thank you for a great library!

I use my Android phone (BlackBerry Priv; Android 6.0.1) to test my app that use flutter_contact 0.6.4. The app cannot get the birthday of people in the "BlackBerry Hub+ Contacts" (version 2.2034.1.8456, the default app pre-installed in the device). It has null for Contact.dates.

I dug the flutter_contact's source code and found ContactDate.fromMap is expecting "date" key (_kdate) in a map but the map actually holds "value" key (screenshot below).

Screen Shot 2020-10-30 at 8 24 06 PM

Can this library support such contact? I'm happy to submit a pull request to support this.

Trying to build the example project for Android

I had to add android.useAndroidX=true to example/android/gradle.properties.

> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     /Users/suztomo/Documents/flutter_contact_sunnyapp/example/android/app/src/main/AndroidManifest.xml:17:5-36:19: AAPT: error: resource mipmap/ic_launcher (aka co.sunnyapp.flutter_contact_example:mipmap/ic_launcher) not found.

     /Users/suztomo/Documents/flutter_contact_sunnyapp/example/android/app/src/main/AndroidManifest.xml:20:9-34:20: AAPT: error: resource style/LaunchTheme (aka co.sunnyapp.flutter_contact_example:style/LaunchTheme) not found.

     /Users/suztomo/Documents/flutter_contact_sunnyapp/example/android/app/src/main/AndroidManifest.xml:27:13-29:66: AAPT: error: resource drawable/launch_background (aka co.sunnyapp.flutter_contact_example:drawable/launch_background) not found.

Is avatar implemented?

I'm unable to set the avatar for any contact. I'm taking a look at the source code, and can't fine where exactly is the avatar saved. Is it implemented?

Android example project is outdated

I cannot build the example project for my Android phone (Android 6.0.1). It seems that I can use the output from the latest flutter create command outputs to make it work.

NumberFormatException while loading contact with wrong birthday date format

Hello.
We use your plugin in our app and recently faced with this issue.
A few of our users told us that they get error while loading contact list.
In our code we see PlatformException that points to NumberFormatException while parsing "6 июля 1983".

How to reproduce:

  1. Go to https://contacts.google.com
  2. For any contact set birthday like "6 июля 1983"
  3. Wait for contacts synced to android device
  4. Try load Contacts from flutter app
  5. Get NumberFormatException

Android Query by phone number

Hey, I am using the

Contacts.streamContacts(
    query: phoneNumber,
    phoneQuery: true)

method, and I am wondering whether this is working on Android? On iOS it seems to work without any issues but I cannot find a format for phoneNumber to make it work on Android.

See image for what I am testing.

Screenshot 2021-03-11 at 10 46 45

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/OffsetDateTime

Is this plugin require minSdkVersion 26? Can you make it compatible with minSdkVersion 21?

E/AndroidRuntime(30313): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/OffsetDateTime;
E/AndroidRuntime(30313): 	at co.sunnyapp.flutter_contact.Contact.<init>(Contact.kt:33)
E/AndroidRuntime(30313): 	at co.sunnyapp.flutter_contact.Contact.<init>(Contact.kt:45)
E/AndroidRuntime(30313): 	at co.sunnyapp.flutter_contact.Resolver_extensionsKt.toContactList(resolver-extensions.kt:79)
E/AndroidRuntime(30313): 	at co.sunnyapp.flutter_contact.FlutterContactPlugin.getContacts(FlutterContactPlugin.kt:112)
E/AndroidRuntime(30313): 	at co.sunnyapp.flutter_contact.FlutterContactPlugin.access$getContacts(FlutterContactPlugin.kt:29)
E/AndroidRuntime(30313): 	at co.sunnyapp.flutter_contact.FlutterContactPlugin$onMethodCall$1.invoke(FlutterContactPlugin.kt:44)
E/AndroidRuntime(30313): 	at co.sunnyapp.flutter_contact.FlutterContactPlugin$onMethodCall$1.invoke(FlutterContactPlugin.kt:29)
E/AndroidRuntime(30313): 	at co.sunnyapp.flutter_contact.PluginStubsKt$asyncTask$task$1.doInBackground(PluginStubs.kt:12)
E/AndroidRuntime(30313): 	at co.sunnyapp.flutter_contact.PluginStubsKt$asyncTask$task$1.doInBackground(PluginStubs.kt:9)
E/AndroidRuntime(30313): 	at android.os.AsyncTask$2.call(AsyncTask.java:305)
E/AndroidRuntime(30313): 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/AndroidRuntime(30313): 	... 4 more
E/AndroidRuntime(30313): Caused by: java.lang.ClassNotFoundException: Didn't find class "java.time.OffsetDateTime" on path: DexPathList[[zip file "/data/app/io.thedocs.android.chatChecklist-2/base.apk"],nativeLibraryDirectories=[/data/app/io.thedocs.android.chatChecklist-2/lib/arm64, /data/app/io.thedocs.android.chatChecklist-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
E/AndroidRuntime(30313): 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(30313): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
E/AndroidRuntime(30313): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

Any plan to update deps and support null safety?

I am getting a conflict with:

Because innenu depends on flutter_contact ^0.6.4 which depends on logging ^0.11.4, logging ^0.11.4 is required.

So, because innenu depends on logging ^1.0.0, version solving failed.
pub get failed (1; So, because innenu depends on logging ^1.0.0, version solving failed.)
exit code 1

I did not checkout, but probably logging started null safety in 1 and my other plugins is requiring it.

LastModified is NULL on iOS

Hi @ericmartineau,

The value of lastModified is also NULL on iOS - I'm using an iPhone 5s running iOS 12.4.8.

[✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.6 19G2021, locale en-GB)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.49.3)
[✓] Connected device (2 available)

• No issues found!

Thanks,
Dere

Each page returns bufferSize + 1 contacts

Hello,

When setting a bufferSize for listContacts() each page returns bufferSize+1 contacts. For example, the code below will return a list of 6 contacts instead of 5, with the 6th contact containing mostly blank fields.

This is being run on Android 10 (API 29).

final int bufferSize = 5;
final pagingList = Contacts.listContacts(bufferSize: bufferSize);

if(await pagingList.moveNextPage()) {
    final List<Contact> contacts = await pagingList.currentPage;
    for(int i =0; i < contacts.length; ++i) {
        final Contact contact = contacts[i];
        print('CONTACT ($i):\n${contact.toMap()}\n\n');
    }
}

flutter doctor

[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale en-GB)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.7)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.49.1)
[✓] Connected device (1 available) - Samsung Galaxy S9+

• No issues found!

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.