插件安装好后不知道怎么用,只需要获取登陆信息,设备信息。获取这些基本信息就行了。
1条回答 默认 最新
- 白色薄荷糖 2018-01-15 05:50关注
iOS Cordova接入文档
百度移动统计现已提供Cordova插件的支持,对于基于Cordova开发的APP(或者Phonegap),您可以按如下步骤使用百度移动统计。集成方法
新建一个Cordava工程,关于如何新建一个Cordova工程请参考Cordova官方文档cordova create hello com.example.hello HelloWorld
cd hello
cordova platform add ios
添加百度移动统计静态库,可参考在项目中添加百度移动统计的方法,包括手动添加和使用cocoapods两种方法手动添加请参考SDK中心的iOS开发文档。
cocoapods添加可结合您的项目情况,本文档列出一种方式如下:在项目内添加cocoapods插件,以支持直接部署cocoapods
cordova plugin add cordova-plugin-cocoapod-support --save
修改项目的config.xml文件如下<?xml version='1.0' encoding='utf-8'?> <widget id="com.blakgeek.cordova.superdopeness" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>CocoapodsDemo</name> <description> An app demonstrating the use of CocoaPods dependencies. </description> <content src="index.html" /> <access origin="*" /> <platform name="ios"> <!-- set platform :ios, defaults to 7.0 --> <preference name="pods_ios_min_version" value="8.0"/> <pod id="BaiduMobStat" /> </platform> </widget>
添加百度移动统计cocoapods插件
cordova plugin add cordova-plugin-baidumobstat --save
打开platform/ios下的工程,在Classs/AppDelegate.m内添加百度移动统计的启动代码#import "BaiduMobStat.h"
// - (BOOL)application: didFinishLaunchingWithOptions:
[[BaiduMobStat defaultStat] startWithAppId:@"xxx"];
在www/js/index.js内使用对应的接口运行cordova prepapre ios,然后build调试
您也可以使用以下方法进行自动prepare
1. 在Xcode中选择Product->Scheme->Edit Scheme
2. 展开Build步骤的左边的三角形选择Pre-actions
3. 点击”+”创建新的步骤- “Shell” 不用填写
- “Provide build settings from” 选择你要编译的工程
- “script” 区域填写
cd ${PROJECT_DIR}/../..
echo "--- Start ---" > xcode-prepare-ios-results.txt
echo "Running cordova prepare ios command..."
pwd >> xcode-prepare-ios-results.txt
cordova prepare ios --verbose >> xcode-prepare-ios-results.txt
echo "--- Finished ---" >> xcode-prepare-ios-results.txtAPI
具体使用方法请参考样例程序事件分析
无时长事件
BaiduMobStat.onEvent(eventId, eventLabel);
// attributes 是以object形式传入的字典,如{'类型':'类型一', '数值': '3'}
BaiduMobStat.onEventWithAttributes(eventId, eventLabel, attributes);
固定时长事件
BaiduMobStat.onEventDuration(eventId, eventLabel, duration);
// attributes 是以object形式传入的字典,如{'类型':'类型一', '数值': '3'}
BaiduMobStat.onEventDurationWithAttributes(eventId, eventLabel, duration, attributes);
自定义时长事件
BaiduMobStat.onEventStart(eventId, eventLabel);
BaiduMobStat.onEventEnd(eventId, eventLabel);
// attributes 是以object形式传入的字典,如{'类型':'类型一', '数值': '3'}
BaiduMobStat.onEventEndWithAttributes(eventId, eventLabel, attributes);
页面分析
BaiduMobStat.onPageStart(pageName);
BaiduMobStat.onPageEnd(pageName);本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报