UADetect canShareData
Method
Description
Tests if the data that you specify can be shared via the Web Share API
Arguments
Takes one optional argument. This is the data to be tested if it can be shared. If no data is specified, the method will still run, but generically. The data to be shared must be in this interface
interface ShareData { files?: File[]; text?: string; title?: string; url?: string;}
Possible Returns
A boolean value of
true
false
Usage Example
import { canShareData } from 'uadetect'const testData = canShareData({ url: "https://example.com", title: "Example", text: "Example Website"})if (testData == true) { navigator.shareData()} else { // Not supported // do something else}
Note:
Note:
vibrate
does not work on Firefox for desktop or android.- It also does not work of Android WebView
- It will
console.error()
if you try to use it in those environments.
Table of Contents