[React Native] 如何分享 AirDrop only?

我在SO里也提了该问题,就是我想要把分享设为只有 AirDrop 一项,去掉其它的,如:
image.png

而不是:
image.png

How to Share AirDrop only in React Native?
很期待SegmentFault > StackOverflow 耀武扬威的时刻到了

阅读 1.5k
1 个回答

Only a demo

Share.share({
                message:'MSG',
                url:'URL',
                title:'RN',
            },{
                 dialogTitle:'Stephanie',
                 excludedActivityTypes:[
                    //把你不想要展示的内容同通过放在这里
                    //这里仅仅展示一个;其他的自己添加;我在下面给出其他选项
                    'com.apple.UIKit'.activity.PostToFacebook
                ],
                  tintColor:'green'
            }).then(this._showResult).catch(error) => this.setState({result:'error:' + error.message});

extension UIActivity.ActivityType {

    @available(iOS 6.0, *)
    public static let postToFacebook: UIActivity.ActivityType

    @available(iOS 6.0, *)
    public static let postToTwitter: UIActivity.ActivityType

    @available(iOS 6.0, *)
    public static let postToWeibo: UIActivity.ActivityType

    @available(iOS 6.0, *)
    public static let message: UIActivity.ActivityType

    @available(iOS 6.0, *)
    public static let mail: UIActivity.ActivityType

    @available(iOS 6.0, *)
    public static let print: UIActivity.ActivityType

    @available(iOS 6.0, *)
    public static let copyToPasteboard: UIActivity.ActivityType

    @available(iOS 6.0, *)
    public static let assignToContact: UIActivity.ActivityType

    @available(iOS 6.0, *)
    public static let saveToCameraRoll: UIActivity.ActivityType

    @available(iOS 7.0, *)
    public static let addToReadingList: UIActivity.ActivityType

    @available(iOS 7.0, *)
    public static let postToFlickr: UIActivity.ActivityType

    @available(iOS 7.0, *)
    public static let postToVimeo: UIActivity.ActivityType

    @available(iOS 7.0, *)
    public static let postToTencentWeibo: UIActivity.ActivityType

    @available(iOS 7.0, *)
    public static let airDrop: UIActivity.ActivityType

    @available(iOS 9.0, *)
    public static let openInIBooks: UIActivity.ActivityType

    @available(iOS 11.0, *)
    public static let markupAsPDF: UIActivity.ActivityType
}

如果使用其他组件应该也会有类似excludedActivityTypes的字段,道理是一样的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏