引子:
什么是cordova?简单讲就是可以让你用丰富的前端经验写移动应用的东西。Cordova其设计初衷是希望用户群体能够通过跨平台开发的方法降低原生开发的成本。原生代码是避不开的 ,想要利用系统的各项功能必须要写对应不同系统支持的不同语言的原生代码。但是没关系,因为有丰富的插件。
openinstall一家专注做免填邀请码安装来源追踪的精准的渠道统计。很多App只需集成sdk,10分钟就能集成完毕测试。openinstall也支持cordova插件的形式让写cordova的工程师能轻松的对接集成openinstall,,实现业务需求,使App推广更高效。
那么如何集成快速对接呢?可以参考官方文档
安装插件
cordova plugin add cordova-plugin-openinstall --variable OPENINSTALL_APPKEY=[appkey] --variable OPENINSTALL_SCHEME=[scheme]
调用API
获取安装参数
window.openinstall.getInstall(function(data){
console.log('openinstall.getInstall success: ' + data);
}, function(msg){
console.log('openinstall.getInstall error: ' + msg);
});
也可传入一个整形数值,单位秒,指定时间未返回将超时
window.openinstall.getInstall(function(data){
console.log('openinstall.getInstall success: ' + data);
}, function(msg){
console.log('openinstall.getInstall error: ' + msg);
}, 10);
成功回调的data数据格式
{"channel": "渠道号", "data": "自定义数据"}
重点内容
拉起参数获取
调用以下代码注册拉起回调,应尽早调用。如在 java deviceready
事件回调之时注册
window.openinstall.registerWakeUpHandler(function(data){
console.log("openinstall.wakeup success : channel=" + data.channel + ", data=" + data.data);
}, function(msg){
console.log("openinstall.wakeup error : " + msg)
});
注意:对于 iOS,为确保能正常跳转,AppID 必须开启 Associated Domains 功能,请到苹果开发者网站,选择 Certificate, Identifiers & Profiles,选择相应的 AppID,开启 Associated Domains。注意:当 AppID 重新编辑过之后,需要更新相应的 mobileprovision 证书。(详细步骤请参考openinstall官方文档)
注册上报
window.openinstall.reportRegister();
效果点统计
window.openinstall.reportEffectPoint("effect_test", 1);
第一个参数为“效果点ID”,字符串类型
第二个参数为“效果点值”,数字类型
测试
好了,集成这时候就完毕了,打包导出包到后台测试(以Android包为例子)