【问题标题】:Can we invoke smart phone's native share functionality with jquery?我们可以用 jquery 调用智能手机的原生共享功能吗?
【发布时间】:2013-11-24 13:56:35
【问题描述】:

我们可以使用手机 (android/Iphones) 的原生分享功能来分享来自应用的不同内容。是否也可以在所有智能手机中使用 javascript 通过浏览器调用此共享功能?这样在浏览器中的某些事件上,我们可以加载共享小部件。

谢谢。

【问题讨论】:

标签: javascript android jquery ios


【解决方案1】:

是的,现在您可以使用适用于 Android 的 Javascript 共享它。 如果您需要更多详细信息或表示感谢,请点击链接

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】:

对于 iOS/Android,只有在应用程序中打开 UIWebView 时才有可能,而不是从原生 Safari/Chrome 独立浏览器中打开。

来自应用内网页视图:How to Call Native Iphone/Android function from Javascript?

【讨论】:

    【解决方案3】:

    不是 jquery 本身,而是 Chrome for Android 和 Android 的本机浏览器对此提供支持: https://developer.chrome.com/multidevice/android/intents

    不幸的是,文档非常有限,因为我试图弄清楚如何通过共享对话框共享链接(让用户可以选择与哪个应用共享链接)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 1970-01-01
      • 1970-01-01
      • 2022-07-04
      • 2022-12-28
      • 2020-04-21
      • 2011-01-04
      相关资源
      最近更新 更多