0.2.2 • Published 5 years ago
@lepont/share v0.2.2
@lepont/share v0.2.2
Share messages and files from browser, a lepont plugin
Install
After initializing react-native:
npm i --save lepont @lepont/share react-native-share
# or
yarn add lepont @lepont/share react-native-shareAnd then:
npx pod-installUsage
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 AppBrowser side:
import { share } from '@lepont/share'
await share({
  message: 'Share from my app!'
})API
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.
License
MIT