更新记录

1.0.0(2022-12-03)

新版首发


平台兼容性

Android iOS
× 适用版本区间:11 - 16

原生插件通用使用流程:

  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原生插件配置”->”云端插件“列表中删除该插件重新选择


KJ-CallDirectory

来电阻止、电话拦截、身份识别、电话识别(ios)

注意事项

1.关于AppStore审核,CallKit第一次上架时,收到了苹果的拒信,说CallKit在中国区被禁止了
审核备注模板:
关于CallKit,我们遵守中国的法律,没有使用VOIP,我们仅使用了Call Directory。
我们应用内有一个xxx功能。我们录制了一个演示视频:视频地址

扩展证书配置,更多教程,进群:673958630,到群文件中查找“ios扩展证书配置教程”

1.配置扩展
    需要在 主目录->nativeplugins->KJ-CallDirectory 下配置添加ios-extension.json、ios-callDirectory1.mobileprovision、
    ios-callDirectory2.mobileprovision、ios-callDirectory3.mobileprovision文件
    ios-extension.json文件配置参考 示列项目
    比如主工程Bundle ID为:com.kj.KJDocument
    分享扩展的Bundle ID 和 App Groups Bundle ID 需要开苹果开发者官网配置
    KJGroupIdentifier 和 com.apple.security.application-groups要配置一样
    每个appex,对应一个Bundle ID和证书
    {
        "callDirectory1.appex": {
            "identifier": "com.kj.KJDocument.callDirectory1",
            "profile": "ios-callDirectory1.mobileprovision",
            "plists": {
                "KJGroupIdentifier": "group.com.kj.KJDocument.callDirectory"
            },
            "entitlements": {
                "com.apple.security.application-groups": ["group.com.kj.KJDocument.callDirectory"]
            }
        },
        "callDirectory2.appex": {
            "identifier": "com.kj.KJDocument.callDirectory2",
            "profile": "ios-callDirectory2.mobileprovision",
            "plists": {
                "KJGroupIdentifier": "group.com.kj.KJDocument.callDirectory"
            },
            "entitlements": {
                "com.apple.security.application-groups": ["group.com.kj.KJDocument.callDirectory"]
            }
        },
        "callDirectory3.appex": {
            "identifier": "com.kj.KJDocument.callDirectory3",
            "profile": "ios-callDirectory3.mobileprovision",
            "plists": {
                "KJGroupIdentifier": "group.com.kj.KJDocument.callDirectory"
            },
            "entitlements": {
                "com.apple.security.application-groups": ["group.com.kj.KJDocument.callDirectory"]
            }
        }
    }
2.配置manifest.json
    /* ios打包配置 */
    "ios" : {
        "capabilities" : {
            "entitlements" : {
                "com.apple.security.application-groups" : [ "group.com.kj.KJDocument.callDirectory" ]
            }
        },
    },

使用

<template>
    <view class="content">
        <button type="primary" @click="init">初始化</button>
        <button type="primary" @click="openSetting">打开电话设置页面</button>
        <view>----电话识别----</view>
        <button type="primary" @click="getEnabledStatus1">获取授权状态1</button>
        <button type="primary" @click="reloadExtension1">刷新扩展1</button>
        <view>----电话拦截----</view>
        <button type="primary" @click="getEnabledStatus2">获取授权状态2</button>
        <button type="primary" @click="reloadExtension2">刷新扩展2</button>
        <view>----号码包----</view>
        <button type="primary" @click="getEnabledStatus3">获取授权状态3</button>
        <button type="primary" @click="reloadExtension3">刷新扩展3</button>
    </view>
</template>

<script>
    /**
     * reloadExtension 方法 传的参数说明
     * callDirectoryIdentifier - 为xxx.appex的bunlde id
     * jsonPath - 如果data不传,则会使用这个json文件的数据,方便大量数据
     * data - 不能为null,不想设置,直接不传
     *      blocking - 电话拦截,会先执行删除,后执行添加
     *      identification - 电话识别,会先执行删除,后执行添加
     *      isRemoveAll - 是否删除所有号码
     *      removes - 需要删除的号码,必须生序排序,不能为null、可以赋值为[]或者直接不传
     *      adds - 需要添加的号码,必须生序排序,不能为null、可以赋值为[]或者直接不传
     *          phoneNumber - 电话号码,数值类型,前缀必须要有区号比如86
     *          label - 电话识别的文字,注意:如果该号码在通讯录中,会优先显示通信录里的
     * */
    const KJCallDirectory = uni.requireNativePlugin('KJ-CallDirectory');
    export default {
        data() {
            return {

            }
        },
        onLoad() {
            this.init();
            var globalEvent = uni.requireNativePlugin('globalEvent');
            globalEvent.addEventListener('onState', (res) => {
                console.log("onState:" + JSON.stringify(res))
                /**
                 * 返回json说明:{"isIncremental":true,"extensionName":"callDirectory1","method":"beginRequest","error":""}
                 * extensionName 扩展的名字 对应第几个扩展
                 * */
                if (res.method == "beginRequest") {
                    console.log("请求数据库操作")
                } else if (res.method == "requestFailed") {
                    console.log("请求数据库操作失败")
                }
            });
        },
        methods: {
            init() {
                var dic = {
                    GroupIdentifier: "group.com.kj.KJDocument.callDirectory",
                }
                KJCallDirectory.init(dic);
            },
            openSetting() {
                KJCallDirectory.openSetting((res) => {
                    console.log("openSetting:" + JSON.stringify(res))
                });
            },
            getEnabledStatus(callDirectoryIdentifier) {
                var dic = {
                    callDirectoryIdentifier: callDirectoryIdentifier //为xxx.appex的bunlde id
                }
                KJCallDirectory.getEnabledStatus(dic, (res) => {
                    console.log("getEnabledStatus:" + JSON.stringify(res))
                    /**
                     * 返回json说明:{"error":"","enabledStatus":2}
                     * enabledStatus - 授权状态 0(未知) 1(拒绝) 2(已授权)
                     * */
                });
            },
            getEnabledStatus1() {
                this.getEnabledStatus("com.kj.KJDocument.callDirectory1");
            },
            reloadExtension1() { //电话识别
                var dic = {
                    callDirectoryIdentifier: "com.kj.KJDocument.callDirectory1",
                    jsonPath: plus.io.convertLocalFileSystemURL("static/callDirectory1.json"),
                    data: {
                        "identification": {
                            "isRemoveAll": true,
                            // "removes": [{
                            //  "phoneNumber": 8612345678910 
                            // }],
                            "adds": [{
                                "phoneNumber": 8612345678910,
                                "label": "某某人的电话"
                            }]
                        }
                    }
                }
                KJCallDirectory.reloadExtension(dic, (res) => {
                    console.log("reloadExtension:" + JSON.stringify(res))
                    /**
                     * 返回json说明:{"error":"未能完成操作。(com.apple.CallKit.error.calldirectorymanager错误6。)","errorCode":6} 
                     * errorCode - 错误码 1(callDirectoryIdentifier设置的不对) 2(加载时被中断) 
                     * 3(加载数据格式错误比如号码中带有符号,号码没有增序排列) 4(数据有重复) 6(权限未打开)
                     * */
                });
            },
            getEnabledStatus2() {
                this.getEnabledStatus("com.kj.KJDocument.callDirectory2");
            },
            reloadExtension2() { //电话拦截
                var dic = {
                    callDirectoryIdentifier: "com.kj.KJDocument.callDirectory2",
                    jsonPath: plus.io.convertLocalFileSystemURL("static/callDirectory2.json"),
                    data: {
                        "blocking": {
                            "isRemoveAll": true,
                            // "removes": [{
                            //  "phoneNumber": 8612345678910
                            // }],
                            "adds": [{
                                "phoneNumber": 8612345678910
                            }],
                        },
                    }
                }
                KJCallDirectory.reloadExtension(dic, (res) => {
                    console.log("reloadExtension:" + JSON.stringify(res))
                });
            },
            getEnabledStatus3() {
                this.getEnabledStatus("com.kj.KJDocument.callDirectory3");
            },
            reloadExtension3() { //号码包
                var dic = {
                    callDirectoryIdentifier: "com.kj.KJDocument.callDirectory3",
                    jsonPath: plus.io.convertLocalFileSystemURL("static/callDirectory3.json"),
                    data: {
                        "blocking": {
                            "isRemoveAll": true,
                            // "removes": [{
                            //  "phoneNumber": 8612345678910
                            // }],
                            "adds": [{
                                "phoneNumber": 8612345678910
                            }],
                        },
                        "identification": {
                            "isRemoveAll": true,
                            // "removes": [{
                            //  "phoneNumber": 8612345678910
                            // }],
                            "adds": [{
                                "phoneNumber": 8612345678910,
                                "label": "某某人的电话"
                            }]
                        }
                    }
                }
                KJCallDirectory.reloadExtension(dic, (res) => {
                    console.log("reloadExtension:" + JSON.stringify(res))

                });
            }
        }
    }
</script>

<style>
    .content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .logo {
        height: 200rpx;
        width: 200rpx;
        margin-top: 200rpx;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 50rpx;
    }

    .text-area {
        display: flex;
        justify-content: center;
    }

    .title {
        font-size: 36rpx;
        color: #8f8f94;
    }
</style>

隐私、权限声明

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

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

插件不采集任何数据

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

暂无用户评论。

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