react-native调用系统分享组件Share组件的使用

版权声明:本文为博主原创文章,若需转载,请注明出处 https://blog.csdn.net/suwu150/article/details/83088364

title: React-Native调用系统分享Share组件的使用

一. 方法

  • share
  • sharedAction
  • dismissedAction

二、具体说明

1.share
接口:
static share(content, options)

打开一个分享文本内容的对话框

  • 在 iOS 中,返回一个 Promise,最终会解析为一个对象,包含有action和activityType两个属性。如果用户取消对话框,则 Promise 仍将被解析,最终返回的action属性会是Share.dismissedAction,而其他属性为 undefined。
  • 在 Android 中同样返回一个 Promise,但返回的action始终为Share.sharedAction。

In iOS, Returns a Promise which will be invoked an object containing action, activityType. If the user dismissed the dialog, the Promise will still be resolved with action being Share.dismissedAction and all the other keys being undefined.
In Android, Returns a Promise which always be resolved with action being Share.sharedAction.

Content参数说明
   - message - 要分享的消息
   - title - 消息的标题
   - url - 要分享的网址,(iOS系统中特有)

至少需要一个 url 和message。

options参数说明
ios
	- subject - 通过邮件分享的标题
	- excludedActivityTypes
	- tintColor
android
	- dialogTitle
2 sharedAction()
接口:
static sharedAction()

表示内容已成功分享。

3 dismissedAction()
接口:
static dismissedAction()

表示对话框被取消。仅限 iOS系统。

三. 效果如下所示

ios系统测试,调起系统分享

猜你喜欢

转载自blog.csdn.net/suwu150/article/details/83088364