navigator.share not working in mobile browser(chrome v64)

Gopakumar N G picture Gopakumar N G · Feb 15, 2018 · Viewed 13.1k times · Source

I have been trying to trigger the Intent Share in the Android browser from javascript using the navigator.share.

Following is an example code:

$("#printTest").click(function(e){
    if (navigator.share === undefined){
        alert('Undefined!');
    }
    else{
        alert('Sharing!');
        navigator.share({title: 'Example Page', text: 'https://example.com'});
    }
});

When I try to click on the button from chrome in ubuntu, it opens a window for sharing(which shows no apps to select though). But the same is not working on any android mobile browser. I have tested in Chrome for Android version 64 and Chrome for Android Dev also. All of the shows the alert 'Undefined' even after enabling the flag chrome://flags/#enable-experimental-web-platform-features.

Answer

Gopakumar N G picture Gopakumar N G · Feb 16, 2018

navigator.share will only work on websites with https and not HTTP