8000 GitHub - tutcugil/cordova-plugin-web-share: Web Share API polyfill for Cordova
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tutcugil/cordova-plugin-web-share

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-web-share
NPM version NPM downloads Twitter

Web Share API polyfill for Cordova

Installation

cordova plugin add cordova-plugin-web-share --save

Supported Platforms

  • iOS
  • Android

Methods

Plugin polyfills stadards-based Web Share API to trigger native platform-specific dialogs. The first argument in navigator.share is an options object, that might have title, text and url properties (all optional).

navigator.share({
    title: "Share topic",
    text: "Share message",
    url: "Share url"
}).then(() => {
    console.log("Data was shared successfully");
}).catch((err) => {
    console.error("Share failed:", err.message);
});

Method returns a Promise object that resolved on success.

Additionally to the standard, the plugin detects which activity was used to share. Resolved value is an array of selected activity names:

navigator.share({...}).then((packageNames) => {
    if (packageNames.length > 0) {
        console.log("Shared successfully with activity", packageNames[0]);
    } else {
        console.log("Share was aborted");
    }
}).catch((err) => {
    console.error("Share failed:", err.message);
});

About

Web Share API polyfill for Cordova

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 48.2%
  • Objective-C 42.7%
  • JavaScript 9.1%
0