├── ios ├── Assets │ └── .gitkeep ├── Classes │ ├── ContactsPlugin.h │ ├── model │ │ ├── Note.swift │ │ ├── Website.swift │ │ ├── PhoneNumber.swift │ │ ├── Relationship.swift │ │ ├── EmailAddress.swift │ │ ├── Organization.swift │ │ ├── InstantMessagingAccount.swift │ │ ├── Address.swift │ │ ├── Contact.swift │ │ └── extensions │ │ │ └── ContactExtensions.swift │ ├── strategies │ │ ├── ContactStrategy.swift │ │ └── ContactStoreStrategy.swift │ ├── ContactsPlugin.m │ ├── data │ │ ├── OrganizationType.swift │ │ ├── AddressType.swift │ │ ├── EmailAddressType.swift │ │ ├── PhoneNumberType.swift │ │ ├── InstantMessagingService.swift │ │ └── RelationshipType.swift │ ├── utils │ │ └── JsonCodec.swift │ ├── SwiftContactsPlugin.swift │ └── ContactManager.swift ├── .gitignore └── contacts_plugin.podspec ├── android ├── gradle.properties ├── settings.gradle ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── kotlin │ │ └── com │ │ └── baseflow │ │ └── contactsplugin │ │ ├── models │ │ ├── Note.kt │ │ ├── Website.kt │ │ ├── Relationship.kt │ │ ├── PhoneNumber.kt │ │ ├── EmailAddress.kt │ │ ├── InstantMessagingAccount.kt │ │ ├── Organization.kt │ │ ├── Address.kt │ │ └── Contact.kt │ │ ├── data │ │ ├── OrganizationType.kt │ │ ├── AddressType.kt │ │ ├── EmailAddressType.kt │ │ ├── PhoneNumberType.kt │ │ ├── InstantMessagingService.kt │ │ └── RelationshipType.kt │ │ ├── utils │ │ └── JsonCodec.kt │ │ ├── ContactsPlugin.kt │ │ └── ContactManager.kt └── build.gradle ├── example ├── android │ ├── gradle.properties │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── app │ │ ├── .settings │ │ │ └── org.eclipse.buildship.core.prefs │ │ ├── src │ │ │ └── main │ │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values │ │ │ │ │ └── styles.xml │ │ │ │ └── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── contactspluginexample │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ ├── .classpath │ │ └── build.gradle │ ├── .gitignore │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ └── build.gradle ├── ios │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ └── project.pbxproj │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── .gitignore │ └── Podfile ├── .gitignore ├── README.md ├── .metadata ├── test │ └── widget_test.dart ├── lib │ └── main.dart └── pubspec.yaml ├── FUNDING.yml ├── CHANGELOG.md ├── .github ├── ISSUE_TEMPLATE │ ├── e-question.md │ ├── b-bug-report.md │ ├── a-regression.md │ ├── d-enhancement-proposal.md │ └── c-feature-request.md └── PULL_REQUEST_TEMPLATE.md ├── scripts ├── before_build_ipas.sh └── before_build_apks.sh ├── analysis_options.yaml ├── lib ├── models │ ├── note.dart │ ├── website.dart │ ├── relationship.dart │ ├── phone_number.dart │ ├── email_address.dart │ ├── organization.dart │ ├── instant_messaging_account.dart │ ├── address.dart │ └── contact.dart ├── utils │ └── json_codec.dart ├── contacts_plugin.dart └── data │ └── contact_enums.dart ├── .gitattributes ├── LICENSE ├── pubspec.yaml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── .editorconfig ├── README.md └── CODE_OF_CONDUCT.md /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'contacts_plugin' 2 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Baseflow 2 | custom: https://baseflow.com/contact 3 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /example/android/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /example/android/app/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir=.. 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | 9 | .flutter-plugins 10 | -------------------------------------------------------------------------------- /ios/Classes/ContactsPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface ContactsPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/models/Note.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.models 2 | 3 | class Note { 4 | var content: String = "" 5 | } -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | FLUTTER_BUILD_MODE=debug -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/models/Website.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.models 2 | 3 | class Website { 4 | var address: String = "" 5 | } -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | FLUTTER_BUILD_MODE=release -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | *.class 3 | .gradle 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /captures 10 | GeneratedPluginRegistrant.java 11 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.3 2 | 3 | * Refactored the encoding and decoding of JSON messages. 4 | 5 | ## 0.0.2 6 | 7 | * Added build configuration for the build_runner 8 | 9 | ## 0.0.1 10 | 11 | * Initial release 12 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baseflow/flutter-contacts-plugin/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # contacts_plugin_example 2 | 3 | Demonstrates how to use the contacts_plugin plugin. 4 | 5 | ## Getting Started 6 | 7 | For help getting started with Flutter, view our online 8 | [documentation](https://flutter.io/). 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Classes/model/Note.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Note.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class Note : Codable { 11 | var content : String = "" 12 | } 13 | -------------------------------------------------------------------------------- /ios/Classes/model/Website.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Website.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class Website : Codable { 11 | var address : String = "" 12 | } 13 | -------------------------------------------------------------------------------- /ios/Classes/strategies/ContactStrategy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContactStrategyProtocol.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | protocol ContactStrategy { 11 | func fetchContacts() -> [Contact]; 12 | } 13 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/models/Relationship.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.models 2 | 3 | import com.baseflow.contactsplugin.data.RelationshipType 4 | 5 | class Relationship { 6 | var label: String = "" 7 | var type: RelationshipType = RelationshipType.OTHER 8 | } -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /ios/Classes/ContactsPlugin.m: -------------------------------------------------------------------------------- 1 | #import "ContactsPlugin.h" 2 | #import 3 | 4 | @implementation ContactsPlugin 5 | + (void)registerWithRegistrar:(NSObject*)registrar { 6 | [SwiftContactsPlugin registerWithRegistrar:registrar]; 7 | } 8 | @end 9 | -------------------------------------------------------------------------------- /ios/Classes/data/OrganizationType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OrganizationType.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | enum OrganizationType : String, Codable { 11 | case work = "work" 12 | case other = "other" 13 | } 14 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/data/OrganizationType.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.data 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | enum class OrganizationType { 6 | @SerializedName("work") 7 | WORK, 8 | @SerializedName("other") 9 | OTHER 10 | } -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 09fe34708f5767e3dac6b04943677d2d8962b78c 8 | channel: dev 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Classes/data/AddressType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AddressType.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | enum AddressType : String, Codable { 11 | case home = "home" 12 | case work = "work" 13 | case other = "other" 14 | } 15 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/models/PhoneNumber.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.models 2 | 3 | import com.baseflow.contactsplugin.data.PhoneNumberType 4 | 5 | class PhoneNumber { 6 | var label: String = "" 7 | var number: String = "" 8 | var type: PhoneNumberType = PhoneNumberType.OTHER 9 | } -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/models/EmailAddress.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.models 2 | 3 | import com.baseflow.contactsplugin.data.EmailAddressType 4 | 5 | class EmailAddress { 6 | var address: String = "" 7 | var label: String = "" 8 | var type: EmailAddressType = EmailAddressType.OTHER 9 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/e-question.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: 💬 Questions and Help 4 | about: If you have questions, please use this for support 5 | --- 6 | 7 | ## 💬 Questions and Help 8 | 9 | For questions or help we recommend checking: 10 | 11 | - The [Flutter tag in Stack Overflow](https://stackoverflow.com/questions/tagged/flutter) -------------------------------------------------------------------------------- /ios/Classes/data/EmailAddressType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EmailAddressType.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | enum EmailAddressType : String, Codable { 11 | case home = "home" 12 | case work = "work" 13 | case other = "other" 14 | } 15 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/data/AddressType.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.data 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | enum class AddressType { 6 | @SerializedName("home") 7 | HOME, 8 | @SerializedName("work") 9 | WORK, 10 | @SerializedName("other") 11 | OTHER 12 | } -------------------------------------------------------------------------------- /ios/Classes/model/PhoneNumber.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneNumber.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class PhoneNumber : Codable { 11 | var label : String = "" 12 | var number : String = "" 13 | var type : PhoneNumberType = PhoneNumberType.other 14 | } 15 | -------------------------------------------------------------------------------- /ios/Classes/model/Relationship.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Relationship.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class Relationship : Codable { 11 | var label: String = "" 12 | var name: String = "" 13 | var type: RelationshipType = RelationshipType.other 14 | } 15 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/data/EmailAddressType.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.data 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | enum class EmailAddressType { 6 | @SerializedName("home") 7 | HOME, 8 | @SerializedName("work") 9 | WORK, 10 | @SerializedName("other") 11 | OTHER 12 | } -------------------------------------------------------------------------------- /ios/Classes/model/EmailAddress.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EmailAddress.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class EmailAddress : Codable { 11 | var address : String = "" 12 | var label : String = "" 13 | var type : EmailAddressType = EmailAddressType.other 14 | } 15 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/models/InstantMessagingAccount.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.models 2 | 3 | import com.baseflow.contactsplugin.data.InstantMessagingService 4 | 5 | class InstantMessagingAccount { 6 | var account: String = "" 7 | var label: String = "" 8 | var service: InstantMessagingService = InstantMessagingService.OTHER 9 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/models/Organization.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.models 2 | 3 | import com.baseflow.contactsplugin.data.OrganizationType 4 | 5 | class Organization { 6 | var contactTitle: String = "" 7 | var label: String = "" 8 | var name: String = "" 9 | var type: OrganizationType = OrganizationType.OTHER 10 | } -------------------------------------------------------------------------------- /scripts/before_build_ipas.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | brew update 3 | brew install libimobiledevice 4 | brew install ideviceinstaller 5 | brew install ios-deploy 6 | pod repo update 7 | gem update cocoapods 8 | git clone https://github.com/flutter/flutter.git $HOME/flutter 9 | export PATH=$HOME/flutter/bin:$HOME/flutter/bin/cache/dart-sdk/bin:$PATH 10 | flutter doctor 11 | flutter packages get 12 | -------------------------------------------------------------------------------- /example/android/app/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ios/Classes/model/Organization.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Organization.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class Organization : Codable { 11 | var jobTitle : String = "" 12 | var label : String = "" 13 | var name : String = "" 14 | var type : OrganizationType = OrganizationType.other 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Classes/model/InstantMessagingAccount.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InstantMessagingAccount.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class InstantMessagingAccount : Codable { 11 | var account : String = "" 12 | var label : String = "" 13 | var service : InstantMessagingService = InstantMessagingService.other 14 | } 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/b-bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: 🐛 Bug Report 4 | about: Create a report to help us fix bugs and make improvements 5 | --- 6 | 7 | ## 🐛 Bug Report 8 | 9 | 10 | 11 | ### Expected behavior 12 | 13 | ### Reproduction steps 14 | 15 | ### Configuration 16 | 17 | **Version:** 1.x 18 | 19 | **Platform:** 20 | - [ ] :iphone: iOS 21 | - [ ] :robot: Android -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/models/Address.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.models 2 | 3 | import com.baseflow.contactsplugin.data.AddressType 4 | 5 | class Address { 6 | var type: AddressType = AddressType.OTHER 7 | var label: String = "" 8 | var streetAddress: String = "" 9 | var city: String = "" 10 | var region: String = "" 11 | var country: String = "" 12 | var postalCode: String = "" 13 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/a-regression.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: 🔙 Regression 4 | about: Report unexpected behavior that worked previously 5 | --- 6 | 7 | ## 🔙 Regression 8 | 9 | 10 | 11 | ### Old (and correct) behavior 12 | 13 | ### Current behavior 14 | 15 | ### Reproduction steps 16 | 17 | ### Configuration 18 | 19 | **Version:** 1.x 20 | 21 | **Platform:** 22 | - [ ] :iphone: iOS 23 | - [ ] :robot: Android -------------------------------------------------------------------------------- /ios/Classes/model/Address.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Address.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class Address : Codable { 11 | var label : String = "" 12 | var streetAddress : String = "" 13 | var city : String = "" 14 | var region : String = "" 15 | var country : String = "" 16 | var postalCode : String = "" 17 | var type : AddressType = AddressType.other 18 | } 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/contactspluginexample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactspluginexample 2 | 3 | import android.os.Bundle 4 | 5 | import io.flutter.app.FlutterActivity 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity(): FlutterActivity() { 9 | override fun onCreate(savedInstanceState: Bundle?) { 10 | super.onCreate(savedInstanceState) 11 | GeneratedPluginRegistrant.registerWith(this) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/d-enhancement-proposal.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: 🏗 Enhancement Proposal 4 | about: Proposals for code cleanup, refactor and improvements in general 5 | --- 6 | 7 | ## 🏗 Enhancement Proposal 8 | 9 | 10 | 11 | ### Pitch 12 | 13 | 14 | 15 | ### Platforms affected (mark all that apply) 16 | - [ ] :iphone: iOS 17 | - [ ] :robot: Android -------------------------------------------------------------------------------- /ios/Classes/utils/JsonCodec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JsonCodec.swift 3 | // contacts_plugin 4 | // 5 | // Created by Maurits van Beusekom on 31/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | struct JsonCodec { 11 | private static let jsonEncoder = JSONEncoder() 12 | 13 | static func encodeToJsonString(_ objectToEncode: T) -> String? where T : Encodable { 14 | let data = try! jsonEncoder.encode(objectToEncode) 15 | return String(data: data, encoding: .utf8) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ios/Classes/data/PhoneNumberType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneNumberType.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | enum PhoneNumberType : String, Codable { 11 | case home = "home" 12 | case homeFax = "homeFax" 13 | case iphone = "iphone" 14 | case main = "main" 15 | case mobile = "mobile" 16 | case work = "work" 17 | case workFax = "workFax" 18 | case pager = "pager" 19 | case other = "other" 20 | } 21 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/c-feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: 🚀 Feature Request 4 | about: Want to see something new included in the Framework? Submit it! 5 | --- 6 | 7 | ## 🚀 Feature Requests 8 | 9 | 10 | 11 | ### Contextualize the feature 12 | 13 | 14 | ### Describe the feature 15 | 16 | 17 | ### Platforms affected (mark all that apply) 18 | - [ ] :iphone: iOS 19 | - [ ] :robot: Android -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/utils/JsonCodec.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.utils 2 | 3 | import com.google.gson.Gson 4 | import com.google.gson.GsonBuilder 5 | 6 | class JsonCodec { 7 | companion object { 8 | @JvmStatic 9 | private val gsonDecoder : Gson = GsonBuilder().enableComplexMapKeySerialization().create() 10 | 11 | 12 | @JvmStatic 13 | fun encodeToJsonString(objectToEncode: T) : String { 14 | return gsonDecoder.toJson(objectToEncode) 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /ios/Classes/data/InstantMessagingService.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InstantMessagingService.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | enum InstantMessagingService : String, Codable { 11 | case aim = "aim" 12 | case facebook = "facebook" 13 | case gaduGadu = "gaduGadu" 14 | case googleTalk = "googleTalk" 15 | case icq = "icq" 16 | case jabber = "jabber" 17 | case msn = "msn" 18 | case qq = "qq" 19 | case skype = "skype" 20 | case yahoo = "yahoo" 21 | case other = "other" 22 | } 23 | -------------------------------------------------------------------------------- /ios/Classes/data/RelationshipType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RelationshipType.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | enum RelationshipType : String, Codable { 11 | case father = "father" 12 | case mother = "mother" 13 | case parent = "parent" 14 | case brother = "brother" 15 | case sister = "sister" 16 | case child = "child" 17 | case friend = "friend" 18 | case spouse = "spouse" 19 | case partner = "partner" 20 | case assistant = "assistant" 21 | case manager = "manager" 22 | case other = "other" 23 | } 24 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://www.dartlang.org/guides/language/analysis-options 2 | analyzer: 3 | strong-mode: 4 | implicit-casts: true 5 | implicit-dynamic: true 6 | 7 | # Source of linter options: 8 | # http://dart-lang.github.io/linter/lints/options/options.html 9 | linter: 10 | rules: 11 | - always_declare_return_types 12 | - camel_case_types 13 | - empty_constructor_bodies 14 | - annotate_overrides 15 | - avoid_init_to_null 16 | - constant_identifier_names 17 | - one_member_abstracts 18 | - slash_for_doc_comments 19 | - sort_constructors_first 20 | - unnecessary_brace_in_string_interps 21 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/data/PhoneNumberType.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.data 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | enum class PhoneNumberType { 6 | @SerializedName("home") 7 | HOME, 8 | @SerializedName("homeFax") 9 | HOME_FAX, 10 | @SerializedName("iphone") 11 | IPHONE, 12 | @SerializedName("main") 13 | MAIN, 14 | @SerializedName("mobile") 15 | MOBILE, 16 | @SerializedName("pager") 17 | PAGER, 18 | @SerializedName("work") 19 | WORK, 20 | @SerializedName("workFax") 21 | WORK_FAX, 22 | @SerializedName("other") 23 | OTHER, 24 | } -------------------------------------------------------------------------------- /lib/models/note.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | /// A representation of a note that is linked to a contact. 4 | class Note { 5 | /// The string representation of the note. 6 | String content; 7 | 8 | /// Creates a new (empty) instance of the [Note] class. 9 | Note(); 10 | 11 | /// Create a new instance of the [Note] class and populates it's properties based on the supplied JSON message. 12 | factory Note.fromJson(Map json) { 13 | return Note()..content = json['content'] as String; 14 | } 15 | 16 | /// Converts the [Note] instance to a key / value map which can easily be serialized to a JSON string. 17 | Map toJson() => {'content': this.content}; 18 | } 19 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/app.flx 37 | /Flutter/app.zip 38 | /Flutter/flutter_assets/ 39 | /Flutter/App.framework 40 | /Flutter/Flutter.framework 41 | /Flutter/Generated.xcconfig 42 | /ServiceDefinitions.json 43 | 44 | Pods/ 45 | .symlinks/ 46 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.2.30' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.1.4' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /ios/Classes/SwiftContactsPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | public class SwiftContactsPlugin: NSObject, FlutterPlugin { 5 | public static func register(with registrar: FlutterPluginRegistrar) { 6 | let channel = FlutterMethodChannel(name: "flutter.baseflow.com/contacts_plugin/methods", binaryMessenger: registrar.messenger()) 7 | let instance = SwiftContactsPlugin() 8 | registrar.addMethodCallDelegate(instance, channel: channel) 9 | } 10 | 11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 12 | if call.method == "getContacts" { 13 | ContactManager.fetchContacts(result: result) 14 | } else { 15 | result(FlutterMethodNotImplemented) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### :sparkles: What kind of change does this PR introduce? (Bug fix, feature, docs update...) 2 | 3 | 4 | ### :arrow_heading_down: What is the current behavior? 5 | 6 | 7 | ### :new: What is the new behavior (if this is a feature change)? 8 | 9 | 10 | ### :boom: Does this PR introduce a breaking change? 11 | 12 | 13 | ### :bug: Recommendations for testing 14 | 15 | 16 | ### :memo: Links to relevant issues/docs 17 | 18 | 19 | ### :thinking: Checklist before submitting 20 | 21 | - [ ] All projects build 22 | - [ ] Follows style guide lines ([code style guide](https://github.com/BaseflowIT/flutter-contacts-plugin/blob/develop/CONTRIBUTING.md)) 23 | - [ ] Relevant documentation was updated 24 | - [ ] Rebased onto current develop -------------------------------------------------------------------------------- /lib/models/website.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | /// A representation of a website related to a contact. 4 | class Website { 5 | /// Represents the URL (or web address) of the website. 6 | String address; 7 | 8 | /// Creates a new (empty) instance of the [Website] class. 9 | Website(); 10 | 11 | /// Create a new instance of the [Website] class and populates it's properties based on the supplied JSON message. 12 | factory Website.fromJson(Map json) { 13 | return Website()..address = json['address'] as String; 14 | } 15 | 16 | /// Converts the [Website] instance to a key / value map which can easily be serialized to a JSON string. 17 | Map toJson() => {'address': this.address}; 18 | } 19 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/data/InstantMessagingService.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.data 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | enum class InstantMessagingService { 6 | @SerializedName("aim") 7 | AIM, 8 | @SerializedName("facebook") 9 | FACEBOOK, 10 | @SerializedName("gaduGadu") 11 | GADU_GADU, 12 | @SerializedName("googleTalk") 13 | GOOGLE_TALK, 14 | @SerializedName("icq") 15 | ICQ, 16 | @SerializedName("jabber") 17 | JABBER, 18 | @SerializedName("msn") 19 | MSN, 20 | @SerializedName("qq") 21 | QQ, 22 | @SerializedName("skype") 23 | SKYPE, 24 | @SerializedName("yahoo") 25 | YAHOO, 26 | @SerializedName("other") 27 | OTHER, 28 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/data/RelationshipType.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.data 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | enum class RelationshipType { 6 | @SerializedName("father") 7 | FATHER, 8 | @SerializedName("mother") 9 | MOTHER, 10 | @SerializedName("parent") 11 | PARENT, 12 | @SerializedName("brother") 13 | BROTHER, 14 | @SerializedName("sister") 15 | SISTER, 16 | @SerializedName("child") 17 | CHILD, 18 | @SerializedName("friend") 19 | FRIEND, 20 | @SerializedName("spouse") 21 | SPOUSE, 22 | @SerializedName("partner") 23 | PARTNER, 24 | @SerializedName("assistant") 25 | ASSISTANT, 26 | @SerializedName("manager") 27 | MANAGER, 28 | @SerializedName("other") 29 | OTHER, 30 | } -------------------------------------------------------------------------------- /ios/Classes/ContactManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContactManager.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class ContactManager : NSObject { 11 | 12 | static func fetchContacts(result: @escaping FlutterResult) { 13 | let strategy = createContactStrategy() 14 | let contacts = strategy.fetchContacts() 15 | 16 | let jsonString = JsonCodec.encodeToJsonString(contacts) 17 | result(jsonString) 18 | } 19 | 20 | private static func createContactStrategy() -> ContactStrategy { 21 | if #available(iOS 9.0, *) { 22 | return ContactStoreStrategy() 23 | } else { 24 | // TODO: Add ABAdressBook implementation (pre iOS 9.0) 25 | abort() 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/contacts_plugin.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'contacts_plugin' 6 | s.version = '0.0.3' 7 | s.summary = 'A Flutter contacts plugin which provides easy access to the platform specific address book.' 8 | s.description = <<-DESC 9 | A Flutter contacts plugin which provides easy access to the platform specific address book. 10 | DESC 11 | s.homepage = 'https://github.com/BaseflowIT/flutter-contacts-plugin' 12 | s.license = { :file => '../LICENSE' } 13 | s.author = { 'Baseflow' => 'hello@baseflow.com' } 14 | s.source = { :path => '.' } 15 | s.source_files = 'Classes/**/*' 16 | s.public_header_files = 'Classes/**/*.h' 17 | s.dependency 'Flutter' 18 | 19 | s.ios.deployment_target = '8.0' 20 | end 21 | 22 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # This file is understood by git 1.7.2+. 2 | 3 | # Windows specific files should always be crlf on checkout 4 | *.bat text eol=crlf 5 | *.cmd text eol=crlf 6 | *.ps1 text eol=crlf 7 | 8 | # Check out the following as ln always for osx/linux/cygwin 9 | *.sh text eol=lf 10 | 11 | # Opt in the following types to always normalize line endings 12 | # on checkin and always use native endings on checkout. 13 | *.config text 14 | *.cs text diff=csharp 15 | *.csproj text 16 | *.md text 17 | *.msbuild text 18 | *.nuspec text 19 | *.pp text 20 | *.ps1 text 21 | *.sln text 22 | *.tt text 23 | *.txt text 24 | *.xaml text 25 | *.xml text 26 | 27 | # Binary files 28 | *.bmp binary 29 | *.jpeg binary 30 | *.jpg binary 31 | *.nupkg binary 32 | *.png binary 33 | *.sdf binary 34 | 35 | *.java linguist-language=Dart 36 | *.kt linguist-language=Dart 37 | *.swift linguist-language=Dart 38 | *.m linguist-language=Dart 39 | *.h linguist-language=Dart 40 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter 3 | // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to 4 | // find child widgets in the widget tree, read text, and verify that the values of widget properties 5 | // are correct. 6 | 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter_test/flutter_test.dart'; 9 | 10 | import '../lib/main.dart'; 11 | 12 | void main() { 13 | testWidgets('Verify Platform version', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | await tester.pumpWidget(new MyApp()); 16 | 17 | // Verify that platform version is retrieved. 18 | expect( 19 | find.byWidgetPredicate( 20 | (Widget widget) => 21 | widget is Text && widget.data.startsWith('Running on:'), 22 | ), 23 | findsOneWidget); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /lib/utils/json_codec.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | class _JsonCodec { 4 | static T _decodeEnum(List enumValues, dynamic source) { 5 | if (source == null) { 6 | throw ArgumentError('A value must be provided. Supported values: ' 7 | '${enumValues.join(', ')}'); 8 | } 9 | return enumValues.singleWhere((e) => e.toString().split('.').last == source, 10 | orElse: () => 11 | throw ArgumentError('`$source` is not one of the supported values: ' 12 | '${enumValues.join(', ')}')); 13 | } 14 | 15 | static T _decodeNullableEnum(List enumValues, dynamic source) { 16 | if (source == null) { 17 | return null; 18 | } 19 | return _decodeEnum(enumValues, source); 20 | } 21 | 22 | static String _encodeEnum(T source) { 23 | return source.toString().split('.').last; 24 | } 25 | 26 | static String _encodeNullableEnum(T source) { 27 | if (source == null) { 28 | return null; 29 | } 30 | 31 | return _encodeEnum(source); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/models/relationship.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | /// A representation of a relation between the contact and the user. 4 | class Relationship { 5 | /// The name of the related contact. 6 | String name; 7 | 8 | /// Indicates the type of relation between the contact and the user, for example "father", "sister" or "spouse". 9 | RelationshipType type; 10 | 11 | /// Creates a new (empty) instance of the [Relationship] class. 12 | Relationship(); 13 | 14 | /// Create a new instance of the [Relationship] class and populates it's properties based on the supplied JSON message. 15 | factory Relationship.fromJson(Map json) { 16 | return Relationship() 17 | ..name = json['name'] as String 18 | ..type = 19 | _JsonCodec._decodeNullableEnum(RelationshipType.values, json['type']); 20 | } 21 | 22 | /// Converts the [Relationship] instance to a key / value map which can easily be serialized to a JSON string. 23 | Map toJson() => { 24 | 'name': this.name, 25 | 'type': _JsonCodec._encodeNullableEnum(this.type) 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Baseflow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.baseflow.contactsplugin' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.2.30' 6 | repositories { 7 | google() 8 | jcenter() 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.1.2' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | rootProject.allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'kotlin-android' 26 | 27 | android { 28 | compileSdkVersion 27 29 | 30 | sourceSets { 31 | main.java.srcDirs += 'src/main/kotlin' 32 | } 33 | defaultConfig { 34 | minSdkVersion 16 35 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 36 | } 37 | lintOptions { 38 | disable 'InvalidPackage' 39 | } 40 | } 41 | 42 | dependencies { 43 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 44 | implementation "com.google.code.gson:gson:2.8.5" 45 | } 46 | -------------------------------------------------------------------------------- /lib/models/phone_number.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | /// A representation of a telephone number for the contact. 4 | class PhoneNumber { 5 | /// A user defined label for this telephone number. 6 | String label; 7 | 8 | /// The string value of the telephone number. 9 | String number; 10 | 11 | /// Indicates the type of telephone number, for example "home", "work" or "mobile". 12 | PhoneNumberType type; 13 | 14 | /// Creates a new (empty) instance of the [PhoneNumber] class. 15 | PhoneNumber(); 16 | 17 | /// Create a new instance of the [PhoneNumber] class and populates it's properties based on the supplied JSON message. 18 | factory PhoneNumber.fromJson(Map json) { 19 | return PhoneNumber() 20 | ..label = json['label'] as String 21 | ..number = json['number'] as String 22 | ..type = 23 | _JsonCodec._decodeNullableEnum(PhoneNumberType.values, json['type']); 24 | } 25 | 26 | /// Converts the [PhoneNumber] instance to a key / value map which can easily be serialized to a JSON string. 27 | Map toJson() => { 28 | 'label': this.label, 29 | 'number': this.number, 30 | 'type': _JsonCodec._encodeNullableEnum(this.type) 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /lib/models/email_address.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | /// A representation of an email address linked to a contact 4 | class EmailAddress { 5 | /// The string representation of the email address. 6 | String address; 7 | 8 | /// A user defined label for this email address. 9 | String label; 10 | 11 | /// Indicates the type of email address, for example "home" or "work". 12 | EmailAddressType type; 13 | 14 | /// Creates a new (empty) instance of the [EmailAddress] class. 15 | EmailAddress(); 16 | 17 | /// Create a new instance of the [EmailAddress] class and populates it's properties based on the supplied JSON message. 18 | factory EmailAddress.fromJson(Map json) { 19 | return EmailAddress() 20 | ..address = json['address'] as String 21 | ..label = json['label'] as String 22 | ..type = 23 | _JsonCodec._decodeNullableEnum(EmailAddressType.values, json['type']); 24 | } 25 | 26 | /// Converts the [EmailAddress] instance to a key / value map which can easily be serialized to a JSON string. 27 | Map toJson() => { 28 | 'address': this.address, 29 | 'label': this.label, 30 | 'type': _JsonCodec._encodeNullableEnum(this.type) 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /scripts/before_build_apks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip 3 | mkdir android-sdk 4 | unzip -qq sdk-tools-linux-3859397.zip -d $HOME/android-sdk 5 | export ANDROID_HOME=$HOME/android-sdk 6 | export PATH=$HOME/android-sdk/tools/bin:$PATH 7 | mkdir -p /home/travis/.android # silence sdkmanager warning 8 | echo 'count=0' > /home/travis/.android/repositories.cfg # silence sdkmanager warning 9 | # suppressing output of sdkmanager to keep log under 4MB (travis limit) 10 | echo y | sdkmanager "tools" >/dev/null 11 | echo y | sdkmanager "platform-tools" >/dev/null 12 | echo y | sdkmanager "build-tools;26.0.3" >/dev/null 13 | echo y | sdkmanager "platforms;android-26" >/dev/null 14 | echo y | sdkmanager "extras;android;m2repository" >/dev/null 15 | echo y | sdkmanager "extras;google;m2repository" >/dev/null 16 | echo y | sdkmanager "patcher;v4" >/dev/null 17 | sdkmanager --list 18 | wget http://services.gradle.org/distributions/gradle-4.1-bin.zip 19 | unzip -qq gradle-4.1-bin.zip -d $HOME/gradle-4.1 20 | export GRADLE_HOME=$HOME/gradle-4.1 21 | export PATH=$GRADLE_HOME/bin:$PATH 22 | gradle -v 23 | git clone https://github.com/flutter/flutter.git $HOME/flutter 24 | export PATH=$HOME/flutter/bin:$HOME/flutter/bin/cache/dart-sdk/bin:$PATH 25 | flutter doctor 26 | flutter packages get -------------------------------------------------------------------------------- /lib/models/organization.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | /// A representation of an organization linked to a contact. 4 | class Organization { 5 | /// The contact's job title 6 | String jobTitle; 7 | 8 | /// A user defined label for this organization. 9 | String label; 10 | 11 | /// The name of the organization. 12 | String name; 13 | 14 | /// Indicates the type of organization in relation to the contact, for example "work". 15 | OrganizationType type; 16 | 17 | /// Creates a new (empty) instance of the [Organization] class. 18 | Organization(); 19 | 20 | /// Create a new instance of the [Organization] class and populates it's properties based on the supplied JSON message. 21 | factory Organization.fromJson(Map json) { 22 | return Organization() 23 | ..jobTitle = json['jobTitle'] as String 24 | ..label = json['label'] as String 25 | ..name = json['name'] as String 26 | ..type = 27 | _JsonCodec._decodeNullableEnum(OrganizationType.values, json['type']); 28 | } 29 | 30 | /// Converts the [Organization] instance to a key / value map which can easily be serialized to a JSON string. 31 | Map toJson() => { 32 | 'jobTitle': this.jobTitle, 33 | 'label': this.label, 34 | 'name': this.name, 35 | 'type': _JsonCodec._encodeNullableEnum(this.type) 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /lib/models/instant_messaging_account.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | /// A representation of a instant messaging account linked to a contact. 4 | class InstantMessagingAccount { 5 | /// The name of the account (or account name). 6 | String account; 7 | 8 | /// A user defined label for the [InstantMessagingAccount]. 9 | String label; 10 | 11 | /// Indicates the instant messaging services to which this account belongs. 12 | InstantMessagingService service; 13 | 14 | /// Creates a new (empty) instance of the [InstantMessagingAccount] class. 15 | InstantMessagingAccount(); 16 | 17 | /// Create a new instance of the [InstantMessagingAccount] class and populates it's properties based on the supplied JSON message. 18 | factory InstantMessagingAccount.fromJson(Map json) { 19 | return InstantMessagingAccount() 20 | ..account = json['account'] as String 21 | ..label = json['label'] as String 22 | ..service = _JsonCodec._decodeNullableEnum( 23 | InstantMessagingService.values, json['service']); 24 | } 25 | 26 | /// Converts the [InstantMessagingAccount] instance to a key / value map which can easily be serialized to a JSON string. 27 | Map toJson() => { 28 | 'account': this.account, 29 | 'label': this.label, 30 | 'service': _JsonCodec._encodeNullableEnum(this.service) 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/ContactsPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin 2 | 3 | import android.content.Context 4 | import com.baseflow.contactsplugin.models.Contact 5 | import com.baseflow.contactsplugin.utils.JsonCodec 6 | import io.flutter.plugin.common.MethodChannel 7 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 8 | import io.flutter.plugin.common.MethodChannel.Result 9 | import io.flutter.plugin.common.MethodCall 10 | import io.flutter.plugin.common.PluginRegistry 11 | import io.flutter.plugin.common.PluginRegistry.Registrar 12 | 13 | class ContactsPlugin(private val registrar: PluginRegistry.Registrar): MethodCallHandler { 14 | private val androidContext: Context = registrar.activity() ?: registrar.activeContext() 15 | 16 | companion object { 17 | @JvmStatic 18 | fun registerWith(registrar: Registrar) { 19 | val channel = MethodChannel(registrar.messenger(), "flutter.baseflow.com/contacts_plugin/methods") 20 | channel.setMethodCallHandler(ContactsPlugin(registrar)) 21 | } 22 | } 23 | 24 | override fun onMethodCall(call: MethodCall, result: Result) { 25 | if (call.method == "getContacts") { 26 | val contactManager = ContactManager(androidContext) 27 | val contacts: Collection = contactManager.fetchContacts() 28 | result.success(JsonCodec.encodeToJsonString(contacts)) 29 | } else { 30 | result.notImplemented() 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:contacts_plugin/contacts_plugin.dart'; 5 | 6 | void main() => runApp(new MyApp()); 7 | 8 | class MyApp extends StatelessWidget { 9 | @override 10 | Widget build(BuildContext context) { 11 | return new MaterialApp( 12 | home: new Scaffold( 13 | appBar: new AppBar( 14 | title: const Text('Plugin example app'), 15 | ), 16 | body: new SafeArea( 17 | child: ContactListWidget(), 18 | ), 19 | ), 20 | ); 21 | } 22 | } 23 | 24 | class ContactListWidget extends StatelessWidget { 25 | @override 26 | Widget build(BuildContext context) { 27 | return FutureBuilder( 28 | future: ContactsPlugin().getContacts(), 29 | builder: (BuildContext context, AsyncSnapshot> snapshot) { 30 | if (!snapshot.hasData) { 31 | return Center(child: CircularProgressIndicator()); 32 | } 33 | 34 | return ListView( 35 | children: 36 | snapshot.data.map((contact) => ContactWidget(contact)).toList(), 37 | ); 38 | }, 39 | ); 40 | } 41 | } 42 | 43 | class ContactWidget extends StatelessWidget { 44 | final Contact _contact; 45 | 46 | ContactWidget(this._contact); 47 | 48 | @override 49 | Widget build(BuildContext context) { 50 | return ListTile( 51 | leading: CircleAvatar( 52 | backgroundColor: 53 | Colors.primaries[Random().nextInt(Colors.primaries.length - 1)], 54 | child: 55 | Text(_contact.displayName?.substring(0, 1)?.toUpperCase() ?? "")), 56 | title: Text(_contact.displayName ?? ""), 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/models/Contact.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin.models 2 | 3 | class Contact(val id: String, val isAggregate: Boolean) { 4 | var displayName: String = "" 5 | var firstName: String = "" 6 | var middleName: String = "" 7 | var lastName: String = "" 8 | var prefix: String = "" 9 | var nickname: String = "" 10 | var suffix: String = "" 11 | 12 | var addresses: MutableList
= mutableListOf() 13 | set(value) { 14 | field = mutableListOf(*value.toTypedArray()) 15 | } 16 | var emailAddresses: MutableList = mutableListOf() 17 | set(value) { 18 | field = mutableListOf(*value.toTypedArray()) 19 | } 20 | var instantMessagingAccounts: MutableList = mutableListOf() 21 | set(value) { 22 | field = mutableListOf(*value.toTypedArray()) 23 | } 24 | var notes: MutableList = mutableListOf() 25 | set(value) { 26 | field = mutableListOf(*value.toTypedArray()) 27 | } 28 | var organizations: MutableList = mutableListOf() 29 | set(value) { 30 | field = mutableListOf(*value.toTypedArray()) 31 | } 32 | var phoneNumbers: MutableList = mutableListOf() 33 | set(value) { 34 | field = mutableListOf(*value.toTypedArray()) 35 | } 36 | var relationships: MutableList = mutableListOf() 37 | set(value) { 38 | field = mutableListOf(*value.toTypedArray()) 39 | } 40 | var websites: MutableList = mutableListOf() 41 | set(value) { 42 | field = mutableListOf(*value.toTypedArray()) 43 | } 44 | } -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | contacts_plugin_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | NSContactsUsageDescription 45 | This app needs access to address book. 46 | 47 | 48 | -------------------------------------------------------------------------------- /lib/models/address.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | /// A representation of the postal address for a contact. 4 | class Address { 5 | /// Indicates the type of Address, for example Home or Work. 6 | AddressType type; 7 | 8 | /// An user defined label for this address. 9 | String label; 10 | 11 | /// The street name of the address. 12 | String streetAddress; 13 | 14 | /// The city name of the address. 15 | String city; 16 | 17 | /// The name of the region (for example state or province) of the address. 18 | String region; 19 | 20 | /// The country name of the address. 21 | String country; 22 | 23 | /// The postal code of the address. 24 | String postalCode; 25 | 26 | /// Creates a new (empty) instance of the [Address] class. 27 | Address(); 28 | 29 | /// Create a new instance of the [Address] class and populates it's properties based on the supplied JSON message. 30 | factory Address.fromJson(Map json) { 31 | return Address() 32 | ..type = _JsonCodec._decodeNullableEnum(AddressType.values, json['type']) 33 | ..label = json['label'] as String 34 | ..streetAddress = json['streetAddress'] as String 35 | ..city = json['city'] as String 36 | ..region = json['region'] as String 37 | ..country = json['country'] as String 38 | ..postalCode = json['postalCode'] as String; 39 | } 40 | 41 | /// Converts the [Address] instance to a key / value map which can easily be serialized to a JSON string. 42 | Map toJson() => { 43 | 'type': _JsonCodec._encodeNullableEnum(this.type), 44 | 'label': this.label, 45 | 'streetAddress': this.streetAddress, 46 | 'city': this.city, 47 | 'region': this.region, 48 | 'country': this.country, 49 | 'postalCode': this.postalCode 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: contacts_plugin 2 | description: A Flutter contacts plugin which provides easy access to the platform specific address book. 3 | version: 0.0.3 4 | author: Baseflow 5 | homepage: https://github.com/baseflowit/flutter-contacts-plugin 6 | 7 | 8 | environment: 9 | sdk: ">=2.0.0-dev.68.0 <3.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | permission_handler: ^2.0.0 16 | 17 | dev_dependencies: 18 | flutter_test: 19 | sdk: flutter 20 | 21 | # For information on the generic Dart part of this file, see the 22 | # following page: https://www.dartlang.org/tools/pub/pubspec 23 | 24 | # The following section is specific to Flutter. 25 | flutter: 26 | plugin: 27 | androidPackage: com.baseflow.contactsplugin 28 | pluginClass: ContactsPlugin 29 | 30 | # To add assets to your plugin package, add an assets section, like this: 31 | # assets: 32 | # - images/a_dot_burr.jpeg 33 | # - images/a_dot_ham.jpeg 34 | # 35 | # For details regarding assets in packages, see 36 | # https://flutter.io/assets-and-images/#from-packages 37 | # 38 | # An image asset can refer to one or more resolution-specific "variants", see 39 | # https://flutter.io/assets-and-images/#resolution-aware. 40 | 41 | # To add custom fonts to your plugin package, add a fonts section here, 42 | # in this "flutter" section. Each entry in this list should have a 43 | # "family" key with the font family name, and a "fonts" key with a 44 | # list giving the asset and other descriptors for the font. For 45 | # example: 46 | # fonts: 47 | # - family: Schyler 48 | # fonts: 49 | # - asset: fonts/Schyler-Regular.ttf 50 | # - asset: fonts/Schyler-Italic.ttf 51 | # style: italic 52 | # - family: Trajan Pro 53 | # fonts: 54 | # - asset: fonts/TrajanPro.ttf 55 | # - asset: fonts/TrajanPro_Bold.ttf 56 | # weight: 700 57 | # 58 | # For details regarding fonts in packages, see 59 | # https://flutter.io/custom-fonts/#from-packages 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.lock 4 | *.log 5 | *.pyc 6 | *.swp 7 | .DS_Store 8 | .atom/ 9 | .buildlog/ 10 | .history 11 | .project 12 | .svn/ 13 | bin/ 14 | 15 | # Ignore generated code files 16 | *.g.* 17 | 18 | # IntelliJ related 19 | *.iml 20 | *.ipr 21 | *.iws 22 | .idea/ 23 | 24 | # Android Studio related 25 | android/.classpath 26 | android/.settings/ 27 | 28 | # Visual Studio Code related 29 | .vscode/ 30 | 31 | # Flutter repo-specific 32 | /bin/cache/ 33 | /bin/mingit/ 34 | /dev/benchmarks/mega_gallery/ 35 | /dev/bots/.recipe_deps 36 | /dev/bots/android_tools/ 37 | /dev/docs/doc/ 38 | /dev/docs/lib/ 39 | /dev/docs/pubspec.yaml 40 | /packages/flutter/coverage/ 41 | version 42 | 43 | # Flutter/Dart/Pub related 44 | **/doc/api/ 45 | .dart_tool/ 46 | .flutter-plugins 47 | .packages 48 | .pub-cache/ 49 | .pub/ 50 | build/ 51 | flutter_*.png 52 | linked_*.ds 53 | unlinked.ds 54 | unlinked_spec.ds 55 | 56 | # Android related 57 | **/android/**/gradle-wrapper.jar 58 | **/android/.gradle 59 | **/android/captures/ 60 | **/android/gradlew 61 | **/android/gradlew.bat 62 | **/android/local.properties 63 | **/android/**/GeneratedPluginRegistrant.java 64 | 65 | # iOS/XCode related 66 | **/ios/**/*.mode1v3 67 | **/ios/**/*.mode2v3 68 | **/ios/**/*.moved-aside 69 | **/ios/**/*.pbxuser 70 | **/ios/**/*.perspectivev3 71 | **/ios/**/*sync/ 72 | **/ios/**/.sconsign.dblite 73 | **/ios/**/.tags* 74 | **/ios/**/.vagrant/ 75 | **/ios/**/DerivedData/ 76 | **/ios/**/Icon? 77 | **/ios/**/Pods/ 78 | **/ios/**/.symlinks/ 79 | **/ios/**/profile 80 | **/ios/**/xcuserdata 81 | **/ios/.generated/ 82 | **/ios/Flutter/App.framework 83 | **/ios/Flutter/Flutter.framework 84 | **/ios/Flutter/Generated.xcconfig 85 | **/ios/Flutter/app.flx 86 | **/ios/Flutter/app.zip 87 | **/ios/Flutter/flutter_assets/ 88 | **/ios/ServiceDefinitions.json 89 | **/ios/Runner/GeneratedPluginRegistrant.* 90 | 91 | # Exceptions to above rules. 92 | !**/ios/**/default.mode1v3 93 | !**/ios/**/default.mode2v3 94 | !**/ios/**/default.pbxuser 95 | !**/ios/**/default.perspectivev3 96 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 97 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | # Job 1) Run analyzer 4 | - os: linux 5 | env: 6 | - SHARD=Analyze 7 | sudo: false 8 | addons: 9 | apt: 10 | # Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18 11 | sources: 12 | - ubuntu-toolchain-r-test # if we don't specify this, the libstdc++6 we get is the wrong version 13 | packages: 14 | - libstdc++6 15 | - fonts-droid 16 | before_script: 17 | - git clone https://github.com/flutter/flutter.git $HOME/flutter 18 | - export PATH=$HOME/flutter/bin:$HOME/flutter/bin/cache/dart-sdk/bin:$PATH 19 | - flutter doctor 20 | - flutter packages get 21 | script: 22 | - flutter analyze 23 | # Job 2) Build the example binary for Android (APK) 24 | - os: linux 25 | env: 26 | - SHARD="Build example apks" 27 | jdk: oraclejdk8 28 | sudo: false 29 | addons: 30 | apt: 31 | # Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18 32 | sources: 33 | - ubuntu-toolchain-r-test # if we don't specify this, the libstdc++6 we get is the wrong version 34 | packages: 35 | - lib32stdc++6 # https://github.com/flutter/flutter/issues/6207 36 | - libstdc++6 37 | - fonts-droid 38 | before_script: 39 | - ./scripts/before_build_apks.sh 40 | - export PATH=$HOME/flutter/bin:$HOME/flutter/bin/cache/dart-sdk/bin:$PATH 41 | - export ANDROID_HOME=$HOME/android-sdk 42 | - cd ./example 43 | script: 44 | - flutter build apk 45 | # Job 3) Build the example binary for iOS (IPA) 46 | - os: osx 47 | env: 48 | - SHARD="Build example ipas" 49 | language: generic 50 | osx_image: xcode9.3 51 | before_script: 52 | - ./scripts/before_build_ipas.sh 53 | - export PATH=$HOME/flutter/bin:$HOME/flutter/bin/cache/dart-sdk/bin:$PATH 54 | - cd ./example 55 | script: 56 | - flutter build ios --no-codesign 57 | cache: 58 | directories: 59 | - $HOME/.pub-cache 60 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 16 | 20 | 27 | 31 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 27 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.baseflow.contactspluginexample" 42 | minSdkVersion 16 43 | targetSdkVersion 27 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 66 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 67 | } 68 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | def parse_KV_file(file, separator='=') 8 | file_abs_path = File.expand_path(file) 9 | if !File.exists? file_abs_path 10 | return []; 11 | end 12 | pods_ary = [] 13 | skip_line_start_symbols = ["#", "/"] 14 | File.foreach(file_abs_path) { |line| 15 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } 16 | plugin = line.split(pattern=separator) 17 | if plugin.length == 2 18 | podname = plugin[0].strip() 19 | path = plugin[1].strip() 20 | podpath = File.expand_path("#{path}", file_abs_path) 21 | pods_ary.push({:name => podname, :path => podpath}); 22 | else 23 | puts "Invalid plugin specification: #{line}" 24 | end 25 | } 26 | return pods_ary 27 | end 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | 32 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock 33 | # referring to absolute paths on developers' machines. 34 | system('rm -rf .symlinks') 35 | system('mkdir -p .symlinks/plugins') 36 | 37 | # Flutter Pods 38 | generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') 39 | if generated_xcode_build_settings.empty? 40 | puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." 41 | end 42 | generated_xcode_build_settings.map { |p| 43 | if p[:name] == 'FLUTTER_FRAMEWORK_DIR' 44 | symlink = File.join('.symlinks', 'flutter') 45 | File.symlink(File.dirname(p[:path]), symlink) 46 | pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) 47 | end 48 | } 49 | 50 | # Plugin Pods 51 | plugin_pods = parse_KV_file('../.flutter-plugins') 52 | plugin_pods.map { |p| 53 | symlink = File.join('.symlinks', 'plugins', p[:name]) 54 | File.symlink(p[:path], symlink) 55 | pod p[:name], :path => File.join(symlink, 'ios') 56 | } 57 | end 58 | 59 | post_install do |installer| 60 | installer.pods_project.targets.each do |target| 61 | target.build_configurations.each do |config| 62 | config.build_settings['ENABLE_BITCODE'] = 'NO' 63 | config.build_settings['SWIFT_VERSION'] = '4.1' 64 | end 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Classes/strategies/ContactStoreStrategy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContactStoreStrategy.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Contacts 9 | import Foundation 10 | 11 | @available(iOS 9.0, *) 12 | class ContactStoreStrategy : ContactStrategy { 13 | 14 | func fetchContacts() -> [Contact] { 15 | let contactStore = CNContactStore() 16 | let keysToFetch = [ 17 | CNContactDepartmentNameKey, 18 | CNContactEmailAddressesKey, 19 | CNContactFamilyNameKey, 20 | CNContactGivenNameKey, 21 | CNContactIdentifierKey, 22 | CNContactMiddleNameKey, 23 | CNContactInstantMessageAddressesKey, 24 | CNContactJobTitleKey, 25 | CNContactNamePrefixKey, 26 | CNContactNameSuffixKey, 27 | CNContactNicknameKey, 28 | CNContactNoteKey, 29 | CNContactOrganizationNameKey, 30 | CNContactPhoneNumbersKey, 31 | CNContactPostalAddressesKey, 32 | CNContactRelationsKey, 33 | CNContactSocialProfilesKey, 34 | CNContactTypeKey, 35 | CNContactUrlAddressesKey, 36 | CNInstantMessageAddressServiceKey, 37 | CNInstantMessageAddressUsernameKey, 38 | CNPostalAddressCityKey, 39 | CNPostalAddressStateKey, 40 | CNPostalAddressStreetKey, 41 | CNPostalAddressCountryKey, 42 | CNPostalAddressPostalCodeKey] as [Any] 43 | 44 | // Get all the containers 45 | var allContainers: [CNContainer] = [] 46 | do { 47 | allContainers = try contactStore.containers(matching: nil) 48 | } catch { 49 | print("Error fetching containers") 50 | } 51 | 52 | var results: [CNContact] = [] 53 | 54 | // Iterate all containers and append their contacts to our results array 55 | for container in allContainers { 56 | let fetchPredicate = CNContact.predicateForContactsInContainer(withIdentifier: container.identifier) 57 | 58 | do { 59 | let containerResults = try contactStore.unifiedContacts(matching: fetchPredicate, keysToFetch: keysToFetch as! [CNKeyDescriptor]) 60 | results.append(contentsOf: containerResults) 61 | } catch { 62 | print("Error fetching results for container") 63 | } 64 | } 65 | 66 | return results.toContacts() 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: contacts_plugin_example 2 | description: Demonstrates how to use the contacts_plugin plugin. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # Read more about versioning at semver.org. 10 | version: 1.0.0+1 11 | 12 | environment: 13 | sdk: ">=2.0.0-dev.68.0 <3.0.0" 14 | 15 | dependencies: 16 | flutter: 17 | sdk: flutter 18 | 19 | # The following adds the Cupertino Icons font to your application. 20 | # Use with the CupertinoIcons class for iOS style icons. 21 | cupertino_icons: ^0.1.2 22 | 23 | dev_dependencies: 24 | flutter_test: 25 | sdk: flutter 26 | 27 | contacts_plugin: 28 | path: ../ 29 | 30 | # For information on the generic Dart part of this file, see the 31 | # following page: https://www.dartlang.org/tools/pub/pubspec 32 | 33 | # The following section is specific to Flutter. 34 | flutter: 35 | 36 | # The following line ensures that the Material Icons font is 37 | # included with your application, so that you can use the icons in 38 | # the material Icons class. 39 | uses-material-design: true 40 | 41 | # To add assets to your application, add an assets section, like this: 42 | # assets: 43 | # - images/a_dot_burr.jpeg 44 | # - images/a_dot_ham.jpeg 45 | 46 | # An image asset can refer to one or more resolution-specific "variants", see 47 | # https://flutter.io/assets-and-images/#resolution-aware. 48 | 49 | # For details regarding adding assets from package dependencies, see 50 | # https://flutter.io/assets-and-images/#from-packages 51 | 52 | # To add custom fonts to your application, add a fonts section here, 53 | # in this "flutter" section. Each entry in this list should have a 54 | # "family" key with the font family name, and a "fonts" key with a 55 | # list giving the asset and other descriptors for the font. For 56 | # example: 57 | # fonts: 58 | # - family: Schyler 59 | # fonts: 60 | # - asset: fonts/Schyler-Regular.ttf 61 | # - asset: fonts/Schyler-Italic.ttf 62 | # style: italic 63 | # - family: Trajan Pro 64 | # fonts: 65 | # - asset: fonts/TrajanPro.ttf 66 | # - asset: fonts/TrajanPro_Bold.ttf 67 | # weight: 700 68 | # 69 | # For details regarding fonts from package dependencies, 70 | # see https://flutter.io/custom-fonts/#from-packages 71 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to the Flutter Contacts plugin 2 | ============================================= 3 | 4 | What you will need 5 | ------------------ 6 | 7 | * A Linux, Mac OS X, or Windows machine (note: to run and compile iOS specific parts you'll need access to a Mac OS X machine); 8 | * git (used for source version control, installation instruction can be found [here](https://git-scm.com/)); 9 | * The Flutter SDK (installation instructions can be found [here](https://flutter.io/get-started/install/)); 10 | * A personal GitHub account (if you don't have one, you can sign-up for free [here](https://github.com/)) 11 | 12 | Setting up your development environment 13 | --------------------------------------- 14 | 15 | * Fork `https://github.com/BaseflowIT/flutter-contacts-plugin` into your own GitHub account. If you already have a fork and moving to a new computer, make sure you update you fork. 16 | * If you haven't configured your machine with an SSH key that's known to github, then 17 | follow [GitHub's directions](https://help.github.com/articles/generating-ssh-keys/) 18 | to generate an SSH key. 19 | * Clone your forked repo on your local development machine: `git clone git@github.com:/flutter-contacts-plugin.git` 20 | * Change into the `flutter-contacts-plugin` directory: `cd flutter-contacts-plugin` 21 | * Add an upstream to the original repo, so that fetch from the master repository and not your clone: `git remote add upstream git@github.com:BaseflowIT/flutter-contacts-plugin.git` 22 | 23 | Running the example project 24 | --------------------------- 25 | 26 | * Change into the example directory: `cd example` 27 | * Run the App: `flutter run` 28 | 29 | Contribute 30 | ---------- 31 | 32 | We really appreciate contributions via GitHub pull requests. To contribute take the following steps: 33 | 34 | * Make sure you are up to date with the latest code on the master: 35 | * `git fetch upstream` 36 | * `git checkout upstream/develop -b ` 37 | * Apply your changes 38 | * Verify your changes and fix potential warnings/ errors: 39 | * Check formatting: `flutter format .` 40 | * Run static analyses: `flutter analyzes` 41 | * Run unit-tests: `flutter test` 42 | * Commit your changes: `git commit -am ""` 43 | * Push changes to your fork: `git push origin ` 44 | 45 | Send us your pull request: 46 | 47 | * Go to `https://github.com/BaseflowIT/flutter-contacts-plugin` and click the "Compare & pull request" button. 48 | 49 | Please make sure you solved all warnings and errors reported by the static code analyses and that you fill in the full pull request template. Failing to do so will result in us asking you to fix it. -------------------------------------------------------------------------------- /lib/contacts_plugin.dart: -------------------------------------------------------------------------------- 1 | library contacts_plugin; 2 | 3 | import 'dart:async'; 4 | import 'dart:convert'; 5 | 6 | import 'package:flutter/foundation.dart'; 7 | import 'package:flutter/services.dart'; 8 | import 'package:permission_handler/permission_handler.dart'; 9 | 10 | part 'data/contact_enums.dart'; 11 | part 'models/address.dart'; 12 | part 'models/contact.dart'; 13 | part 'models/email_address.dart'; 14 | part 'models/instant_messaging_account.dart'; 15 | part 'models/note.dart'; 16 | part 'models/organization.dart'; 17 | part 'models/phone_number.dart'; 18 | part 'models/relationship.dart'; 19 | part 'models/website.dart'; 20 | part 'utils/json_codec.dart'; 21 | 22 | /// Provides easy access to the platform specific address book (using the Contacts SDK on iOS and the Contacts Provider on Android) 23 | class ContactsPlugin { 24 | static const MethodChannel _channel = 25 | const MethodChannel('flutter.baseflow.com/contacts_plugin/methods'); 26 | 27 | /// Returns a [Future] containing a list of all contacts ([List]) available on the platform. 28 | Future> getContacts() async { 29 | PermissionStatus permissionStatus = await _getContactPermission(); 30 | 31 | if (permissionStatus == PermissionStatus.granted) { 32 | final dynamic jsonString = await _channel.invokeMethod('getContacts'); 33 | final List jsonObjects = json.decode(jsonString); 34 | final List contacts = jsonObjects 35 | .map((jsonObject) => Contact.fromJson(jsonObject)) 36 | .toList(); 37 | 38 | return contacts; 39 | } else { 40 | _handleInvalidPermissions(permissionStatus); 41 | } 42 | 43 | return null; 44 | } 45 | 46 | Future _getContactPermission() async { 47 | PermissionStatus permission = await PermissionHandler() 48 | .checkPermissionStatus(PermissionGroup.contacts); 49 | 50 | if (permission != PermissionStatus.granted && 51 | permission != PermissionStatus.disabled) { 52 | Map permissionStatus = 53 | await PermissionHandler() 54 | .requestPermissions([PermissionGroup.contacts]); 55 | 56 | return permissionStatus[PermissionGroup.contacts] ?? 57 | PermissionStatus.unknown; 58 | } else { 59 | return permission; 60 | } 61 | } 62 | 63 | void _handleInvalidPermissions(PermissionStatus permissionStatus) { 64 | if (permissionStatus == PermissionStatus.denied) { 65 | throw new PlatformException( 66 | code: "PERMISSION_DENIED", 67 | message: "Access to location data denied", 68 | details: null); 69 | } else if (permissionStatus == PermissionStatus.disabled) { 70 | throw new PlatformException( 71 | code: "PERMISSION_DISABLED", 72 | message: "Location data is not available on device", 73 | details: null); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome:http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Don't use tabs for indentation. 7 | [*] 8 | indent_style = space 9 | # (Please don't specify an indent_size here; that has too many unintended consequences.) 10 | 11 | # Code files 12 | [*.{cs,csx,vb,vbx}] 13 | indent_size = 4 14 | insert_final_newline = true 15 | charset = utf-8-bom 16 | 17 | # Xml project files 18 | [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] 19 | indent_size = 2 20 | 21 | # Xml config files 22 | [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] 23 | indent_size = 2 24 | 25 | # JSON files 26 | [*.json] 27 | indent_size = 2 28 | 29 | # Dotnet code style settings: 30 | [*.{cs,vb}] 31 | # Sort using and Import directives with System.* appearing first 32 | dotnet_sort_system_directives_first = true 33 | # Avoid "this." and "Me." if not necessary 34 | dotnet_style_qualification_for_field = false:suggestion 35 | dotnet_style_qualification_for_property = false:suggestion 36 | dotnet_style_qualification_for_method = false:suggestion 37 | dotnet_style_qualification_for_event = false:suggestion 38 | 39 | # Use language keywords instead of framework type names for type references 40 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion 41 | dotnet_style_predefined_type_for_member_access = true:suggestion 42 | 43 | # Suggest more modern language features when available 44 | dotnet_style_object_initializer = true:suggestion 45 | dotnet_style_collection_initializer = true:suggestion 46 | dotnet_style_coalesce_expression = true:suggestion 47 | dotnet_style_null_propagation = true:suggestion 48 | dotnet_style_explicit_tuple_names = true:suggestion 49 | 50 | # CSharp code style settings: 51 | [*.cs] 52 | # Prefer "var" everywhere 53 | csharp_style_var_for_built_in_types = true:suggestion 54 | csharp_style_var_when_type_is_apparent = true:suggestion 55 | csharp_style_var_elsewhere = true:suggestion 56 | 57 | # Prefer method-like constructs to have a block body 58 | csharp_style_expression_bodied_methods = false:none 59 | csharp_style_expression_bodied_constructors = false:none 60 | csharp_style_expression_bodied_operators = false:none 61 | 62 | # Prefer property-like constructs to have an expression-body 63 | csharp_style_expression_bodied_properties = true:none 64 | csharp_style_expression_bodied_indexers = true:none 65 | csharp_style_expression_bodied_accessors = true:none 66 | 67 | # Suggest more modern language features when available 68 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion 69 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion 70 | csharp_style_inlined_variable_declaration = true:suggestion 71 | csharp_style_throw_expression = true:suggestion 72 | csharp_style_conditional_delegate_call = true:suggestion 73 | 74 | # Newline settings 75 | csharp_new_line_before_open_brace = all 76 | csharp_new_line_before_else = true 77 | csharp_new_line_before_catch = true 78 | csharp_new_line_before_finally = true 79 | csharp_new_line_before_members_in_object_initializers = true 80 | csharp_new_line_before_members_in_anonymous_types = true 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter Contacts Plugin 2 | 3 | [![pub package](https://img.shields.io/pub/v/contacts.svg)](https://pub.dartlang.org/packages/contacts) 4 | 5 | A Flutter contacts plugin which provides easy access to the platform specific address book. 6 | 7 | Branch | Build Status 8 | ------- | ------------ 9 | develop | [![Build Status](https://travis-ci.com/BaseflowIT/flutter-contacts-plugin.svg?branch=develop)](https://travis-ci.com/BaseflowIT/flutter-contacts) 10 | master | [![Build Status](https://travis-ci.com/BaseflowIT/flutter-contacts-plugin.svg?branch=master)](https://travis-ci.com/BaseflowIT/flutter-contacts) 11 | 12 | ## Features 13 | 14 | * Automatically check and request the necessary permissions to access the platform specific address book; 15 | * Read contacts from the addres book; 16 | * [WIP] Store new contacts in the address book; 17 | * [WIP] Update details of existing contacts; 18 | * [WIP] Delete existing contacts from the address book. 19 | 20 | ## Usage 21 | 22 | To use this plugin, add `contacts_plugin` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). For example: 23 | 24 | ```yaml 25 | dependencies: 26 | contacts_plugin: '^0.0.3' 27 | ``` 28 | 29 | > **NOTE:** There's a known issue with integrating plugins that use Swift into a Flutter project created with the Objective-C template. See issue [Flutter#16049](https://github.com/flutter/flutter/issues/16049) for help on integration. 30 | 31 | ## API 32 | 33 | ### Fetch all contacts 34 | 35 | To fetch all contacts from the address book make a call to the `getContacts` method: 36 | 37 | ``` dart 38 | import 'package:geolocator/contacts_plugin.dart'; 39 | 40 | List contacts = await ContactsPlugin().getContacts(); 41 | ``` 42 | 43 | ## Permissions 44 | 45 | ### Android 46 | 47 | On Android you'll need to add either the `READ_CONTACTS` or the `WRITE_CONTACTS` permissions to your Android Manifest (depending if you need read and/ or write access to the address book). Todo so open the AndroidManifest.xml file and one of the following two lines as direct children of the `` tag: 48 | 49 | ``` xml 50 | 51 | 52 | ``` 53 | 54 | ### iOS 55 | 56 | On iOS you'll need to add the `NSContactsUsageDescription` to your Info.plist file in order to access the device's address book. Simply open your Info.plist file and add the following: 57 | 58 | ``` xml 59 | NSContactsUsageDescription 60 | This app needs access to address book. 61 | ``` 62 | 63 | ## Issues 64 | 65 | Please file any issues, bugs or feature request as an issue on our [GitHub](https://github.com/BaseflowIT/flutter-contacts-plugin/issues) page. 66 | 67 | ## Want to contribute 68 | 69 | If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our [contribution guide](CONTRIBUTING.md) and send us your [pull request](https://github.com/BaseflowIT/flutter-contacts-plugin/pulls). 70 | 71 | ## Author 72 | 73 | This Contacts plugin for Flutter is developed by [Baseflow](https://baseflow.com). You can contact us at 74 | -------------------------------------------------------------------------------- /ios/Classes/model/Contact.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Contact.swift 3 | // contacts 4 | // 5 | // Created by Maurits van Beusekom on 28/08/2018. 6 | // 7 | 8 | import Foundation 9 | 10 | class Contact : Encodable { 11 | let id: String 12 | let isAggregate: Bool 13 | 14 | var displayName: String { 15 | var name: String = "" 16 | 17 | if (prefix != "") { 18 | name = "\(prefix) " 19 | } 20 | 21 | if (firstName != "") { 22 | name += "\(firstName) " 23 | } 24 | 25 | if (middleName != "") { 26 | name += "\(middleName) " 27 | } 28 | 29 | if (lastName != "") { 30 | name += "\(lastName) " 31 | } 32 | 33 | if (suffix != "") { 34 | name += "\(suffix)" 35 | } 36 | 37 | return name.trimmingCharacters(in: .whitespacesAndNewlines) 38 | } 39 | 40 | var prefix: String = "" 41 | var firstName: String = "" 42 | var middleName: String = "" 43 | var lastName: String = "" 44 | var nickName: String = "" 45 | var suffix: String = "" 46 | 47 | var addresses = [Address]() 48 | var emailAddresses = [EmailAddress]() 49 | var instantMessagingAccounts = [InstantMessagingAccount]() 50 | var notes = [Note]() 51 | var organizations = [Organization]() 52 | var phoneNumbers = [PhoneNumber]() 53 | var relationships = [Relationship]() 54 | var websites = [Website]() 55 | 56 | init(id: String, isAggregate: Bool) { 57 | self.id = id 58 | self.isAggregate = isAggregate 59 | } 60 | 61 | enum CodingKeys: String, CodingKey { 62 | case id 63 | case isAggregate 64 | case displayName 65 | case prefix 66 | case firstName 67 | case middleName 68 | case lastName 69 | case nickName 70 | case suffix 71 | case addresses 72 | case emailAddresses 73 | case instantMessagingAccounts 74 | case notes 75 | case organizations 76 | case phoneNumbers 77 | case relationships 78 | case websites 79 | } 80 | 81 | func encode(to encoder: Encoder) throws { 82 | var container = encoder.container(keyedBy: CodingKeys.self) 83 | try container.encode(id, forKey: .id) 84 | try container.encode(isAggregate, forKey: .isAggregate) 85 | try container.encode(displayName, forKey: .displayName) 86 | try container.encode(prefix, forKey: .prefix) 87 | try container.encode(firstName, forKey: .firstName) 88 | try container.encode(middleName, forKey: .middleName) 89 | try container.encode(lastName, forKey: .lastName) 90 | try container.encode(nickName, forKey: .nickName) 91 | try container.encode(suffix, forKey: .suffix) 92 | try container.encode(addresses, forKey: .addresses) 93 | try container.encode(emailAddresses, forKey: .emailAddresses) 94 | try container.encode(instantMessagingAccounts, forKey: .instantMessagingAccounts) 95 | try container.encode(notes, forKey: .notes) 96 | try container.encode(organizations, forKey: .organizations) 97 | try container.encode(phoneNumbers, forKey: .phoneNumbers) 98 | try container.encode(relationships, forKey: .relationships) 99 | try container.encode(websites, forKey: .websites) 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at [hello@baseflow.com](mailto:hello@baseflow.com). All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /lib/data/contact_enums.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | enum AddressType { 4 | /// Indicates that the user marked this address his or her as "home" address. 5 | home, 6 | 7 | /// Indicates that the user marked this address his or her as "work" address. 8 | work, 9 | 10 | /// Indicates the address is neither a "home" nor "work" address. 11 | other, 12 | } 13 | 14 | enum EmailAddressType { 15 | /// Indicates that the user marked this emailaddress as his or her "home" emailaddress. 16 | home, 17 | 18 | /// Indicates that the user marked this emailaddress as his or her "work" emailaddress. 19 | work, 20 | 21 | /// Indicates the emailaddress is neither a "home" nor "work" emailaddress. 22 | other, 23 | } 24 | 25 | enum InstantMessagingService { 26 | /// Indicates that the account represents a AIM account. 27 | aim, 28 | 29 | /// Indicates that the account represents a Facebook account. 30 | facebook, 31 | 32 | /// Indicates that the account represents a Gadu Gadu account. 33 | gaduGadu, 34 | 35 | /// Indicates that the account represents a Google account. 36 | googleTalk, 37 | 38 | /// Indicates that the account represents an ICQ account. 39 | icq, 40 | 41 | /// Indicates that the account represents a Jabber account. 42 | jabber, 43 | 44 | /// Indicates that the account represents a MSN account. 45 | msn, 46 | 47 | /// Indicates that the account represents a QQ messenger account. 48 | qq, 49 | 50 | /// Indicates that the account represents a Skype account. 51 | skype, 52 | 53 | /// Indicates that the account represents a Yahoo account. 54 | yahoo, 55 | 56 | /// Indicates that the user marked this number as something that does not match with one of the options in [InstantMessagingService] enum. 57 | other, 58 | } 59 | 60 | enum OrganizationType { 61 | /// Indicates that the user marked this organization as "work". 62 | work, 63 | 64 | /// Indicates the organization is something other then "work". 65 | other, 66 | } 67 | 68 | enum PhoneNumberType { 69 | /// Indicates that the user marked this number as the "home" telephone number. 70 | home, 71 | 72 | /// Indicates that the user marked this number as the "home fax" number. 73 | homeFax, 74 | 75 | /// Indicates that the user marked this number as the "iPhone" telephone number. 76 | iphone, 77 | 78 | /// Indicates that the user marked this number as the "main" telephone number. 79 | main, 80 | 81 | /// Indicates that the user marked this number as the "mobile" telephone number. 82 | mobile, 83 | 84 | /// Indicates that the user marked this number as the "pager" number. 85 | pager, 86 | 87 | /// Indicates that the user marked this number as the "work" telephone number. 88 | work, 89 | 90 | /// Indicates that the user marked this number as the "work fax" number. 91 | workFax, 92 | 93 | /// Indicates that the user marked this number as something that does not match with one of the options in the [PhoneNumberType] enum. 94 | other, 95 | } 96 | 97 | enum RelationshipType { 98 | /// Indicates that the [Contact] is marked as being the father of the user. 99 | father, 100 | 101 | /// Indicates that the [Contact] is marked as being the mother of the user. 102 | mother, 103 | 104 | /// Indicates that the [Contact] is marked as being a parent of the user. 105 | parent, 106 | 107 | /// Indicates that the [Contact] is marked as being the brother of the user. 108 | brother, 109 | 110 | /// Indicates that the [Contact] is marked as being the sister of the user. 111 | sister, 112 | 113 | /// Indicates that the [Contact] is marked as being a child of the user. 114 | child, 115 | 116 | /// Indicates that the [Contact] is marked as being a friend of the user. 117 | friend, 118 | 119 | /// Indicates that the [Contact] is marked as being the spouse of the user. 120 | spouse, 121 | 122 | /// Indicates that the [Contact] is marked as being a partner of the user. 123 | partner, 124 | 125 | /// Indicates that the [Contact] is marked as being an assistant of the user. 126 | assistant, 127 | 128 | /// Indicates that the [Contact] is marked as being a manager of the user. 129 | manager, 130 | 131 | /// Indicates that the user marked this number as something that does not match with one of the options in the [RelationshipType] enum. 132 | other, 133 | } 134 | -------------------------------------------------------------------------------- /lib/models/contact.dart: -------------------------------------------------------------------------------- 1 | part of contacts_plugin; 2 | 3 | /// A representation of a contact retrieved from the platforms address book. 4 | class Contact { 5 | List
_addresses =
[]; 6 | List _emailAddresses = []; 7 | List _instantMessagingAccounts = 8 | []; 9 | List _notes = []; 10 | List _organizations = []; 11 | List _phoneNumbers = []; 12 | List _relationships = []; 13 | List _websites = []; 14 | 15 | /// A unique identifier which is used to identify this contact on the platform. 16 | final String id; 17 | 18 | /// Indicates if the contact is an aggregated representation from the same contact stored on different locations. 19 | final bool isAggregate; 20 | 21 | /// The display name of the contact. 22 | String displayName; 23 | 24 | /// The contact's honorific prefix. 25 | String prefix; 26 | 27 | /// The given name for the contact. 28 | String firstName; 29 | 30 | /// The contact's middle name. 31 | String middleName; 32 | 33 | /// The family name for the contact. 34 | String lastName; 35 | 36 | /// The nickname for the contact. 37 | String nickName; 38 | 39 | /// The contact's honorific suffix. 40 | String suffix; 41 | 42 | /// Creates a new instance of the [Contact] class. 43 | Contact({@required this.id, @required this.isAggregate}); 44 | 45 | /// Create a new instance of the [Contact] class and populates it's properties based on the supplied JSON message. 46 | factory Contact.fromJson(Map json) { 47 | return Contact( 48 | id: json['id'] as String, isAggregate: json['isAggregate'] as bool) 49 | ..displayName = json['displayName'] as String 50 | ..prefix = json['prefix'] as String 51 | ..firstName = json['firstName'] as String 52 | ..middleName = json['middleName'] as String 53 | ..lastName = json['lastName'] as String 54 | ..nickName = json['nickName'] as String 55 | ..suffix = json['suffix'] as String 56 | ..addresses = (json['addresses'] as List) 57 | ?.map((e) => 58 | e == null ? null : Address.fromJson(e as Map)) 59 | ?.toList() 60 | ..emailAddresses = (json['emailAddresses'] as List) 61 | ?.map((e) => e == null 62 | ? null 63 | : EmailAddress.fromJson(e as Map)) 64 | ?.toList() 65 | ..instantMessagingAccounts = (json['instantMessagingAccounts'] as List) 66 | ?.map((e) => e == null 67 | ? null 68 | : InstantMessagingAccount.fromJson(e as Map)) 69 | ?.toList() 70 | ..notes = (json['notes'] as List) 71 | ?.map((e) => 72 | e == null ? null : Note.fromJson(e as Map)) 73 | ?.toList() 74 | ..organizations = (json['organizations'] as List) 75 | ?.map((e) => e == null 76 | ? null 77 | : Organization.fromJson(e as Map)) 78 | ?.toList() 79 | ..phoneNumbers = (json['phoneNumbers'] as List) 80 | ?.map((e) => e == null 81 | ? null 82 | : PhoneNumber.fromJson(e as Map)) 83 | ?.toList() 84 | ..relationships = (json['relationships'] as List) 85 | ?.map((e) => e == null 86 | ? null 87 | : Relationship.fromJson(e as Map)) 88 | ?.toList() 89 | ..websites = (json['websites'] as List) 90 | ?.map((e) => 91 | e == null ? null : Website.fromJson(e as Map)) 92 | ?.toList(); 93 | } 94 | 95 | /// Converts the [Contact] instance to a key / value map which can easily be serialized to a JSON string. 96 | Map toJson() => { 97 | 'id': this.id, 98 | 'isAggregate': this.isAggregate, 99 | 'displayName': this.displayName, 100 | 'prefix': this.prefix, 101 | 'firstName': this.firstName, 102 | 'middleName': this.middleName, 103 | 'lastName': this.lastName, 104 | 'nickName': this.nickName, 105 | 'suffix': this.suffix, 106 | 'addresses': this.addresses, 107 | 'emailAddresses': this.emailAddresses, 108 | 'instantMessagingAccounts': this.instantMessagingAccounts, 109 | 'notes': this.notes, 110 | 'organizations': this.organizations, 111 | 'phoneNumbers': this.phoneNumbers, 112 | 'relationships': this.relationships, 113 | 'websites': this.websites 114 | }; 115 | 116 | /// A collection of all addresses related to this contact. 117 | List
get addresses => _addresses; 118 | set addresses(List
value) => _addresses = List.from(value); 119 | 120 | /// A collection of all email addresses related to this contact. 121 | List get emailAddresses => _emailAddresses; 122 | set emailAddresses(List value) => 123 | _emailAddresses = List.from(value); 124 | 125 | /// A collection of all instant messaging accounts related to this contact. 126 | List get instantMessagingAccounts => 127 | _instantMessagingAccounts; 128 | set instantMessagingAccounts(List value) => 129 | _instantMessagingAccounts = List.from(value); 130 | 131 | /// A collection of all notes related to this contact. 132 | List get notes => _notes; 133 | set notes(List value) => _notes = List.from(value); 134 | 135 | /// A collection of all organizations related to this contact. 136 | List get organizations => _organizations; 137 | set organizations(List value) => 138 | _organizations = List.from(value); 139 | 140 | /// A collection of all phone numbers related to this contact. 141 | List get phoneNumbers => _phoneNumbers; 142 | set phoneNumbers(List value) => _phoneNumbers = List.from(value); 143 | 144 | /// A collection of all relations related to this contact. 145 | List get relationships => _relationships; 146 | set relationships(List value) => 147 | _relationships = List.from(value); 148 | 149 | /// A collection of all websites related to this contact. 150 | List get websites => _websites; 151 | set websites(List value) => _websites = List.from(value); 152 | } 153 | -------------------------------------------------------------------------------- /ios/Classes/model/extensions/ContactExtensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContactExtensions.swift 3 | // contacts_plugin 4 | // 5 | // Created by Maurits van Beusekom on 29/08/2018. 6 | // 7 | 8 | import Contacts 9 | import Foundation 10 | 11 | @available(iOS 9.0, *) 12 | extension Array where Element:CNContact { 13 | func toContacts() -> [Contact] { 14 | return self.map { $0.toContact() } 15 | } 16 | } 17 | 18 | @available(iOS 9.0, *) 19 | extension CNContact { 20 | func toContact() -> Contact { 21 | let contact = Contact(id: self.identifier, isAggregate: true) 22 | contact.prefix = self.namePrefix 23 | contact.firstName = self.givenName 24 | contact.middleName = self.middleName 25 | contact.lastName = self.familyName 26 | contact.nickName = self.nickname 27 | contact.suffix = self.nameSuffix 28 | 29 | contact.addresses = self.postalAddresses.toAddresses() 30 | contact.emailAddresses = self.emailAddresses.toEmailAddresses() 31 | contact.instantMessagingAccounts = self.instantMessageAddresses.toInstantMessagingAccounts() 32 | contact.notes = CNContact.toNotes(content: self.note) 33 | contact.organizations = self.toOrganizations() 34 | contact.phoneNumbers = self.phoneNumbers.toPhoneNumbers() 35 | contact.relationships = self.contactRelations.toRelationships() 36 | contact.websites = self.urlAddresses.toWebsites() 37 | 38 | return contact 39 | } 40 | 41 | func toOrganizations() -> [Organization] { 42 | let organization = Organization() 43 | organization.name = self.organizationName 44 | organization.jobTitle = self.jobTitle 45 | organization.label = CNLabelWork.localizedCapitalized 46 | organization.type = OrganizationType.work 47 | 48 | return [organization] 49 | } 50 | 51 | private static func toNotes(content: String) -> [Note] { 52 | if (content.isEmpty) { 53 | return [Note]() 54 | } 55 | 56 | let note = Note() 57 | note.content = content 58 | 59 | return [note] 60 | } 61 | } 62 | 63 | @available(iOS 9.0, *) 64 | private extension Array where Element:CNLabeledValue { 65 | func toRelationships() -> [Relationship] { 66 | return self.map { $0.toRelationship() } 67 | } 68 | } 69 | 70 | @available(iOS 9.0, *) 71 | private extension CNLabeledValue where ValueType == CNContactRelation { 72 | func toRelationship() -> Relationship { 73 | let cnContactRelation = self.value 74 | let relationship = Relationship() 75 | relationship.label = self.label ?? CNLabelOther.localizedCapitalized 76 | relationship.name = cnContactRelation.name 77 | relationship.type = CNLabeledValue.toRelationshipType(label: self.label) 78 | 79 | return relationship 80 | } 81 | 82 | private static func toRelationshipType(label: String?) -> RelationshipType { 83 | guard let safeLabel = label else { 84 | return RelationshipType.other 85 | } 86 | 87 | switch safeLabel { 88 | case CNLabelContactRelationFather: 89 | return RelationshipType.father 90 | case CNLabelContactRelationMother: 91 | return RelationshipType.mother 92 | case CNLabelContactRelationParent: 93 | return RelationshipType.parent 94 | case CNLabelContactRelationBrother: 95 | return RelationshipType.brother 96 | case CNLabelContactRelationSister: 97 | return RelationshipType.sister 98 | case CNLabelContactRelationChild: 99 | return RelationshipType.child 100 | case CNLabelContactRelationFriend: 101 | return RelationshipType.friend 102 | case CNLabelContactRelationSpouse: 103 | return RelationshipType.spouse 104 | case CNLabelContactRelationPartner: 105 | return RelationshipType.partner 106 | case CNLabelContactRelationAssistant: 107 | return RelationshipType.assistant 108 | case CNLabelContactRelationManager: 109 | return RelationshipType.manager 110 | default: 111 | return RelationshipType.other 112 | } 113 | } 114 | } 115 | 116 | @available(iOS 9.0, *) 117 | private extension Array where Element:CNLabeledValue { 118 | func toInstantMessagingAccounts() -> [InstantMessagingAccount] { 119 | return self.map { $0.toInstantMessagingAccount() } 120 | } 121 | } 122 | 123 | @available(iOS 9.0, *) 124 | private extension CNLabeledValue where ValueType == CNInstantMessageAddress { 125 | func toInstantMessagingAccount() -> InstantMessagingAccount { 126 | let instantMessageAddress = self.value 127 | let account = InstantMessagingAccount() 128 | account.account = instantMessageAddress.username 129 | account.label = instantMessageAddress.service 130 | account.service = CNLabeledValue.toInstantMessagingService(service: instantMessageAddress.service) 131 | 132 | return account 133 | } 134 | 135 | private static func toInstantMessagingService(service: String) -> InstantMessagingService { 136 | switch service { 137 | case CNInstantMessageServiceAIM: 138 | return InstantMessagingService.aim 139 | case CNInstantMessageServiceFacebook: 140 | return InstantMessagingService.facebook 141 | case CNInstantMessageServiceGaduGadu: 142 | return InstantMessagingService.gaduGadu 143 | case CNInstantMessageServiceGoogleTalk: 144 | return InstantMessagingService.googleTalk 145 | case CNInstantMessageServiceICQ: 146 | return InstantMessagingService.icq 147 | case CNInstantMessageServiceJabber: 148 | return InstantMessagingService.jabber 149 | case CNInstantMessageServiceMSN: 150 | return InstantMessagingService.msn 151 | case CNInstantMessageServiceQQ: 152 | return InstantMessagingService.qq 153 | case CNInstantMessageServiceSkype: 154 | return InstantMessagingService.skype 155 | case CNInstantMessageServiceYahoo: 156 | return InstantMessagingService.yahoo 157 | default: 158 | return InstantMessagingService.other 159 | } 160 | } 161 | } 162 | 163 | @available(iOS 9.0, *) 164 | private extension Array where Element:CNLabeledValue { 165 | func toPhoneNumbers() -> [PhoneNumber] { 166 | return self.map { $0.toPhoneNumber() } 167 | } 168 | } 169 | 170 | @available(iOS 9.0, *) 171 | private extension CNLabeledValue where ValueType == CNPhoneNumber { 172 | func toPhoneNumber() -> PhoneNumber { 173 | let cnPhoneNumber = self.value 174 | let phoneNumber = PhoneNumber() 175 | phoneNumber.label = self.label ?? CNLabelOther.localizedCapitalized 176 | phoneNumber.number = cnPhoneNumber.stringValue 177 | phoneNumber.type = CNLabeledValue.toPhoneNumberType(label: self.label) 178 | 179 | return phoneNumber 180 | } 181 | 182 | private static func toPhoneNumberType(label: String?) -> PhoneNumberType { 183 | guard let safeLabel = label else { 184 | return PhoneNumberType.other 185 | } 186 | 187 | switch safeLabel { 188 | case CNLabelHome: 189 | return PhoneNumberType.home 190 | case CNLabelPhoneNumberHomeFax: 191 | return PhoneNumberType.homeFax 192 | case CNLabelPhoneNumberiPhone: 193 | return PhoneNumberType.iphone 194 | case CNLabelPhoneNumberMain: 195 | return PhoneNumberType.main 196 | case CNLabelPhoneNumberMobile: 197 | return PhoneNumberType.mobile 198 | case CNLabelPhoneNumberPager: 199 | return PhoneNumberType.pager 200 | case CNLabelWork: 201 | return PhoneNumberType.work 202 | case CNLabelPhoneNumberWorkFax: 203 | return PhoneNumberType.workFax 204 | default: 205 | return PhoneNumberType.other 206 | } 207 | } 208 | } 209 | 210 | @available(iOS 9.0, *) 211 | private extension Array where Element:CNLabeledValue { 212 | func toAddresses() -> [Address] { 213 | return self.map { $0.toAddress() } 214 | } 215 | } 216 | 217 | @available(iOS 9.0, *) 218 | private extension CNLabeledValue where ValueType == CNPostalAddress { 219 | func toAddress() -> Address { 220 | let postalAddress = self.value 221 | 222 | let address = Address() 223 | address.city = postalAddress.city 224 | address.country = postalAddress.country 225 | address.label = self.label ?? CNLabelOther.localizedCapitalized 226 | address.postalCode = postalAddress.postalCode 227 | address.region = postalAddress.state 228 | address.streetAddress = postalAddress.street 229 | address.type = CNLabeledValue.toAddressType(label: self.label) 230 | 231 | return address 232 | } 233 | 234 | private static func toAddressType(label: String?) -> AddressType { 235 | guard let safeLabel = label else { 236 | return AddressType.other 237 | } 238 | 239 | switch safeLabel { 240 | case CNLabelHome: 241 | return AddressType.home 242 | case CNLabelWork: 243 | return AddressType.work 244 | default: 245 | return AddressType.other 246 | } 247 | } 248 | } 249 | 250 | @available(iOS 9.0, *) 251 | private extension Array where Element:CNLabeledValue { 252 | func toEmailAddresses() -> [EmailAddress] { 253 | return self.map { $0.toEmailAddress() } 254 | } 255 | 256 | func toWebsites() -> [Website] { 257 | return self.map { $0.toWebsite() } 258 | } 259 | } 260 | 261 | @available(iOS 9.0, *) 262 | private extension CNLabeledValue where ValueType == NSString { 263 | func toEmailAddress() -> EmailAddress { 264 | let emailAddress = EmailAddress() 265 | emailAddress.address = self.value as String 266 | emailAddress.label = self.label ?? CNLabelOther.localizedCapitalized 267 | emailAddress.type = CNLabeledValue.toEmailType(label: self.label) 268 | 269 | return emailAddress 270 | } 271 | 272 | func toWebsite() -> Website { 273 | let website = Website() 274 | website.address = self.value as String 275 | 276 | return website 277 | } 278 | 279 | private static func toEmailType(label: String?) -> EmailAddressType { 280 | guard let safeLabel: String = label else { 281 | return EmailAddressType.other 282 | } 283 | 284 | switch safeLabel { 285 | case CNLabelHome: 286 | return EmailAddressType.home 287 | case CNLabelWork: 288 | return EmailAddressType.work 289 | default: 290 | return EmailAddressType.other 291 | } 292 | } 293 | } 294 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/baseflow/contactsplugin/ContactManager.kt: -------------------------------------------------------------------------------- 1 | package com.baseflow.contactsplugin 2 | 3 | import android.content.ContentResolver 4 | import android.content.Context 5 | import android.content.res.Resources 6 | import android.database.Cursor 7 | import android.provider.ContactsContract 8 | import com.baseflow.contactsplugin.data.* 9 | import com.baseflow.contactsplugin.models.* 10 | 11 | class ContactManager(private val androidContext: Context) { 12 | 13 | fun fetchContacts(): Collection { 14 | val contentResolver: ContentResolver = androidContext.contentResolver 15 | 16 | return fetchContacts(contentResolver) 17 | } 18 | 19 | 20 | private fun fetchContacts(contentResolver: ContentResolver): Collection { 21 | var cursor: Cursor? = null 22 | 23 | val keyColumn: String = ContactsContract.Contacts.LOOKUP_KEY 24 | val contacts: MutableList = mutableListOf() 25 | 26 | try { 27 | var currentContact: Contact? = null 28 | cursor = contentResolver.query( 29 | ContactsContract.Data.CONTENT_URI, 30 | null, 31 | null, 32 | null, 33 | null) 34 | if (cursor == null) 35 | return listOf() 36 | 37 | val idIndex: Int = cursor.getColumnIndex(keyColumn) 38 | val displayNameIndex: Int = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME) 39 | var contactId: String? = null 40 | while(cursor.moveToNext()) { 41 | contactId = cursor.getString(idIndex); 42 | 43 | if (currentContact == null || currentContact.id != contactId) { 44 | currentContact = Contact(contactId, true) 45 | currentContact.displayName = cursor.getString(displayNameIndex) 46 | 47 | contacts.add(currentContact) 48 | } 49 | 50 | fillContactWithRow(androidContext.resources, currentContact, cursor) 51 | } 52 | 53 | return contacts 54 | } finally { 55 | cursor?.close() 56 | } 57 | } 58 | 59 | private fun fillContactWithRow(resources: Resources, contact: Contact, cursor: Cursor) { 60 | val mimeTypeIndex: Int = cursor.getColumnIndex(ContactsContract.Data.MIMETYPE) 61 | val dataType: String = cursor.getString(mimeTypeIndex) 62 | 63 | when (dataType) { 64 | ContactsContract.CommonDataKinds.Nickname.CONTENT_ITEM_TYPE -> 65 | contact.nickname = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Nickname.NAME)) ?: "" 66 | ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE -> { 67 | contact.prefix = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.PREFIX)) ?: "" 68 | contact.firstName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME)) ?: "" 69 | contact.middleName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME)) ?: "" 70 | contact.lastName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME)) ?: "" 71 | contact.suffix = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.SUFFIX)) ?: "" 72 | } 73 | ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE -> 74 | contact.addresses.add(getAddress(cursor, resources)) 75 | ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE -> 76 | contact.emailAddresses.add(getEmailAddress(cursor, resources)) 77 | ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE -> 78 | contact.instantMessagingAccounts.add(getInstantMessagingAccount(cursor, resources)) 79 | ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE -> 80 | contact.notes.add(getNote(cursor)) 81 | ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE -> 82 | contact.organizations.add(getOrganization(cursor, resources)) 83 | ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE -> 84 | contact.phoneNumbers.add(getPhoneNumber(cursor, resources)) 85 | ContactsContract.CommonDataKinds.Relation.CONTENT_ITEM_TYPE -> 86 | contact.relationships.add(getRelationship(cursor, resources)) 87 | ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE -> 88 | contact.websites.add(getWebsite(cursor)) 89 | } 90 | } 91 | 92 | private fun getAddress(cursor: Cursor, resources: Resources): Address { 93 | val address = Address() 94 | address.country = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY)) ?: "" 95 | address.region = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.REGION)) ?: "" 96 | address.city = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.CITY)) ?: "" 97 | address.postalCode = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE)) ?: "" 98 | 99 | val addressDataKind: Int = cursor.getInt(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.TYPE)) 100 | address.type = addressDataKind.toAddressType() 101 | address.label = if (addressDataKind != ContactsContract.CommonDataKinds.StructuredPostal.TYPE_CUSTOM) 102 | ContactsContract.CommonDataKinds.StructuredPostal.getTypeLabel(resources, addressDataKind, "").toString() 103 | else 104 | cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.LABEL)) ?: "" 105 | 106 | val street: String? = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.STREET)) 107 | val pobox: String? = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.POBOX)) 108 | if (street != null) { 109 | address.streetAddress = street 110 | } 111 | if (pobox != null) { 112 | address.streetAddress += 113 | if (street != null) 114 | System.getProperty("line.separator") + pobox 115 | else 116 | pobox 117 | } 118 | 119 | return address 120 | 121 | } 122 | 123 | private fun getEmailAddress(cursor: Cursor, resources: Resources): EmailAddress { 124 | val emailAddress = EmailAddress() 125 | emailAddress.address = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DATA1)) ?: "" 126 | 127 | val emailAddressKind: Int = cursor.getInt(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE)) 128 | emailAddress.type = emailAddressKind.toEmailAddressType() 129 | emailAddress.label = 130 | if (emailAddressKind != ContactsContract.CommonDataKinds.Email.TYPE_CUSTOM) 131 | ContactsContract.CommonDataKinds.StructuredPostal.getTypeLabel(resources, emailAddressKind, "").toString() 132 | else 133 | cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.LABEL)) ?: "" 134 | 135 | return emailAddress 136 | } 137 | 138 | private fun getInstantMessagingAccount(cursor: Cursor, resources: Resources): InstantMessagingAccount { 139 | val instantMessagingAccount = InstantMessagingAccount() 140 | instantMessagingAccount.account = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA)) ?: "" 141 | 142 | val instanMessagingKind: Int = cursor.getInt(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Im.PROTOCOL)) 143 | instantMessagingAccount.service = instanMessagingKind.toInstantMessagingService() 144 | instantMessagingAccount.label = 145 | if (instanMessagingKind != ContactsContract.CommonDataKinds.Im.TYPE_CUSTOM) 146 | ContactsContract.CommonDataKinds.Im.getProtocolLabel(resources, instanMessagingKind, "").toString() 147 | else 148 | cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Im.LABEL)) ?: "" 149 | 150 | return instantMessagingAccount 151 | } 152 | 153 | private fun getNote(cursor: Cursor): Note { 154 | val note = Note() 155 | note.content = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Note.DATA1)) ?: "" 156 | 157 | return note 158 | } 159 | 160 | private fun getOrganization(cursor: Cursor, resources: Resources): Organization { 161 | val organization = Organization() 162 | organization.name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Organization.COMPANY)) ?: "" 163 | organization.contactTitle = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Organization.TITLE)) ?: "" 164 | 165 | val organizationKind: Int = cursor.getInt(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Organization.TYPE)) 166 | organization.type = organizationKind.toOrganizationType() 167 | organization.label = 168 | if (organizationKind != ContactsContract.CommonDataKinds.Organization.TYPE_CUSTOM) 169 | ContactsContract.CommonDataKinds.Organization.getTypeLabel(resources, organizationKind, "").toString() 170 | else 171 | cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Organization.LABEL)) ?: "" 172 | 173 | return organization 174 | } 175 | 176 | private fun getPhoneNumber(cursor: Cursor, resources: Resources): PhoneNumber { 177 | val phoneNumber = PhoneNumber() 178 | phoneNumber.number = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)) ?: "" 179 | 180 | val phoneNumberKind: Int = cursor.getInt(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE)) 181 | phoneNumber.type = phoneNumberKind.toPhoneNumberType() 182 | phoneNumber.label = 183 | if (phoneNumberKind != ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM) 184 | ContactsContract.CommonDataKinds.Phone.getTypeLabel(resources, phoneNumberKind, "").toString() 185 | else 186 | cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL)) ?: "" 187 | 188 | return phoneNumber 189 | } 190 | 191 | private fun getRelationship(cursor: Cursor, resources: Resources): Relationship { 192 | val relationship = Relationship() 193 | val relationshipKind: Int = cursor.getInt(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Relation.TYPE)) 194 | relationship.type = relationshipKind.toRelationshipType() 195 | relationship.label = 196 | if (relationshipKind != ContactsContract.CommonDataKinds.Relation.TYPE_CUSTOM) 197 | ContactsContract.CommonDataKinds.Relation.getTypeLabel(resources, relationshipKind, "").toString() 198 | else 199 | cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Relation.LABEL)) ?: "" 200 | 201 | return relationship 202 | } 203 | 204 | private fun getWebsite(cursor: Cursor): Website { 205 | val website = Website() 206 | website.address = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Website.URL)) ?: "" 207 | 208 | return website 209 | } 210 | 211 | private fun Int.toAddressType(): AddressType { 212 | return when(this) { 213 | ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME -> 214 | AddressType.HOME 215 | ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK -> 216 | AddressType.WORK 217 | else -> 218 | AddressType.OTHER 219 | } 220 | } 221 | 222 | private fun Int.toEmailAddressType(): EmailAddressType { 223 | return when(this) { 224 | ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME -> 225 | EmailAddressType.HOME 226 | ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK -> 227 | EmailAddressType.WORK 228 | else -> 229 | EmailAddressType.OTHER 230 | } 231 | } 232 | 233 | private fun Int.toInstantMessagingService(): InstantMessagingService { 234 | return when(this) { 235 | ContactsContract.CommonDataKinds.Im.PROTOCOL_AIM -> 236 | InstantMessagingService.AIM 237 | ContactsContract.CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK -> 238 | InstantMessagingService.GOOGLE_TALK 239 | ContactsContract.CommonDataKinds.Im.PROTOCOL_ICQ -> 240 | InstantMessagingService.ICQ 241 | ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER -> 242 | InstantMessagingService.JABBER 243 | ContactsContract.CommonDataKinds.Im.PROTOCOL_MSN -> 244 | InstantMessagingService.MSN 245 | ContactsContract.CommonDataKinds.Im.PROTOCOL_QQ -> 246 | InstantMessagingService.QQ 247 | ContactsContract.CommonDataKinds.Im.PROTOCOL_SKYPE -> 248 | InstantMessagingService.SKYPE 249 | ContactsContract.CommonDataKinds.Im.PROTOCOL_YAHOO -> 250 | InstantMessagingService.YAHOO 251 | else -> 252 | InstantMessagingService.OTHER 253 | } 254 | } 255 | 256 | private fun Int.toOrganizationType(): OrganizationType { 257 | return when(this) { 258 | ContactsContract.CommonDataKinds.Organization.TYPE_WORK -> 259 | OrganizationType.WORK 260 | else -> 261 | OrganizationType.OTHER 262 | } 263 | } 264 | 265 | private fun Int.toPhoneNumberType(): PhoneNumberType { 266 | return when(this) { 267 | ContactsContract.CommonDataKinds.Phone.TYPE_HOME -> 268 | PhoneNumberType.HOME 269 | ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME -> 270 | PhoneNumberType.HOME_FAX 271 | ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE -> 272 | PhoneNumberType.MOBILE 273 | ContactsContract.CommonDataKinds.Phone.TYPE_PAGER, 274 | ContactsContract.CommonDataKinds.Phone.TYPE_WORK_PAGER -> 275 | PhoneNumberType.HOME_FAX 276 | ContactsContract.CommonDataKinds.Phone.TYPE_WORK -> 277 | PhoneNumberType.WORK 278 | ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK -> 279 | PhoneNumberType.WORK_FAX 280 | else -> 281 | PhoneNumberType.OTHER 282 | } 283 | } 284 | 285 | private fun Int.toRelationshipType(): RelationshipType { 286 | return when(this) { 287 | ContactsContract.CommonDataKinds.Relation.TYPE_FATHER -> 288 | RelationshipType.FATHER 289 | ContactsContract.CommonDataKinds.Relation.TYPE_MOTHER -> 290 | RelationshipType.MOTHER 291 | ContactsContract.CommonDataKinds.Relation.TYPE_PARENT -> 292 | RelationshipType.PARENT 293 | ContactsContract.CommonDataKinds.Relation.TYPE_BROTHER -> 294 | RelationshipType.BROTHER 295 | ContactsContract.CommonDataKinds.Relation.TYPE_SISTER -> 296 | RelationshipType.SISTER 297 | ContactsContract.CommonDataKinds.Relation.TYPE_DOMESTIC_PARTNER, 298 | ContactsContract.CommonDataKinds.Relation.TYPE_PARTNER -> 299 | RelationshipType.PARTNER 300 | ContactsContract.CommonDataKinds.Relation.TYPE_SPOUSE -> 301 | RelationshipType.SPOUSE 302 | ContactsContract.CommonDataKinds.Relation.TYPE_FRIEND -> 303 | RelationshipType.FRIEND 304 | ContactsContract.CommonDataKinds.Relation.TYPE_MANAGER -> 305 | RelationshipType.MANAGER 306 | ContactsContract.CommonDataKinds.Relation.TYPE_ASSISTANT -> 307 | RelationshipType.ASSISTANT 308 | else -> 309 | RelationshipType.OTHER 310 | } 311 | } 312 | 313 | } -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 14 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 15 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 16 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 17 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 18 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 19 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 20 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 21 | D817EBEFB1E00F2B29F40109 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C54B7A064D852835582DAB39 /* Pods_Runner.framework */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXCopyFilesBuildPhase section */ 25 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 26 | isa = PBXCopyFilesBuildPhase; 27 | buildActionMask = 2147483647; 28 | dstPath = ""; 29 | dstSubfolderSpec = 10; 30 | files = ( 31 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 32 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 33 | ); 34 | name = "Embed Frameworks"; 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXCopyFilesBuildPhase section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 41 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 42 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; 43 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 44 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 45 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 46 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 47 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 48 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 49 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 50 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 51 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 53 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 55 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | C54B7A064D852835582DAB39 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 65 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 66 | D817EBEFB1E00F2B29F40109 /* Pods_Runner.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | 6FE75FB3B61835EADEE90BC1 /* Frameworks */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | C54B7A064D852835582DAB39 /* Pods_Runner.framework */, 77 | ); 78 | name = Frameworks; 79 | sourceTree = ""; 80 | }; 81 | 9740EEB11CF90186004384FC /* Flutter */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, 85 | 3B80C3931E831B6300D905FE /* App.framework */, 86 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 87 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 88 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 89 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 90 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 91 | ); 92 | name = Flutter; 93 | sourceTree = ""; 94 | }; 95 | 97C146E51CF9000F007C117D = { 96 | isa = PBXGroup; 97 | children = ( 98 | 9740EEB11CF90186004384FC /* Flutter */, 99 | 97C146F01CF9000F007C117D /* Runner */, 100 | 97C146EF1CF9000F007C117D /* Products */, 101 | F95DE0C6559B94A4137E76D5 /* Pods */, 102 | 6FE75FB3B61835EADEE90BC1 /* Frameworks */, 103 | ); 104 | sourceTree = ""; 105 | }; 106 | 97C146EF1CF9000F007C117D /* Products */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 97C146EE1CF9000F007C117D /* Runner.app */, 110 | ); 111 | name = Products; 112 | sourceTree = ""; 113 | }; 114 | 97C146F01CF9000F007C117D /* Runner */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 118 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 119 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 120 | 97C147021CF9000F007C117D /* Info.plist */, 121 | 97C146F11CF9000F007C117D /* Supporting Files */, 122 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 123 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 124 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 125 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 126 | ); 127 | path = Runner; 128 | sourceTree = ""; 129 | }; 130 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | ); 134 | name = "Supporting Files"; 135 | sourceTree = ""; 136 | }; 137 | F95DE0C6559B94A4137E76D5 /* Pods */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | ); 141 | name = Pods; 142 | sourceTree = ""; 143 | }; 144 | /* End PBXGroup section */ 145 | 146 | /* Begin PBXNativeTarget section */ 147 | 97C146ED1CF9000F007C117D /* Runner */ = { 148 | isa = PBXNativeTarget; 149 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 150 | buildPhases = ( 151 | 7D7F1E1283D6F8A8774A3853 /* [CP] Check Pods Manifest.lock */, 152 | 9740EEB61CF901F6004384FC /* Run Script */, 153 | 97C146EA1CF9000F007C117D /* Sources */, 154 | 97C146EB1CF9000F007C117D /* Frameworks */, 155 | 97C146EC1CF9000F007C117D /* Resources */, 156 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 157 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 158 | 8B3F16A3BE6F576D86107D42 /* [CP] Embed Pods Frameworks */, 159 | ); 160 | buildRules = ( 161 | ); 162 | dependencies = ( 163 | ); 164 | name = Runner; 165 | productName = Runner; 166 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 167 | productType = "com.apple.product-type.application"; 168 | }; 169 | /* End PBXNativeTarget section */ 170 | 171 | /* Begin PBXProject section */ 172 | 97C146E61CF9000F007C117D /* Project object */ = { 173 | isa = PBXProject; 174 | attributes = { 175 | LastUpgradeCheck = 0940; 176 | ORGANIZATIONNAME = "The Chromium Authors"; 177 | TargetAttributes = { 178 | 97C146ED1CF9000F007C117D = { 179 | CreatedOnToolsVersion = 7.3.1; 180 | LastSwiftMigration = 0910; 181 | }; 182 | }; 183 | }; 184 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 185 | compatibilityVersion = "Xcode 3.2"; 186 | developmentRegion = English; 187 | hasScannedForEncodings = 0; 188 | knownRegions = ( 189 | en, 190 | Base, 191 | ); 192 | mainGroup = 97C146E51CF9000F007C117D; 193 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 194 | projectDirPath = ""; 195 | projectRoot = ""; 196 | targets = ( 197 | 97C146ED1CF9000F007C117D /* Runner */, 198 | ); 199 | }; 200 | /* End PBXProject section */ 201 | 202 | /* Begin PBXResourcesBuildPhase section */ 203 | 97C146EC1CF9000F007C117D /* Resources */ = { 204 | isa = PBXResourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 208 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 209 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 210 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, 211 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | }; 215 | /* End PBXResourcesBuildPhase section */ 216 | 217 | /* Begin PBXShellScriptBuildPhase section */ 218 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 219 | isa = PBXShellScriptBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | ); 223 | inputPaths = ( 224 | ); 225 | name = "Thin Binary"; 226 | outputPaths = ( 227 | ); 228 | runOnlyForDeploymentPostprocessing = 0; 229 | shellPath = /bin/sh; 230 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 231 | }; 232 | 7D7F1E1283D6F8A8774A3853 /* [CP] Check Pods Manifest.lock */ = { 233 | isa = PBXShellScriptBuildPhase; 234 | buildActionMask = 2147483647; 235 | files = ( 236 | ); 237 | inputPaths = ( 238 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 239 | "${PODS_ROOT}/Manifest.lock", 240 | ); 241 | name = "[CP] Check Pods Manifest.lock"; 242 | outputPaths = ( 243 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 244 | ); 245 | runOnlyForDeploymentPostprocessing = 0; 246 | shellPath = /bin/sh; 247 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 248 | showEnvVarsInLog = 0; 249 | }; 250 | 8B3F16A3BE6F576D86107D42 /* [CP] Embed Pods Frameworks */ = { 251 | isa = PBXShellScriptBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | ); 255 | inputPaths = ( 256 | "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", 257 | "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", 258 | "${BUILT_PRODUCTS_DIR}/contacts_plugin/contacts_plugin.framework", 259 | "${BUILT_PRODUCTS_DIR}/permission_handler/permission_handler.framework", 260 | ); 261 | name = "[CP] Embed Pods Frameworks"; 262 | outputPaths = ( 263 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", 264 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/contacts_plugin.framework", 265 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/permission_handler.framework", 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | shellPath = /bin/sh; 269 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 270 | showEnvVarsInLog = 0; 271 | }; 272 | 9740EEB61CF901F6004384FC /* Run Script */ = { 273 | isa = PBXShellScriptBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | inputPaths = ( 278 | ); 279 | name = "Run Script"; 280 | outputPaths = ( 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | shellPath = /bin/sh; 284 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 285 | }; 286 | /* End PBXShellScriptBuildPhase section */ 287 | 288 | /* Begin PBXSourcesBuildPhase section */ 289 | 97C146EA1CF9000F007C117D /* Sources */ = { 290 | isa = PBXSourcesBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 294 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | /* End PBXSourcesBuildPhase section */ 299 | 300 | /* Begin PBXVariantGroup section */ 301 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 302 | isa = PBXVariantGroup; 303 | children = ( 304 | 97C146FB1CF9000F007C117D /* Base */, 305 | ); 306 | name = Main.storyboard; 307 | sourceTree = ""; 308 | }; 309 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 310 | isa = PBXVariantGroup; 311 | children = ( 312 | 97C147001CF9000F007C117D /* Base */, 313 | ); 314 | name = LaunchScreen.storyboard; 315 | sourceTree = ""; 316 | }; 317 | /* End PBXVariantGroup section */ 318 | 319 | /* Begin XCBuildConfiguration section */ 320 | 97C147031CF9000F007C117D /* Debug */ = { 321 | isa = XCBuildConfiguration; 322 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_ANALYZER_NONNULL = YES; 326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 327 | CLANG_CXX_LIBRARY = "libc++"; 328 | CLANG_ENABLE_MODULES = YES; 329 | CLANG_ENABLE_OBJC_ARC = YES; 330 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_COMMA = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 335 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 336 | CLANG_WARN_EMPTY_BODY = YES; 337 | CLANG_WARN_ENUM_CONVERSION = YES; 338 | CLANG_WARN_INFINITE_RECURSION = YES; 339 | CLANG_WARN_INT_CONVERSION = YES; 340 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 341 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 342 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 344 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 345 | CLANG_WARN_STRICT_PROTOTYPES = YES; 346 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 347 | CLANG_WARN_UNREACHABLE_CODE = YES; 348 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 349 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 350 | COPY_PHASE_STRIP = NO; 351 | DEBUG_INFORMATION_FORMAT = dwarf; 352 | ENABLE_STRICT_OBJC_MSGSEND = YES; 353 | ENABLE_TESTABILITY = YES; 354 | GCC_C_LANGUAGE_STANDARD = gnu99; 355 | GCC_DYNAMIC_NO_PIC = NO; 356 | GCC_NO_COMMON_BLOCKS = YES; 357 | GCC_OPTIMIZATION_LEVEL = 0; 358 | GCC_PREPROCESSOR_DEFINITIONS = ( 359 | "DEBUG=1", 360 | "$(inherited)", 361 | ); 362 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 363 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 364 | GCC_WARN_UNDECLARED_SELECTOR = YES; 365 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 366 | GCC_WARN_UNUSED_FUNCTION = YES; 367 | GCC_WARN_UNUSED_VARIABLE = YES; 368 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 369 | MTL_ENABLE_DEBUG_INFO = YES; 370 | ONLY_ACTIVE_ARCH = YES; 371 | SDKROOT = iphoneos; 372 | TARGETED_DEVICE_FAMILY = "1,2"; 373 | }; 374 | name = Debug; 375 | }; 376 | 97C147041CF9000F007C117D /* Release */ = { 377 | isa = XCBuildConfiguration; 378 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 379 | buildSettings = { 380 | ALWAYS_SEARCH_USER_PATHS = NO; 381 | CLANG_ANALYZER_NONNULL = YES; 382 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 383 | CLANG_CXX_LIBRARY = "libc++"; 384 | CLANG_ENABLE_MODULES = YES; 385 | CLANG_ENABLE_OBJC_ARC = YES; 386 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 387 | CLANG_WARN_BOOL_CONVERSION = YES; 388 | CLANG_WARN_COMMA = YES; 389 | CLANG_WARN_CONSTANT_CONVERSION = YES; 390 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 391 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 392 | CLANG_WARN_EMPTY_BODY = YES; 393 | CLANG_WARN_ENUM_CONVERSION = YES; 394 | CLANG_WARN_INFINITE_RECURSION = YES; 395 | CLANG_WARN_INT_CONVERSION = YES; 396 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 397 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 398 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 399 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 400 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 401 | CLANG_WARN_STRICT_PROTOTYPES = YES; 402 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 403 | CLANG_WARN_UNREACHABLE_CODE = YES; 404 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 405 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 406 | COPY_PHASE_STRIP = NO; 407 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 408 | ENABLE_NS_ASSERTIONS = NO; 409 | ENABLE_STRICT_OBJC_MSGSEND = YES; 410 | GCC_C_LANGUAGE_STANDARD = gnu99; 411 | GCC_NO_COMMON_BLOCKS = YES; 412 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 413 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 414 | GCC_WARN_UNDECLARED_SELECTOR = YES; 415 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 416 | GCC_WARN_UNUSED_FUNCTION = YES; 417 | GCC_WARN_UNUSED_VARIABLE = YES; 418 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 419 | MTL_ENABLE_DEBUG_INFO = NO; 420 | SDKROOT = iphoneos; 421 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 422 | TARGETED_DEVICE_FAMILY = "1,2"; 423 | VALIDATE_PRODUCT = YES; 424 | }; 425 | name = Release; 426 | }; 427 | 97C147061CF9000F007C117D /* Debug */ = { 428 | isa = XCBuildConfiguration; 429 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 430 | buildSettings = { 431 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 432 | CLANG_ENABLE_MODULES = YES; 433 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 434 | ENABLE_BITCODE = NO; 435 | FRAMEWORK_SEARCH_PATHS = ( 436 | "$(inherited)", 437 | "$(PROJECT_DIR)/Flutter", 438 | ); 439 | INFOPLIST_FILE = Runner/Info.plist; 440 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 441 | LIBRARY_SEARCH_PATHS = ( 442 | "$(inherited)", 443 | "$(PROJECT_DIR)/Flutter", 444 | ); 445 | PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.contactsPluginExample; 446 | PRODUCT_NAME = "$(TARGET_NAME)"; 447 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 448 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 449 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 450 | SWIFT_VERSION = 4.0; 451 | VERSIONING_SYSTEM = "apple-generic"; 452 | }; 453 | name = Debug; 454 | }; 455 | 97C147071CF9000F007C117D /* Release */ = { 456 | isa = XCBuildConfiguration; 457 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 458 | buildSettings = { 459 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 460 | CLANG_ENABLE_MODULES = YES; 461 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 462 | ENABLE_BITCODE = NO; 463 | FRAMEWORK_SEARCH_PATHS = ( 464 | "$(inherited)", 465 | "$(PROJECT_DIR)/Flutter", 466 | ); 467 | INFOPLIST_FILE = Runner/Info.plist; 468 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 469 | LIBRARY_SEARCH_PATHS = ( 470 | "$(inherited)", 471 | "$(PROJECT_DIR)/Flutter", 472 | ); 473 | PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.contactsPluginExample; 474 | PRODUCT_NAME = "$(TARGET_NAME)"; 475 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 476 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 477 | SWIFT_VERSION = 4.0; 478 | VERSIONING_SYSTEM = "apple-generic"; 479 | }; 480 | name = Release; 481 | }; 482 | /* End XCBuildConfiguration section */ 483 | 484 | /* Begin XCConfigurationList section */ 485 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 486 | isa = XCConfigurationList; 487 | buildConfigurations = ( 488 | 97C147031CF9000F007C117D /* Debug */, 489 | 97C147041CF9000F007C117D /* Release */, 490 | ); 491 | defaultConfigurationIsVisible = 0; 492 | defaultConfigurationName = Release; 493 | }; 494 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 495 | isa = XCConfigurationList; 496 | buildConfigurations = ( 497 | 97C147061CF9000F007C117D /* Debug */, 498 | 97C147071CF9000F007C117D /* Release */, 499 | ); 500 | defaultConfigurationIsVisible = 0; 501 | defaultConfigurationName = Release; 502 | }; 503 | /* End XCConfigurationList section */ 504 | }; 505 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 506 | } 507 | --------------------------------------------------------------------------------