xamarin.android - Permission Denied using Xamarin.Mobile to access contact list xamarin.form -
hey day using xamarin.mobile got error on permission denied added read_contacts in androidmanifest , add permission @ runtime. how solve this?
method
public async task<ienumerable<mobileusercontact>> getallcontacts() { if (_contacts != null) return _contacts; var contacts = new list<mobileusercontact>(); await _book.requestpermission().continuewith(t => { if (!t.result) { log.debug("perm", "permission denied!"); return; } foreach (var contact in _book.where(c => c.emails.any())) // filtering contact's has e-mail addresses { var firstordefault = contact.emails.firstordefault(); if (firstordefault != null) { contacts.add(new mobileusercontact() { contactfirstname = contact.firstname, contactlastname = contact.lastname, contactdisplayname = contact.displayname, contactemailid = firstordefault.address, contactnumber = contact.phones.tostring() }); } } }); _contacts = (from c in contacts orderby c.contactfirstname select c).tolist(); return _contacts; }
looks you'r not asking user permission access contacts.
take in here: https://github.com/jamesmontemagno/permissionsplugin , advise use 1 too: https://github.com/jamesmontemagno/xamarin.plugins/tree/master/contacts
Comments
Post a Comment