更新记录

1.0.0(2024-07-05)

发布插件


平台兼容性

Android Android CPU类型 iOS
适用版本区间:6.0 - 14.0 armeabi-v7a:支持,arm64-v8a:支持,x86:未测试 ×

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


概述

  • 申请定位权限
  • 检查定位权限
  • 打开屏幕唤醒
  • 关闭屏幕唤醒
  • 检查电池优化
  • 申请电池优化
  • 设置省电策略
  • 设置自启动
  • 打开GPS
  • 打开应用设置
  • 打开耗电统计
  • 打开系统设置
  • 单次定位
  • 持续定位

温馨提示 如何调用插件

    const plugin = uni.requireNativePlugin('yuange-locationKeepAlive');

申请定位权限

 applyPermission() {
                var that=this;
                plugin.permission({}, result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            },

检查定位权限

   checkPermission() {
                var that=this;
                plugin.hasLocationPermissions(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

打开屏幕唤醒

   openWakeLock() {
                var that=this;
                plugin.openWakeLock({time:5},result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

关闭屏幕唤醒

    colseWakeLock() {
                var that=this;
                plugin.colseWakeLock(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

检查电池优化

    isIgnoringBatteryOptimizations() {
                var that=this;
                plugin.isIgnoringBatteryOptimizations(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

申请电池优化

    requestIgnoreBatteryOptimizations() {
                var that=this;
                plugin.requestIgnoreBatteryOptimizations(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

设置省电策略

   setPowerKeeper() {
                var that=this;
                plugin.setPowerKeeper(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

设置自启动

  startToAutoStartSetting() {
                var that=this;
                plugin.startToAutoStartSetting(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

打开GPS设置

  openGpsSetting() {
                var that=this;
                plugin.openGpsSetting(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

打开应用设置

  openSetting() {
                var that=this;
                plugin.openSetting(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

打开耗电统计

  openPowerUsageSummary() {
                var that=this;
                plugin.openPowerUsageSummary(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

打开系统设置

  openSystemSetting() {
                var that=this;
                plugin.openSystemSetting(result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

单次定位

  onceLocation() {
                var that=this;
                plugin.once({},result => {
                    that.result=JSON.stringify(result);
                    console.log(JSON.stringify(result));
                });
            }

持续定位

plugin.start(
                {
                    intervalTime: 2500, //间隔毫秒
                    isReport: false, //false 以下可以不传
                    reportInterval: 10,//每定位几次进行上传
                    url: 'https://baidu.com/xxx',// 支持向服务端上报数据
                    params: { abcd: 336, def: '556', zdd: "usosf" },//自定义透传参数
                    headers: { abc: 'zxx', def: 'hhjh' }//自定义hearder
                },
                result => {
                    console.log(JSON.stringify(result));

                }
            );

隐私、权限声明

1. 本插件需要申请的系统权限列表:

android.permission.ACCESS_COARSE_LOCATION android.permission.WAKE_LOCK android.permission.ACCESS_BACKGROUND_LOCATION android.permission.ACCESS_FINE_LOCATION

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件所采集的数据可参考高德官方文档:https://lbs.amap.com/api/android-location-sdk/locationsummary/

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问