question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ionic 3 - Can't get android contact photo

See original GitHub issue

There is some days that i search a solution to my problem.

I use the Ionic Contacts plugin ( https://ionicframework.com/docs/native/contacts/ ) and i need to get the photos of my contact list. In iOS it work but in android it won’t.

I tried to sanitize,normalizeURL, and all that i found on the internet but it won’t work.

Here’s my code ;

home.ts

userPhoto: any;
  getContacts() {
    this.contacts.find(['displayName', 'name', 'phoneNumbers', 'emails', 'photos'], {filter: "", multiple: true})
        .then(data => {
          console.table(data[0]);
          this.userName = data[0].displayName;
          this.userPhoto = this.sanitizer.bypassSecurityTrustUrl(data[0].photos[0].value);
        });
  }

home.html

  <button ion-button (click)="getContacts()">Get contacts</button>

  <p>Nom : {{ userName }}</p>

  <hr />
  <img [src]="userPhoto" style="width: 100px;">

The error that i got in Chrome inspector:

Not allowed to load local resource: content://com.android.contacts/contacts/1/photo

Does you have any solution ?

Thanks you,

Dylan

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DydjyZcommented, Sep 1, 2018

Hello,

Thanks you it effectively was the cordova-plugin-ionic-webview plugin, when i removed it it worked !

Thanks you ou saved me a lot of time 👍

Dylan

0reactions
1AbhinavMauryacommented, Feb 7, 2019

yup i also tried everything but img is not display

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get contacts images Ionic 3 - angular - Stack Overflow
import { DomSanitizer } from '@angular/platform-browser';. Define Component Class method sanitizeImage(value){ return this.sanitizer.
Read more >
Image not displaying while displaying contacts - Ionic Forum
it is trying to fetch the image as that box is visible only in contacts which have photo,but its not able to display...
Read more >
Ionic Native: Accessing iOS Photos and Android Gallery, Part I
In today's post, we'll take a look at the first of two ways to easily get images from the Gallery on Android and...
Read more >
Camera Capacitor Plugin API
The Camera API provides the ability to take a photo with the camera or choose an existing one from the photo album.
Read more >
Camera and Image picker in Ionic 5 apps - Enappd
Step 3 — Use Camera / Image Picker Plugin In App ; DATA_URL · FILE_URI · Return file uri (content://media/external/images/media/2 for Android). NATIVE_URI,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found