0.2.2 • Published 4 years ago

@lepont/share v0.2.2

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

@lepont/share v0.2.2

ci codecov

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-share

And then:

npx pod-install

Usage

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!'
})

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

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago