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.

Not working on iOS devices

See original GitHub issue

Hello,

I´m using html2canvas with Wordpress. It works fine on every desktop/android device but iOS is not working. I have tested iPhone SE (iOS 11.2.1) Safari/Chrome and iPad 2 (iOS 9.3.5) Safari/Chrome. I´m using 1.0.0-alpha.9 html2canvas. It returns only white background as img. You can test it here - http://konf.inforadar.sk - “Uložit do galerie” is a save to gallery button and in top right corner is a gallery (galeria).

Code:

<script src="inc/html2canvas.min.js"></script>
<script type="text/javascript">
jQuery(document).on("click", "#vpc-add-to-cart", function(event) { takeScreenshot(); event.stopImmediatePropagation(); } );
function takeScreenshot() {
    var element = jQuery("#vpc-preview")[0];
    html2canvas(element, { "background": "#FFFFFF" }).then(function(canvas) {
        var imgData = canvas.toDataURL('image/jpeg',1.0);
        jQuery.ajax({
            url: 'gallery/save.php',
            type: 'post',
            dataType: 'text',
            data: { base64data: imgData }
        });
        window.alert('Uloženo!');
    });
}
</script>

Any advice? Thank you very much!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:15

github_iconTop GitHub Comments

3reactions
0xmaayancommented, Aug 14, 2020

found this solution.

 var s = document.createElement("script");
  if(isSafari()){
    s.src = "https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-alpha1/html2canvas.min.js";
  }else{
    s.type = "text/javascript";
    s.src = "js/scripts/html2canvas.js"; // version html2canvas 1.0.0-rc.7
  }
  
  $("head").append(s);

https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-alpha1/html2canvas.min.js seems to be working on safari/IOS devices but not on chrome/android

0reactions
pravnvijicommented, Nov 7, 2020

@msbir

Thanks for sharing this solution. For Safari, it’s working now with [ 1.0.0-rc.7 js]

Is there is any generic library for both browsers? Currently, I’m using this library for Android and IOS [ Chrome and Safari ] for hybrid mobile application.

Now to achieve this I’m loading 2 different html2canvas.min.js. If you could share common js [ CDN link ] which support both platforms it will be very helpful to optimize the app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

If your iPhone or iPad won't connect to a Wi-Fi network
If you're using iOS or iPadOS 15 or later, tap Settings > General > Transfer or Reset [Device] > Reset > Reset Network...
Read more >
A device attached to the system is not functioning? Easy fix here!
The first thing to check ... In some cases, the error can occur because of a connectivity issue between the USB device (in...
Read more >
Troubleshoot managed iOS devices for users - Google Support
If the user's device is set up correctly, make sure that iOS Sync is enabled for the device: Sign in to your Google...
Read more >
[Solved] How to Fix Move to iOS Not Working - iMobie Help
How to Fix Move to iOS Not Working · 1. Check and Download the latest firmware on both devices. · 2. Set your...
Read more >
iOS 16 Problems: 11 Common iPhone Issues and How to Fix ...
Simply restarting the iPhone may resolve wi-fi issues. Also, make sure the wi-fi network is active and online for other devices. If all...
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