更新记录

1.0.3(2023-01-06)

修复HBuilderX 3.6.15 不兼容的问题

1.0.2(2022-03-18)

修复 云打包后,可能会出现打包失败的问题。

1.0.1(2021-08-09)

package.json 新增"ignore" 属性

查看更多

平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 12.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原生插件配置”->”云端插件“列表中删除该插件重新选择


前置条件

  • HBuilderX3.2.0及以上版本支持
  • 仅支持uni-app项目,5+ App(wap2app)项目不支持
  • 仅支持Android平台
  • 具备Uni原生插件开发能力
  • 具备基本的Android布局知识

功能说明

根据工业和信息化部关于开展APP侵害用户权益专项整治要求,各大应用市场都加强应用的审核检测,要求应用必须配置“隐私与政策”协议框。为了满足隐私提示框显示之前不能调用涉及个人信息相关API(如设备标识)的要求,需要配置使用“template”模式隐私与政策提示框,详情参考https://ask.dcloud.net.cn/article/36937

“template”模式原生隐私与政策提示框是通过Android原生布局文件实现,uni原生插件支持通过提交原生布局文件自定义原生隐私与政策提示框样式。建议开发者下载此插件根据设计要求自定义配置后作为本地插件提交云端打包,完整教程请参考https://ask.dcloud.net.cn/article/39199

解压下载的插件,可在对应的android/res/layout 目录下,查看到隐私与政策原生提示框二次确认提示框布局文件

注意:布局可以随便改,但是基本元素的id是不能改的

自定义隐私与政策原生提示框

隐私与政策原生提示框使用布局文件dcloud_custom_privacy_dialog_layout.xml,默认效果

开发者可以根据需求自由修改界面布局文件,但需要保证关键组件id不变。

以下是修改背景颜色、标题颜色、链接颜色的示例源码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll_content_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/dcloud_dialog_shape"
    android:gravity="center"
    android:orientation="vertical">
    <!--android:background 对话框背景布局-->

    <!--隐私协议标题-->
    <TextView
        android:id="@+id/tv_custom_privacy_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="12dp"
        android:gravity="center"
        android:paddingTop="20dp"
        android:textColor="#000000"
        android:textSize="16sp"
        android:textStyle="bold" ></TextView>
    <!--隐私协议内容-->
    <TextView
        android:id="@+id/tv_privacy_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="12dp"
        android:paddingTop="6dp"
        android:paddingRight="12dp"
        android:paddingBottom="2dp"
         <!--这里可以控制协议内容中的超链接样式,包括链接颜色以及是否有下划线-->
        android:tag="{'linkColor':'#FF00FF','linkLine':false}" />

    <!--用户按钮区域-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="12dp"
        android:paddingTop="2dp"
        android:paddingRight="12dp"
        android:paddingBottom="8dp">
        <!--取消按钮-->
        <Button
            android:id="@+id/btn_custom_privacy_cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@null"
            android:paddingLeft="12dp"
            android:paddingTop="10dp"
            android:paddingRight="12dp"
            android:paddingBottom="10dp"
            android:text="取消"
            android:textColor="@drawable/dcloud_custom_rich_dialog_button_text_selecter"
            android:textSize="14sp"
            android:visibility="gone" ></Button>
        <!--确认按钮-->
        <Button
            android:id="@+id/btn_custom_privacy_sure"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@null"
            android:paddingLeft="12dp"
            android:paddingTop="10dp"
            android:paddingRight="12dp"
            android:paddingBottom="10dp"
            android:text="确认"
            android:textColor="@drawable/dcloud_custom_rich_dialog_button_text_selecter"
            android:textSize="14sp"
            android:visibility="gone" ></Button>

    </LinearLayout>
</LinearLayout>

上面的布局文件中,使用到的自定义背景文件

drawable/dcloud_dialog_shape.xml
内容如下

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!--背景颜色色值-->
    <solid android:color="#FFFFE0" ></solid>
    <!--背景圆角弧度-->
    <corners android:radius="5dp" ></corners>
</shape>

修改后的运行效果

自定义“二次确认提示框”

二次确认提示框使用布局文件dcloud_custom_privacy_second_dialog_layout.xml,默认效果

以下是修改背景颜色、链接颜色的示例源码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll_content_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/dcloud_dialog_shape"
    android:gravity="center"
    android:orientation="vertical">
    <!--android:background 对话框背景布局-->

    <!--隐私协议标题-->
    <TextView
        android:id="@+id/tv_custom_privacy_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="12dp"
        android:gravity="center"
        android:paddingTop="20dp"
        android:textColor="#000000"
        android:textSize="16sp"
        android:textStyle="bold" ></TextView>
    <!--隐私协议内容-->
    <TextView
        android:id="@+id/tv_privacy_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="12dp"
        android:paddingTop="6dp"
        android:paddingRight="12dp"
        android:paddingBottom="2dp"
         <!--这里可以控制协议内容中的超链接样式,包括链接颜色以及是否有下划线-->
        android:tag="{'linkColor':'#FF00FF','linkLine':false}" />

    <!--用户按钮区域-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="12dp"
        android:paddingTop="2dp"
        android:paddingRight="12dp"
        android:paddingBottom="8dp">
        <!--取消按钮-->
        <Button
            android:id="@+id/btn_custom_privacy_cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@null"
            android:paddingLeft="12dp"
            android:paddingTop="10dp"
            android:paddingRight="12dp"
            android:paddingBottom="10dp"
            android:text="取消"
            android:textColor="@drawable/dcloud_custom_rich_dialog_button_text_selecter"
            android:textSize="14sp"
            android:visibility="gone" ></Button>
        <!--确认按钮-->
        <Button
            android:id="@+id/btn_custom_privacy_sure"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@null"
            android:paddingLeft="12dp"
            android:paddingTop="10dp"
            android:paddingRight="12dp"
            android:paddingBottom="10dp"
            android:text="确认"
            android:textColor="@drawable/dcloud_custom_rich_dialog_button_text_selecter"
            android:textSize="14sp"
            android:visibility="gone" ></Button>

    </LinearLayout>
</LinearLayout>

修改后的运行效果

隐私、权限声明

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

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

插件不采集任何数据

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

许可协议

许可协议 Copyright © 2022

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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