New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-native-sc-share

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-sc-share

this is a share component for react-native

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

react-native-sc-share

集成umeng分享模块,支持微信,微信朋友圈,QQ,QQ朋友圈,支付宝分享

umeng合规文档地址:https://developer.umeng.com/docs/147377/detail/210664

1.安装

$ npm install react-native-sc-share --save

2.手动安装部分

Android

1.微信

1.1 添加回调Activity

在包名目录下创建wxapi文件夹,新建一个名为WXEntryActivity的activity继承WXCallbackActivity

1.2 添加FileProvider

<provider
	android:name="android.support.v4.content.FileProvider"
	android:authorities="${applicationId}.fileprovider"
	android:exported="false"
	android:grantUriPermissions="true">
	<meta-data
		android:name="android.support.FILE_PROVIDER_PATHS"
		android:resource="@xml/filepaths "/>
</provider>	 

在res/xml目录(如果没有xml目录,则新建一个)下,添加文件filepaths.xml,内容如下:

<?xml version="1.0" encoding="utf-8"?>
<paths>
	<root-path name="opensdk_root" path=""/>
	<external-files-path name="umeng_cache" path="umeng_cache/"/>
</paths>

2.qq

2.1 添加回调Activity

在包名目录下创建apshare文件夹,新建一个名为ShareEntryActivity的activity继承ShareCallbackActivity

2.2 添加FileProvider
<provider
	android:name="android.support.v4.content.FileProvider"
	android:authorities="${applicationId}.fileprovider"
	android:exported="false"
	android:grantUriPermissions="true">
	<meta-data
		android:name="android.support.FILE_PROVIDER_PATHS"
		android:resource="@xml/filepaths" />
</provider> 

在res/xml目录(如果没有xml目录,则新建一个)下,添加文件filepaths.xml,内容如下:

<root-path name="opensdk_root" path=""/>
<external-files-path name="opensdk_external" path="Images/tmp"/>
2.3 添加qqappid

在app/build.gradle中添加如下代码:

android {
	defaultConfig {  
		manifestPlaceholders = [qqappid: "qq的appid"]
	}
} 

iOS

3.使用

3.1 引入

import {Share,SHARE_PLATFORM} from 'react-native-share'

3.2 预初始化(隐私协议同意前调用)

Share.preInit({
   appkey:appkey,		//appkey,必填
   channel: channel	//渠道,可选     
});

3.3 初始化(隐私协议同意后调用)

Share.init({
   isDebug:true,					//调试模式是否打开,可选
   appkey:appkey,					//appkey,必填
   wx:{							//微信配置,可选
   	appId: "", 					//appId
   	appSecret:""				//appSecret
   },
   qq:{							//qq配置,可选
   	appId: "",					//appId
   	appSecret:""				//appSecret					
   },
   ali:{							//支付宝配置,可选
   	appId:""					//appId
   }
   	
});

3.4 分享

Share.share({
   title:"",							//标题
   desc:"",							//描述
   url:"",								//链接	
   img:"",								//图片
   platform:SHARE_PLATFORM.WEIXIN,		//平台	
   wx:{								//微信小程序配置,可选
   	miniId:"", 						//小程序id
   	path:""							//小程序路径
   },
   qq: {                            	//QQ小程序配置,可选
   	miniId: "",						//小程序id
   	path: "",						//小程序路径
   }
}).then(res=>{
   console.log(res)
}).catch(err=>{
   console.log(err)
})

3.5 多个平台分享弹窗

Share.shareWithPanel({
   title:"",							//标题
   desc:"",							//描述
   url:"",								//链接	
   img:"",								//图片
   platforms:[SHARE_PLATFORM.WEIXIN,SHARE_PLATFORM.WEIXIN_CIRCLE,SHARE_PLATFORM.ALIPAY, SHARE_PLATFORM.QQ], 				 //需要显示的平台	
   wx:{								//微信小程序配置,可选
   	miniId:"", 						//小程序id
   	path:""							//小程序路径
   },
   qq: {                            	//QQ小程序配置,可选
   	miniId: "",						//小程序id
   	path: "",						//小程序路径
   },
   ali:{								//支付宝小程序配置,可选	
   	scheme: string;					//小程序scheme,会替换url,场景:分享链接跳转支付宝小程序指定页面
   }
}).then(res=>{
   console.log(res)
}).catch(err=>{
   console.log(err)
})

Keywords

react-native

FAQs

Package last updated on 26 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts