Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Ionic 3 - Can't get android contact photo #165

Closed
DydjyZ opened this issue Aug 29, 2018 · 10 comments
Closed

Ionic 3 - Can't get android contact photo #165

DydjyZ opened this issue Aug 29, 2018 · 10 comments
Labels

Comments

@DydjyZ
Copy link

DydjyZ commented Aug 29, 2018

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

@janpio janpio added the support label Aug 29, 2018
@janpio
Copy link
Member

janpio commented Aug 29, 2018

Here is some code that definitely used to work: https://github.com/janpio/ionic-native-contacts/blob/master/src/pages/home/home.ts#L29

@DydjyZ
Copy link
Author

DydjyZ commented Aug 29, 2018

Hello, thanks you for your answer, i already tried to solve my problem with this repo but it's the same...

Not allowed to load local resource: content://com.android.contacts/contacts/381/photo (index):1 Not allowed to load local resource: content://com.android.contacts/contacts/542/photo (index):1 Not allowed to load local resource: content://com.android.contacts/contacts/543/photo (index):1 Not allowed to load local resource: content://com.android.contacts/contacts/730/photo

I tried with the emulator, with two different android phones, without livereload...

@janpio
Copy link
Member

janpio commented Aug 29, 2018

What is your ionic info output?
Did you download the app I linked to, install it and run it with the configuration there is?

@DydjyZ
Copy link
Author

DydjyZ commented Aug 29, 2018

Here's my ionic info :

✔ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)  : 4.1.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.0, (and 6 other plugins)

System:

   ios-deploy : 1.9.2
   NodeJS     : v8.9.3 (/usr/local/bin/node)
   npm        : 5.6.0
   OS         : macOS High Sierra
   Xcode      : Xcode 9.4.1 Build version 9F2000

I just saw when i download your code and start into my smartphone the app, it work, but when I copy the home.ts/.html code into my app, it won't work...

I didn't see any difference between these two apps except there is not the same version of ionic..

@janpio
Copy link
Member

janpio commented Aug 29, 2018

Compare ionic cordova platform list, ionic cordova plugin list and package.json in total - my guess it's a plugin.

@DydjyZ
Copy link
Author

DydjyZ commented Aug 29, 2018

I think it's not a plugin error because it's a blank projets.. so I anyway inspect the plugins and there is no difference between the two apps except the ionic version..

@janpio
Copy link
Member

janpio commented Aug 29, 2018

Your ionic info output shows cordova-plugin-ionic-webview 2.1.0 which did not exist back when I created the demo repository.

@DydjyZ
Copy link
Author

DydjyZ commented 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

@Pezhvak
Copy link

Pezhvak commented Jan 9, 2019

i tried everything i just removed the webview plugin as well. can't make it to work

@1AbhinavMaurya
Copy link

yup i also tried everything but img is not display

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants