Share messages and files from browser, a lepont plugin
MIT License
Share messages and files from browser, a lepont plugin
After initializing react-native:
npm i --save lepont @lepont/share react-native-share
# or
yarn add lepont @lepont/share react-native-share
And then:
npx pod-install
React Native side:
import { useBridge } from 'lepont'
import { ShareBridge } from '@lepont/share/bridge'
import Share from 'react-native-share'
import { WebView } from 'react-native-webview'
const App = () => {
const [ref, onMessage] = useRegistry(ShareBridge(Share))
return (
<WebView
source={{ uri: 'Web.bundle/index.html' }}
javaScriptEnabled
ref={ref}
onMessage={onMessage}
/>
)
}
export default App
Browser side:
import { share } from '@lepont/share'
await share({
message: 'Share from my app!'
})
import { share } from '@lepont/share'
share(options: Options): Promise<void>
type Options = {
/** array of base64 string you want to share */
urls?: string[]
/** array of filename for base64 urls array (only works for Android */
filenames?: string[]
/** File mime type ex. "image/png" */
type?: string
/** The message to share */
message?: string
/** The title of the message */
title?: string
}
Shares the given contents and sends the data to other Apps.
MIT