-->

'Share Functionality' for Mobile Web Apps

2019-08-07 05:43发布

问题:

If I add a 'mailto:' link to my Mobile web app, smartphones know to open up the native mail app, is there something similar for 'sharing'?

I ask because on my Android 2.2, if I 'select text' using the browser's menu option, and then I select some text, I get presented with a 'share via' option that opens a native dialog with options to share via gmail, facebook, etc... I'd like to trigger this dialog from my Mobile Web App. Is this possible?

Thanks in advance for any help, much appreciated as I couldn't figure it out on my own. :)

回答1:

Here a tutorial but I don't know if it works for mobile web apps.

http://mobile.tutsplus.com/tutorials/android/android-sdk-implement-a-share-intent/



回答2:

If your web app is wrapped in a native layer (via Phonegap or by manually creating the native layer yourself), you can communicate your intention to share to the native layer by various means (like providing a url with a custom protocol that only your native layer intercepts, or via javascript callback functions) and delegate the share intent to your native layer.

Any data needed to be shared can be parsed from the custom url or be passed as parameters in the callback function.