I believe in the power of the web ๐ฏ My passion is building mobile Apps with the Ionic Framework.
einfachhans / cordova-plugin-contacts-x Goto Github PK
View Code? Open in Web Editor NEWCordova Plugin for managing contacts
Cordova Plugin for managing contacts
I believe in the power of the web ๐ฏ My passion is building mobile Apps with the Ionic Framework.
Hi there,
I've wanted to use this plugin in my ionic 5 project. sadly, I couldn't find how I have to import it to my project.
I use this plugin in a component.
I can't address ContactsX with window.ContactsX.xyz() and since the whole class is static, I don't know were Ionic instanciates it...
I tried to import it as you said
import ContactsX from 'cordova-plugin-contacts-x'
called the pick() function like so:
ContactsX.pick(function(success){ console.log(success); }, function(error){ console.log(error); });
all I got was the error message:
undefined is not an Object.
Could you help me please? :)
Using the code below the contact is created but the phone number stays empty...
window.ContactsX.save(
{
firstName: "James",
familyName: "Test",
phoneNumebers: [{
type: "mobile",
value: "+36301234567"
}]
},
function(success) {
console.log(JSON.stringify(success));
alert('Contact saved!');
},
function (error) {
console.error(JSON.stringify(error));
alert('Contact NOT saved!');
}
);
Android 11, Huawei P30 Pro.
Removal of compile and runtime configurations
Since its inception, Gradle provided the compile and runtime configurations to declare dependencies. These however did not support a fine grained scoping of dependencies. Hence, better replacements were introduced in Gradle 3.4:
The implementation configuration should be used to declare dependencies which are implementation details of a library: they are not visible to consumers of the library during compilation time.
The api configuration, available only if you apply the java-library plugin, should be used to declare dependencies which are part of the API of a library, that need to be exposed to consumers at compilation time.
Need change this setup
dependencies {
compile 'com.googlecode.libphonenumber:libphonenumber:8.2.0'
}
I Installed the plugin on my Ionic App, but after importing the ContactsX from the module 'cordova-plugin-contacts-x', im trying to call the requestPermission() function but it throws me the next error:
It doesn't appear to be related to the plugin itself, but I cant find the answer.
Any help will be appreciated.
Environment information:
Current Behavior:
build gives following error:
Object literal may only specify known properties, and 'baseCountryCode' does not exist in type 'FindOptions'.
Expected Behavior:
there should be no build errors
Additional information
Adding fields to corresponding interfaces in find-options.d.ts
file fixes the issue.
Alternatively you can use as FindOptions
to cast object when using find()
, but that's temporary workaround.
I'm trying to access the contact numbers using bellow code in Cordova IOS (using Cordova 9)
window.ContactsX.requestPermission((success) => {
if (success.read) {
console.log(success, 'got permission');
window.ContactsX.find((data) => {
console.log(data, 'found contacts');
}, (error) => {
console.error(error, 'contact find error');
}, [ 'phoneNumbers']);
} else {
console.error(success, 'permission denied');
}
});
=======================================================================
window.ContactsX.requestPermission((success) => {
if (success.read) {
console.log(success, 'got permission');
window.ContactsX.find((data) => {
console.log(data, 'found contacts');
}, (error) => {
console.error(error, 'contact find error');
}, {phoneNumbers: true});
} else {
console.error(success, 'permission denied');
}
});
Other properties retrieving properly but with empty contact number array
I go to swift code and change property like billows
class ContactsXOptions {
var firstName: Bool = true;
var middleName: Bool = true;
var familyName: Bool = true;
var phoneNumbers: Bool = true;
var emails: Bool = true;
init(options: NSDictionary?) {
if(options != nil) {
let fields = options?.value(forKey: "fields") as? NSDictionary ?? nil;
if(fields != nil) {
self.parseFields(fields: fields!)
}
}
}
private func parseFields(fields: NSDictionary) {
firstName = fields.value(forKey: "firstName") as? Bool ?? true;
middleName = fields.value(forKey: "middleName") as? Bool ?? true;
familyName = fields.value(forKey: "familyName") as? Bool ?? true;
phoneNumbers = fields.value(forKey: "phoneNumbers") as? Bool ?? false;
emails = fields.value(forKey: "emails") as? Bool ?? false;
}
}
var phoneNumbers: Bool = true; false to true it returns number list as well
is there a special way of sending options list to native code other than above mention code?
Hi, we are having a problem updating the plugin at the application level, we are currently using version 2.0.3 but we want to migrate to version 2.1.0 as the most updated. The steps to update using cordova prepare are followed but the download of the correct version is not achieved, it continues to show version 2.0.3. Here is the evidence of the error.
Current Behavior:
"cordova plugin add cordova-plugin-contacts-x" command install plugin version 2.0.3
"cordova plugin add [email protected]" command install plugin version 2.0.3
"cordova plugin add https://github.com/EinfachHans/cordova-plugin-contacts-x" command install plugin version 2.0.3
Expected Behavior:
"cordova plugin add cordova-plugin-contacts-x" command install plugin version 2.1.0
"cordova plugin add [email protected]" command install plugin version 2.1.0
"cordova plugin add https://github.com/EinfachHans/cordova-plugin-contacts-x" command install plugin version 2.1.0
Steps to reproduce:
Create a new cordova proyect with the command "cordova create myApp"
Add plugin with the comman "cordova plugin add cordova-plugin-contacts-x"
Validate plugin version
Environment information:
Hi guys, we're migrating our app to Angular 14, and Cordova 11. Code is the exact same as before, but now when I build an apk and launch the page that requests permission from the user for contacts. I get this error.
Cannot read properties of undefined (reading 'requestPermission')
Below is the code.
try {
// @ts-ignore
window.ContactsX.requestPermission(function (success: any) {
}, function (error: any) {
console.error(error);
});
} catch (err) {
console.error(err);
}
Is it possible to load contact's photo?
-if user disallow permission and if app is in background and if user try to change permission from phone settings page in android and ios it is killing background process and start app again.it should be display current page in app.and should not kill background process . and should check for permission again
Current Behavior:
When retrieving contacts on iOS I see the "type" property for every phone number is _$!<Other>!$_
. In Android the type is properly set to values like "home", "mobile", etc.
Expected Behavior:
When retrieving contacts on iOS I see the "type" property for every phone number should be set to values like "home", "mobile", etc. (as they appear when viewing contacts in iOS)
Steps to reproduce:
Just do a window.ContactsX.find()
in iOS and inspect the results.
Screenshots:
N/A
Environment information:
Hi!, it would be possible to add an extra parameter that allows filter the contacts by name, surname or any available field y phonebook.
If this feature is already available I didn't find it in the documentation.
I currently using Cordova.
Regards!
Hello Hans,
right now i'm integrating your nice little plugin, is there any chance to add the phoneNumbers type?
Like you do with the Emails?
https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Phone
Thanks
When trying to add "import ContactsX from 'cordova-plugin-contacts-x';" to my typescript file which requires contactsx I get error "cannot find module cordova-plugin-contacts-x". How do I work around this? I have installed the plugin through npm and can see it in window when I console.log(window) on a mobile device.
Hi there, it's me again.
I hope I'm not stupid again :D
It's working fine and the object return on ContactX.pick() looks fine too.
But when I want to do this:
this.name = contactX.firstName
the compiler shows this error:
null is not an object (evaluating this.name = contactX.firstName)
if I do a console.log, contactX.firstName is showing correctly...
Thanks for helping again!
Feature
Hi, we recently use this plugins to replace de official plugin of ionic, but I have a little problem, When I use the "find" method i didnยดt access to "this" scope inside the callback function, can you help me to resolve this please. I currently use ionic with Angular.
Regards
Hello,
I'm building my Cordova app to release in store and I found that the .ipa file has a high size (120MB), instead of previous 45MB. I commented the contacts-x plugin line and it seems is returning to low size.
I inspected the .ipa file and it seems that the contacts plugin added SwiftSupport folder, in the .ipa root folder, with libswiftCore.dylib / libswiftFoundation.dylib etc.. (150+MB). These are duplicated also in the Payload under Frameworks (~40MB).
What can I do to decrease the .ipa size? Because it seems too high.
Current Behavior:
Expected Behavior:
Can anyone help me?
Regards
Bug Report / FIX
Current Behavior:
BUILD FAIL
Using Cordova CLI build on fresh plugin install, two issues arise, which are are now fixed.
FIX:
USING platforms/android/cordova-plugin-contacts-x/app-build.gradle
UPDATE class path:
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
// classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:7.0.4'
}
}
UPDATE "compile":
dependencies {
// compile 'com.googlecode.libphonenumber:libphonenumber:8.2.0'
implementation 'com.googlecode.libphonenumber:libphonenumber:8.2.0'
}
Could you please share, how it working in ionic 4 or greater
Hello!
I'm curious, why this plugin does not follow contact picker api?
https://developer.mozilla.org/en-US/docs/Web/API/ContactsManager/getProperties
It would help avoid writing additional code for webview.
Thank you!
Hi, I currently use this plugin, and works perfectly. Actually i have a big problem, a few users has around 10k contacts and the app crash :( . I see the pick function but i have a question, it's possible select multiple contacts?. Or some way to keep open pick windows to select and use?.
Thanks
Regards
There is a serious problem for iOS platform 6.2.
The access contact permission cannot be seen from iPhone settings of app itself. It means user has no way to turn it on allowing App to read contact. However, platform 6.1.2 seems ok.
I try keep both corodva-plugin-contacts and cordova-plugin-contacts-x installed and now the access permission can be seen from in iPhone's setting page.
Please help.
Current Behavior:
I'm trying to run a build using Xcode 11.3 and it fails with the following error message:
[21:45:48] /tmp/download/platforms/ios/testproject/Plugins/cordova-plugin-contacts-x/ContactsX.swift:19:32: error: cannot convert value of type '(_) -> ()' to expected argument type 'CDVInvokedUrlCommand'
[21:45:48] self.hasPermission { (granted) in
[21:45:48] ^~~~~~~~~~~~~~
[21:45:48] /tmp/download/platforms/ios/testproject/Plugins/cordova-plugin-contacts-x/ContactsX.swift:74:28: error: cannot convert value of type '(_) -> ()' to expected argument type 'CDVInvokedUrlCommand'
[21:45:48] self.hasPermission { (granted) in
Environment information:
Cordova CLI v10.0.0
cordova-ios v6.1.0
cordova-plugin-contacts-x v1.1.0
Monaca.io remote build tool (running Xcode 11.3)
Unfortunately I know next to nothing about Swift, so haven't been able to debug it myself. The best I could find online was a reference to Swift 3 code throwing similar errors in Xcode versions where Swift 4+ is required.
P.S. Thanks for creating the plugin. Has worked perfectly on Android and performs better than any of the alternatives.
I am not sure if it's a bug, but while working, I came across one issue where I pressed "deny" option when permission dialog was invoked. My plan was to present user with a dialog asking for permissions for feature to work. But when app is requesting permissions again, it's just not requesting it anymore (by invoking permission dialog) but giving me previous results "false" directly.
Current Behavior:
App runs fine on device from CLI, but crashes upon launch if installed from PlayStore.
Expected Behavior:
App should run fine if downloaded from PlayStore.
Steps to reproduce:
cordova run android = runs fine
Download from PlayStore = crash.
Screenshots:
Not aplicable.
Environment information:
Cordova CLI version
11.0.0
Cordova platform version
android 10.1.1
browser 6.0.0
ios 6.2.0
Plugins & versions installed in project (including this plugin)
cordova-plugin-add-swift-support 2.0.2 "AddSwiftSupport"
cordova-plugin-android-notification-manager 0.0.1 "Notification Manager"
cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
cordova-plugin-app-version 0.1.12 "AppVersion"
cordova-plugin-camera-with-exif 1.4.3 "cordova-plugin-camera-with-exif"
cordova-plugin-contacts-x 2.0.3 "ContactsX"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-geolocation 4.1.0 "Geolocation"
cordova-plugin-keyboard 1.2.0 "Keyboard"
cordova-plugin-media 5.0.4 "Media"
cordova-plugin-network-information 3.0.0 "Network Information"
cordova-plugin-push-notifications 1.0.1 "cordova-plugin-push-notifications"
cordova-plugin-statusbar 3.0.0 "StatusBar"
cordova-universal-links-plugin 1.2.1 "Universal Links Plugin"
cordova.plugins.diagnostic 6.1.1 "Diagnostic"
Additional information
config.xml permissions manifest:
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
</config-file>
adb catlog:
03-01 17:15:36.141 12367 13242 D OpenGLRenderer: RenderThread::setGrContext()
03-01 17:15:36.141 12367 12367 D AndroidRuntime: Shutting down VM
03-01 17:15:36.141 12367 12367 E AndroidRuntime: FATAL EXCEPTION: main
03-01 17:15:36.141 12367 12367 E AndroidRuntime: Process: tld.app, PID: 12367
03-01 17:15:36.141 12367 12367 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{tld.app/tld.app.MainActivity}: java.lang.RuntimeException: Failed to create webview.
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4031)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4197)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2434)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:226)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.os.Looper.loop(Looper.java:313)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8633)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: Caused by: java.lang.RuntimeException: Failed to create webview.
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at e.a.a.u.C(Unknown Source:51)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at e.a.a.g.Q(Unknown Source:2)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at e.a.a.g.P(Unknown Source:2)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at e.a.a.g.s(Unknown Source:0)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at e.a.a.g.N(Unknown Source:4)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at tld.app.MainActivity.onCreate(Unknown Source:28)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8282)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8262)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1335)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4005)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: ... 12 more
03-01 17:15:36.141 12367 12367 E AndroidRuntime: Caused by: java.lang.NoSuchMethodException: e.a.a.e0.f. [class android.content.Context, class e.a.a.q]
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at java.lang.Class.getConstructor0(Class.java:2363)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at java.lang.Class.getConstructor(Class.java:1759)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: at e.a.a.u.C(Unknown Source:29)
03-01 17:15:36.141 12367 12367 E AndroidRuntime: ... 21 more
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.