9

We can use phone's (android/ Iphones) native share functionality to share different content from apps. Is it also possible to invoke this share functionality through browser using javascript in all smart phones? So that on some event in browser, we can load share widget.

Thanks.

Justin
  • 26,443
  • 16
  • 111
  • 128
sonam
  • 875
  • 2
  • 18
  • 37
  • Possible duplicated of https://stackoverflow.com/questions/15921262/is-it-possible-to-trigger-share-menu-on-smartphones-via-html-js – Moradnejad Jul 09 '17 at 10:42
  • Possible duplicate of [Is it possible to trigger share menu on smartphones (via HTML/JS)?](https://stackoverflow.com/questions/15921262/is-it-possible-to-trigger-share-menu-on-smartphones-via-html-js) – Moradnejad Jul 09 '17 at 10:42

3 Answers3

4

Yes now you can share it with Javascript for Android. Follow link if you need more details or say thanks

https://sdtuts.com/javascript-android-native-share-popup-navigator-share-api/

async function AndroidNativeShare(Title,URL,Description){
  if(typeof navigator.share==='undefined' || !navigator.share){
    alert('Your browser does not support Android Native Share');
  } else {
    const TitleConst = Title;
    const URLConst = URL;
    const DescriptionConst = Description;

    try{
      await navigator.share({title:TitleConst, text:DescriptionConst, url:URLConst});
    } catch (error) {
    console.log('Error sharing: ' + error);
    return;
    }   
  }
} 

$(".share_button").click(function(){
  AndroidNativeShare('My Page Title', 'https://google.com','This is description'); 
});
  • 2
    Code only answers arent encouraged as they dont provide much information for future readers please provide some explanation to what you have written – WhatsThePoint Jan 24 '18 at 20:50
1

For iOS/Android it is only possible if a UIWebView is opened within an app, but not from the native Safari/Chrome standalone browsers.

From in-app web view: How to Call Native Iphone/Android function from Javascript?

Community
  • 1
  • 1
Justin
  • 26,443
  • 16
  • 111
  • 128
0

Not jquery per se but Chrome for Android and Android's native browser have support for this: https://developer.chrome.com/multidevice/android/intents

Unfortunately the documentation is VERY limited as I'm trying to figure out how to share a link via the share dialog (giving the user the option to select which app to share the link with) myself.

REJH
  • 3,273
  • 5
  • 31
  • 56