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
- In XCode, in the project navigator, right click
Libraries
➜ Add Files to [your project's name]
- Go to
node_modules
➜ react-native-qy-library
and add RNQyLibrary.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNQyLibrary.a
to your project's Build Phases
➜ Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- 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
- 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')
- 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独有
具体调用方法
属性 |
说明 |
类型 |
示例 |
无 |
app 版本号 |
string |
"v1.0.0" |
属性 |
说明 |
类型 |
示例 |
success |
权限是否同意 |
boolean |
true 同意 false 拒绝 |
data |
{ success: '是否成功(boolean)',latitude: '经度(string)', longitude:'纬度(string)' } |
object |
|
info |
提示 |
string |
|
属性 |
说明 |
类型 |
示例 |
无 |
检查位置信息是否打开 |
boolean |
true 打开 false 关闭 |
属性 |
说明 |
类型 |
示例 |
success |
权限是否同意 |
boolean |
true 同意 false 拒绝 |
data |
照片路径 |
string |
|
info |
提示 |
string |
|
属性 |
说明 |
类型 |
示例 |
无 |
照片路径 |
string |
|
属性 |
说明 |
类型 |
示例 |
无 |
照片路径 |
string |
|
属性 |
说明 |
类型 |
示例 |
success |
权限是否同意 |
boolean |
true 同意 false 拒绝 |
data |
{ number: '手机号', name: '姓名'} |
string |
|
info |
提示 |
string |
|
属性 |
说明 |
类型 |
示例 |
success |
权限是否同意 |
boolean |
true 同意 false 拒绝 |
data |
通讯录数据 |
(json)string |
“[{ "name": "test", phone_number: "342342332"}]” |
(phone_number) |
手机号 |
string |
|
(name) |
姓名 |
string |
|
info |
提示 |
string |
|
传入属性 |
说明 |
类型 |
示例 |
key |
存储的 key 值 |
string |
|
value |
存储的值 |
string |
|
传入属性 |
说明 |
类型 |
示例 |
key |
存储的 key 值 |
string |
|
输出属性 |
说明 |
类型 |
示例 |
---- |
---- |
---- |
---- |
无 |
存储的 value 值 |
string |
|
传入属性 |
说明 |
类型 |
示例 |
key |
存储的 key 值 |
string |
|
属性 |
说明 |
类型 |
示例 |
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 |
|
属性 |
说明 |
类型 |
示例 |
无 |
app 版本 code |
number |
1 |
属性 |
说明 |
类型 |
示例 |
success |
权限是否同意 |
boolean |
true 同意 false 拒绝 |
name |
权限名字 |
string |
"android.permission.ACCESS_FINE_LOCATION" |
status |
权限状态 |
string |
"granted" |
属性 |
说明 |
类型 |
示例 |
无 |
打开 googleplay 定位到当前 app |
无 |
|
通过注册订阅事件 监听 回调的 短信记录数据
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 是已发出 |
通过注册订阅事件 监听 回调的 通话记录数据
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 |
|
通过注册订阅事件 监听 回调的 通话记录数据
DeviceEventEmitter.addListener('GetGoogleAds', async (res: any) => {
console.log(res)
})
属性 |
说明 |
类型 |
示例 |
无 |
googleAds |
string |
|
属性 |
说明 |
类型 |
示例 |
无 |
相关权限权限 |
json字典 |
{key:value...} |
key |
权限名称 |
string |
"photo"/"camera"/"contact"/"location" |
value |
权限状态 |
bool |
|
属性 |
说明 |
类型 |
示例 |
bundleId |
App的唯一标识 |
string |
com.qiyuan.jrn |
serial |
手机唯一标识 |
string |
|
model |
手机型号 |
string |
|
version |
App版本号 |
string |
|
systemVersion |
系统版本号 |
string |
|
displayName |
App名称 |
string |
|
requestContactForIOS()
属性 |
说明 |
类型 |
示例 |
无 |
请求通讯录权限结果 |
bool |
|
requestPhotoForIOS()
属性 |
说明 |
类型 |
示例 |
无 |
请求相册权限结果 |
bool |
|
requestCameraForIOS()
属性 |
说明 |
类型 |
示例 |
无 |
请求相机权限结果 |
bool |
|