【发布时间】:2021-09-12 14:12:20
【问题描述】:
我正在尝试让我的应用程序允许共享到其他应用程序,但我似乎无法弄清楚。
我正在使用 React JS 并尝试使用以下代码
// Check if navigator.share is supported by the browser
if (navigator.share) {
console.log("Congrats! Your browser supports Web Share API");
navigator
.share({
url: "https://www.google.com",
text: "add text",
title: "Your Discovery",
})
.then(() => {
console.log("Sharing successfull");
})
.catch(() => {
console.log("Sharing failed");
});
} else {
console.log("Sorry! Your browser does not support Web Share API");
}
};
我收集到这不适用于我的应用程序,因为它不受支持的浏览器类型。但是想知道如果我通过我的应用程序启动应用程序内浏览器是否可以工作?
或者有谁知道如何将本机共享功能添加到 react js 应用程序。
谢谢。
【问题讨论】:
-
您是否在真实设备浏览器(智能手机)中尝试过?我想这应该在这种情况下工作