terikon / cordova-plugin-photo-library

Maintainer needed. Please contact if you're using this library in your project
MIT License
149 stars 295 forks source link

[iOS device ]Can not display image when using Photo Library #109

Open totoro0103 opened 6 years ago

totoro0103 commented 6 years ago

I have a issues that i can not understand. It's here: https://forum.ionicframework.com/t/ios-device-can-not-display-image-when-using-photo-library/114197 Please help me !

jaybloke commented 6 years ago

If you are using WKWebview, custom schemes like cdvphotolibrary:// are not [yet] supported. I had a similar problem and had to revert back to UIWebView --- that's the only way I could get this plugin to work.

See https://github.com/terikon/cordova-plugin-photo-library/issues/41 for more info.

totoro0103 commented 6 years ago

thank a lot @jaybloke . I had solve my issue:

  1. I remove(not reinstall) WKWebview: ionic cordova plugin rm cordova-plugin-ionic-webview --save
  2. In config.xml. Add 3 line :
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />

    And it's work !

jaybloke commented 6 years ago

Following your steps @hoangphan92 above, it looks like you have not re-installed WKWebview - you have simply uninstalled WKWebview, so the default web view plugin will be used - UIWebView.

To see if WKWebview is installed correctly, try adding this to your main app component:

if (window.indexedDB) {
  console.log('I have WKWebview installed!');
} else {
  console.log('I have UIWebView installed!');
}
totoro0103 commented 6 years ago

I'm so sorry @jaybloke . I mean: remove WKWebview. OMG ! ,my english is very bad

abcdurga commented 6 years ago

This works like a charm:-

If you are using wkwebview(which is now default for new apps) then follow below steps,

import { normalizeURL} from ‘ionic-angular’;

store your image path in some new variable.
var imagePath = this.file.dataDirectory + “test.png”;
this.tempImagePath = normalizeURL(imagePath);

then in your html file,
use tempImagePath as image src.

Source: https://forum.ionicframework.com/t/downloaded-image-is-not-displayed-ionic-3-8/110912/2

soulmecca commented 6 years ago

With WKWebview, this plugin is still not working. The workaround by @abcdurga only works with files ("file://") but the actual url (photoURL or thumbnailURL) I have to use is starting with "cdvphotolibrary://" which I cannot show with . I hope this will be fixed soon or to find any workaround.

Thanks for your great plugin.

boyfunky commented 6 years ago

@soulmecca were you able to find a way around this issue? i am facing the same thing as well even in my android phone. my photoURL starts with 'cdvphotolibrary://' and i cannot show my images as well

jaybloke commented 6 years ago

Unfortunately not @boyfunky - this was, and still is the deal-breaker for upgrading to WKWebview --- i'm still using UIWebView 👎

BrentonWatt commented 6 years ago

It's not really a fix but a kind of work around. I was saving the images directories to a SQLiteDB so with the WKWebview change I could no longer display my images so what I instead did is save the image ID provided in the saveImage() return object in photo-library, then when I need to use that image I use the getPhoto() call and pass the saved ID and then returns blob data, I then convert that blob data to base64 and use that for my image source.

I'm aware it's not suitable for everyone's needs but I thought of posting here in case it could help someone.

timmyrosen commented 5 years ago

Is there an update on this yet?

Reverting back to UIWebView is the last option for me really. This is such an old issue, someone must have solved it right?