react-native-qy-library
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

react-native-qy-library

Getting started

$ npm install react-native-qy-library --save

Mostly automatic installation

$ react-native link react-native-qy-library

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-qy-library and add RNQyLibrary.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNQyLibrary.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.qy.RNQyLibraryPackage; to the imports at the top of the file
  • Add new RNQyLibraryPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-qy-library'
    project(':react-native-qy-library').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-qy-library/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-qy-library')
    

Usage

import RNQyLibrary from 'react-native-qy-library';

// TODO: What to do with the module?
RNQyLibrary;

原生功能调用

系统功能

位置信息

图片

通讯录

存储

android 和 iOS独有

具体调用方法

toSystemSetting()

属性 说明 类型 示例
打开系统设置界面

getAppVersion()

属性 说明 类型 示例
app 版本号 string "v1.0.0"

getGps(appName: string)

属性 说明 类型 示例
success 权限是否同意 boolean true 同意 false 拒绝
data { success: '是否成功(boolean)',latitude: '经度(string)', longitude:'纬度(string)' } object
info 提示 string

checkGpsOpen()

属性 说明 类型 示例
检查位置信息是否打开 boolean true 打开 false 关闭

openCameraForImage(appName: string) app名称

属性 说明 类型 示例
success 权限是否同意 boolean true 同意 false 拒绝
data 照片路径 string
info 提示 string

openTukuForImage()

属性 说明 类型 示例
照片路径 string

compressImage(oldFile: string) 文件地址

属性 说明 类型 示例
照片路径 string

openContact(appName: string)

属性 说明 类型 示例
success 权限是否同意 boolean true 同意 false 拒绝
data { number: '手机号', name: '姓名'} string
info 提示 string

getContactsList(appName: string)

属性 说明 类型 示例
success 权限是否同意 boolean true 同意 false 拒绝
data 通讯录数据 (json)string “[{ "name": "test", phone_number: "342342332"}]”
(phone_number) 手机号 string
(name) 姓名 string
info 提示 string

saveString(key: string, value: string)

传入属性 说明 类型 示例
key 存储的 key 值 string
value 存储的值 string

getString(key: string)

传入属性 说明 类型 示例
key 存储的 key 值 string
输出属性 说明 类型 示例
---- ---- ---- ----
存储的 value 值 string

removeString(key: string)

传入属性 说明 类型 示例
key 存储的 key 值 string

clearString()

传入属性 说明 类型 示例

getDeviceInfoForAndroid()

属性 说明 类型 示例
imei 设备唯一标识 string
serial 序列号 string
model 手机型号 string
wifi wifi 名称 string
systemVersion 系统版本号 string
memory 手机内存 string
totalMemorySize 手机总存储空间 string
useMemorySize 手机可用存储空间 string
ipAddress ip 地址 string
root 是否 root string 返回 是、否
macAddress macd 地址 string
apps 手机已安装 app string '[{ app_name: 'test'}]'
latitude 经度 string
longitude 纬度 string

getAppVersionCodeForAndroid()

属性 说明 类型 示例
app 版本 code number 1

checkPermissionsForAndroid(permission: string[])

属性 说明 类型 示例
success 权限是否同意 boolean true 同意 false 拒绝
name 权限名字 string "android.permission.ACCESS_FINE_LOCATION"
status 权限状态 string "granted"

toGooglePlayForAndroid()

属性 说明 类型 示例
打开 googleplay 定位到当前 app

getMessageRecordForAndroid()

通过注册订阅事件  监听 回调的 短信记录数据
DeviceEventEmitter.addListener('GetSms', async (res: any) => {
        console.log(res)
      })
属性 说明 类型 示例
success 是否成功 boolean true 成功 false 失败
data 短信记录数据 (json)string “[{ ... }]”
(date) 日期 number
(number) 手机号 string
(person) 姓名 string
(status) status string 短信状态-1 接收,0 complete,64 pending,128 failed
(type) 短信类型 string 1 是接收到的,2 是已发出

getCallRecordForAndroid()

通过注册订阅事件  监听 回调的 通话记录数据
DeviceEventEmitter.addListener('GetCallRecord', async (res: any) => {
        console.log(res)
      })
属性 说明 类型 示例
success 是否成功 boolean true成功 false失败
data 短信记录数据 (json)string “[{ ... }]”
(format_number) 格式化号码 string
(number) 格式化号码 string
(name) 联系人名称 string
(location) 运营商地址 string 浙江杭州
(type) 通话类型 string
(duration) 通话时长(秒为单位) number
(date) 通话时间 number

getGoogleAdsForAndroid()

通过注册订阅事件  监听 回调的 通话记录数据
DeviceEventEmitter.addListener('GetGoogleAds', async (res: any) => {
        console.log(res)
      })
属性 说明 类型 示例
googleAds string

getPermissonInfoForIOS()

属性 说明 类型 示例
相关权限权限 json字典 {key:value...}
key 权限名称 string "photo"/"camera"/"contact"/"location"
value 权限状态 bool

getDeviceInfoForIOS()

属性 说明 类型 示例
bundleId App的唯一标识 string com.qiyuan.jrn
serial 手机唯一标识 string
model 手机型号 string
version App版本号 string
systemVersion 系统版本号 string
displayName App名称 string

requestContactForIOS()

属性 说明 类型 示例
请求通讯录权限结果 bool

requestPhotoForIOS()

属性 说明 类型 示例
请求相册权限结果 bool

requestCameraForIOS()

属性 说明 类型 示例
请求相机权限结果 bool

Package Sidebar

Install

npm i react-native-qy-library

Weekly Downloads

1

Version

1.2.2

License

none

Unpacked Size

1.06 MB

Total Files

109

Last publish

Collaborators

  • qy_yeoman