Update the umeng SDK to new version(for iOS)

This commit is contained in:
natural-law 2013-04-28 13:58:26 +08:00
parent a38ea6792b
commit 325faa4736
3 changed files with 260 additions and 257 deletions

View File

@ -62,6 +62,7 @@ void AnalyticsUmeng::startSession(const char* appKey)
return;
}
NSString* pKey = [NSString stringWithUTF8String:appKey];
[[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
[MobClick startWithAppkey:pKey];
}
@ -311,6 +312,7 @@ void AnalyticsUmeng::startSession(const char* appKey, UmengReportPolicy policy,
NSString* key = [NSString stringWithUTF8String:appKey];
NSString* channel = [NSString stringWithUTF8String:channelId];
[[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
[MobClick startWithAppkey:key reportPolicy:(ReportPolicy)policy channelId:channel];
}

View File

@ -3,348 +3,349 @@
// MobClick
//
// Created by Aladdin on 2010-03-25.
// Updated by Minghua on 2012-09-11.
// Updated by Minghua on 2013-04-01.
// Copyright 2010-2012 Umeng.com . All rights reserved.
// Version 2.1.0 , updated_at 2012-09-11.
// Version 2.2.0.OpenUDID, updated_at 2013-04-01.
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#define UMOnlineConfigDidFinishedNotification @"OnlineConfigDidFinishedNotification"
#define XcodeAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
typedef enum {
REALTIME = 0, //实时发送
BATCH = 1, //启动发送
SENDDAILY = 4, //每日发送
SENDWIFIONLY = 5 //仅在WIFI下启动时发送
SENDWIFIONLY = 5, //仅在WIFI下启动时发送
SEND_INTERVAL = 6, //按最小间隔发送
SEND_ON_EXIT = 7 //退出或进入后台时发送
} ReportPolicy;
@protocol MobClickDelegate;
@class CLLocation;
/** MobClick是统计的核心类本身不需要实例化所有方法以类方法的形式提供.
REALTIME,BATCH,SENDDAILY,SENDWIFIONLY,SEND_INTERVAL,SEND_ON_EXIT
REALTIME,SENDWIFIONLY DEBUG模式下生效release模式会自动改成BATCH
http://blog.umeng.com/index.php/2012/12/0601/
SEND_INTERVAL ,10,10 86400() 10
SEND_ON_EXIT 退,App运行过程中不发送
iOS > 4.0, iOS < 4.0 BATCH
*/
@interface MobClick : NSObject <UIAlertViewDelegate> {
@private
id _internal;
}
#pragma mark basics
//开启友盟统计,以BATCH方式发送log.
+ (void)startWithAppkey:(NSString *)appKey;
// channelId 为nil或@""时,默认会被被当作@"App Store"渠道
+ (void)startWithAppkey:(NSString *)appKey reportPolicy:(ReportPolicy)rp channelId:(NSString *)cid;
/*
app版本信息CFBundleVersion里取,build version,xcode3工程兼容.
xcode4版本保持一致使
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
[MobClick setAppVersion:version];
*/
///---------------------------------------------------------------------------------------
/// @name 设置
///---------------------------------------------------------------------------------------
/** 设置app版本号。由于历史原因需要和xcode3工程兼容,友盟提取的是Build号(CFBundleVersion),如果需要和App Store上的版本一致,需要调用此方法。
@param appVersion `XcodeAppVersion`.
@return void.
*/
+ (void)setAppVersion:(NSString *)appVersion;
+ (NSString *)getAgentVersion; //获取友盟sdk 版本号
/*方法名:
* setCrashReportEnabled:(BOOL)value
*:
* umeng SDK crash log
*:
* (BOOL)value:YES
* NO,umeng SDK crash log,setDelegate方法之前调用
*/
/** 开启CrashReport收集, 默认是开启状态.
@param value NO,CrashReport收集.
@return void.
*/
+ (void)setCrashReportEnabled:(BOOL)value;
/*方法名:
* setLogEnabled:(BOOL)value
*:
* sdk的log信息
*:
* (BOOL)value:NO
* YES,umeng SDK log信息,release产品时要设置回NO
/** 设置是否打印sdk的log信息,默认不开启
@param value YES,umeng SDK log信息,release产品时要设置回NO.
@return .
@exception .
*/
+ (void)setLogEnabled:(BOOL)value;
/*方法名:
* logPageView:seconds:
*:
* view打开多长时间.
*
*:
* pageName NSString *
* seconds int型
*
*
*
*:
*
*
*: http://dev.umeng.com/doc/document_ana_ios.html#8
*/
///---------------------------------------------------------------------------------------
/// @name 开启统计
///---------------------------------------------------------------------------------------
/** 开启友盟统计,默认以BATCH方式发送log.
@param appKey appKey.
@param reportPolicy .
@param channelId ,nil或@"",@"App Store"
@return void
*/
+ (void)startWithAppkey:(NSString *)appKey;
+ (void)startWithAppkey:(NSString *)appKey reportPolicy:(ReportPolicy)rp channelId:(NSString *)cid;
/** 当reportPolicy == SEND_INTERVAL 时设定log发送间隔
@param second ,10,86400().
@return void.
*/
+ (void)setLogSendInterval:(double)second;
///---------------------------------------------------------------------------------------
/// @name 页面计时
///---------------------------------------------------------------------------------------
/** 页面时长统计,记录某个view被打开多长时间,可以自己计时也可以调用beginLogPageView,endLogPageView自动计时
@param pageName view名称.
@param seconds int型.
@return void.
*/
+ (void)logPageView:(NSString *)pageName seconds:(int)seconds;
+ (void)beginLogPageView:(NSString *)pageName;
+ (void)endLogPageView:(NSString *)pageName;
#pragma mark event logs
/*方法名:
* event:(NSString *)eventId
* event:(NSString *)eventId label:(NSString *)label
* event:(NSString *)eventId acc:(NSInteger)accumulation
* event:(NSString *)eventId label:(NSString *)label acc:(NSInteger)accumulation
*:
* 使App管理后台的设置-> IDID即可
*
*:
* 便1
* label:ID添加该事件的分类标签统计ID进行统计和整理ID的不同的标签便
* accumulation:ID的某一分类标签进行累加
*
*: http://dev.umeng.com/doc/document_ana_ios.html#3
*/
//如果label为nil或@""时服务器端会生成一个unknown的默认label,
//为避免这种情况,2.0.0之后label为nil或@""时,label将被赋值为eventId
//详细文档参见 iOS统计分析SDK开发指南.html 或在线文档
//http://dev.umeng.com/doc/document_ana_ios.html#3
///---------------------------------------------------------------------------------------
/// @name 事件统计
///---------------------------------------------------------------------------------------
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
@param eventId Id.
@param label 便,nil或空字符串时后台会生成和eventId同名的标签.
@param accumulation ID的某一分类标签进行累加
@return void.
*/
+ (void)event:(NSString *)eventId; //等同于 event:eventId label:eventId;
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
*/
+ (void)event:(NSString *)eventId label:(NSString *)label; // label为nil或@""时,等同于 event:eventId label:eventId;
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
*/
+ (void)event:(NSString *)eventId acc:(NSInteger)accumulation;
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
*/
+ (void)event:(NSString *)eventId label:(NSString *)label acc:(NSInteger)accumulation;
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
*/
+ (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
beginEvent,endEvent要配对使用,durations参数传递进来
@param eventId Id.
@param label 便,nil或空字符串时后台会生成和eventId同名的标签.
@param primarykey event_id一起标示一个唯一事件beginEvent和endEvent eventId primarykey
@param millisecond
@return void.
@warning event的attributes不能超过10个
eventIdattributes中key和value都不能使用空格和特殊字符eventIdattributes的key最大为128个bytes(12842)labelattributes的value最大为256个bytes(25684),
eventId超过的将抛弃不再发送
id ts du是保留字段eventId及key的名称
*/
+ (void)beginEvent:(NSString *)eventId;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)endEvent:(NSString *)eventId;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)beginEvent:(NSString *)eventId label:(NSString *)label;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)endEvent:(NSString *)eventId label:(NSString *)label;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
//primarykey这个参数用于和event_id一起标示一个唯一事件并不会被统计
//对于同一个事件在beginEvent和endEvent 中要传递相同的eventId 和 primarykey
//每个event的attributes不能超过10个
//eventId、attributes中key和value都不能使用空格和特殊字符且长度不能超过255个字符否则将截取前255个字符
//id ts du是保留字段不能作为eventId及key的名称
+ (void)beginEvent:(NSString *)eventId primarykey :(NSString *)keyName attributes:(NSDictionary *)attributes;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)endEvent:(NSString *)eventId primarykey:(NSString *)keyName;
//时间单位为毫秒 microseconds
+ (void)event:(NSString *)eventId durations:(int)microseconds;
+ (void)event:(NSString *)eventId label:(NSString *)label durations:(int)microseconds;
+ (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes durations:(int)microseconds;
#pragma mark feedback Default GUI
/*方法名:
- * showFeedback:(UIViewController *)rootViewcontroller
- *:
- *
- *:
- * rootViewController:presentModalViewController方法来展示反馈界面
- * rootViewController非空
- *
- * 使SDK
- */
+ (void)showFeedback:(UIViewController *)rootViewController;
#pragma mark feedback data api
/*方法名:
* feedbackWithDictionary:(NSDictionary * )feedbackDict
*:
*
*:
* Dictionary中应该有以下三个键名:
* @"UMengFeedbackGender" @"UMengFeedbackAge" @"UMengFeedbackContent"
* :
* NSString类型的
* 1=> 2=>
*
* 1=>18(18),2=>18-24,3=>25-30,
* 4=>31-35,5=>36-40,6=>41-50,7=>51-59,8=>6060
*
*
*
*:
*
*
*
* 使SDK
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)feedbackWithDictionary:(NSDictionary *)feedbackDict;
#pragma mark check app update
/*方法名:
* checkUpdate
* checkUpdateWithTitle:CancelButtonTitle:OtherButtonTitle:
*:
* app是否有更新UIAlertView提示用户,app会跳转到您预先设置的网址
*
* app版本信息App Store.
* checkUpdate .
*
*:
* checkUpdate
* checkUpdate:cancelButtonTitle:otherButtonTitles: :
* title UIAlertView的title
* cancelTitle UIAlertView的cancelTitle
* otherTitle UIAlertView的otherTitle
*
* [MobClick setDelegate:reportPolicy:];
* MobClickDelegate的appUpdate方法
*
*:
*
*
*: http://dev.umeng.com/doc/document_ana_ios.html#5
+ (void)event:(NSString *)eventId durations:(int)millisecond;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)event:(NSString *)eventId label:(NSString *)label durations:(int)millisecond;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes durations:(int)millisecond;
///---------------------------------------------------------------------------------------
/// @name 按渠道自动更新
///---------------------------------------------------------------------------------------
/** 按渠道自动更新检测
app是否有更新UIAlertView提示用户,app会跳转到您预先设置的网址
app版本信息App Store.
MobClickDelegate的appUpdate方法
@param title UIAlertView的title.
@param cancelTitle UIAlertView的cancelTitle.
@param otherTitle UIAlertView的otherTitle.
@param delegate checkUpdate的对象.
@param callBackSelectorWithDictionary checkUpdate事件完成时此方法会被调用,app更新信息的字典被传回.
@return void.
*/
+ (void)checkUpdate;
/** 按渠道自动更新检测
*/
+ (void)checkUpdate:(NSString *)title cancelButtonTitle:(NSString *)cancelTitle otherButtonTitles:(NSString *)otherTitle;
/** 按渠道自动更新检测
*/
+ (void)checkUpdateWithDelegate:(id)delegate selector:(SEL)callBackSelectorWithDictionary;
#pragma mark online config params
/*方法名:
* updateOnlineConfig
*:
* 线,[NSUserDefaults standardUserDefaults].
* 线SDK端发送策略的功能
* 线.
*
*:
*
*
* [MobClick setDelegate:reportPolicy:];
* 使线
*
*:
*
*
*: http://dev.umeng.com/doc/document_ana_ios.html#6
///---------------------------------------------------------------------------------------
/// @name 在线参数
///---------------------------------------------------------------------------------------
/** 使用在线参数功能,可以让你动态修改应用中的参数值,
线,[NSUserDefaults standardUserDefaults],
线SDK端发送策略的功能,线.
[MobClick startWithAppkey:];
线UMOnlineConfigDidFinishedNotification
@param .
@return void.
*/
+ (void)updateOnlineConfig;
/*方法名:
* getConfigParams
* getConfigParams:
*:
* [NSUserDefaults standardUserDefaults]线.
* key的值线.
*
*:
* NSString *
*
* [NSUserDefaults standardUserDefaults],
* updateOnlineConfig方法要先在app启动时被调用
*
*:
* (NSString *) (NSDictionary *)
*
*: http://dev.umeng.com/doc/document_ana_ios.html#6
/** 从[NSUserDefaults standardUserDefaults]获取缓存的在线参数的数值
key的值线.
updateOnlineConfig才能使用,线UMOnlineConfigDidFinishedNotification
@param key
@return (NSString *) .
*/
+ (NSString *)getConfigParams:(NSString *)key;
/** 从[NSUserDefaults standardUserDefaults]获取缓存的在线参数
@return (NSDictionary *).
*/
+ (NSDictionary *)getConfigParams;
// 为了更精确的统计用户地理位置,可以调用此方法传入经纬度信息
// 需要链接 CoreLocation.framework 并且 #import <CoreLocation/CoreLocation.h>
///---------------------------------------------------------------------------------------
/// @name 地理位置设置
///---------------------------------------------------------------------------------------
/** 为了更精确的统计用户地理位置,可以调用此方法传入经纬度信息
CoreLocation.framework #import <CoreLocation/CoreLocation.h>
@param latitude .
@param longitude .
@param location CLLocation *
@return void
*/
+ (void)setLatitude:(double)latitude longitude:(double)longitude;
/** 为了更精确的统计用户地理位置,可以调用此方法传入经纬度信息
*/
+ (void)setLocation:(CLLocation *)location;
#pragma mark helper
/*方法名:
* isJailbroken
*:
* apt和Cydia.app的path来判断
*:
*
*
*
*/
///---------------------------------------------------------------------------------------
/// @name helper方法
///---------------------------------------------------------------------------------------
#pragma mark utils api
// 类方法,判断当前设备是否已经越狱
/** 判断设备是否越狱,判断方法根据 apt和Cydia.app的path来判断
*/
+ (BOOL)isJailbroken;
// 类方法判断你的App是否被破解
/** 判断你的App是否被破解
*/
+ (BOOL)isPirated;
#pragma mark DEPRECATED methods from version 1.7
/*方法名:
* setDelegate:(id<MobClickDelegate>)delegate
* setDelegate:(id<MobClickDelegate>)delegate reportPolicy:(ReportPolicy)rp;
*:
* startWithAppkey:(NSString *)appKey ;
* MobClickDelegate实现使.
* MobClick代理MobClick实例appLaunched方法前
*:
* delegate:MobClickDelegate协议的实例
* ReportPolicy:
* 1.BATCH :
* 2.REALTIME :event
*
*/
/** 设置MobClick代理,已经startWithAppkey:所取代,不要再使用,原有代码可以删除
*/
+ (void)setDelegate:(id)delegate;
+ (void)setDelegate:(id)delegate reportPolicy:(ReportPolicy)rp;
/*方法名:
* appLaunched
*:
* setDelegate: setDelegate: reportPolicy:
*:
*
*
* 1.6.7.
*/
/** 记录启动时间,模块开始启用,不要再使用,原有代码可以删除
*/
+ (void)appLaunched;
/*方法名:
* appTerminated
*:
*
*:
*
* 1.6.7.
/** 记录软件终止时间,模块终止,不要再使用,原有代码可以删除
*/
+ (void)appTerminated;
/*
SDK内部使用的监听方法App启动退
[MobClick startWithAppkey:]application:didFinishLaunchingWithOptions:
App启动和退出事件application:didFinishLaunchingWithOptions:[MobClick startWithAppkey:]
App的启动事件可能会无法监听[MobClick startSession:nil]session
/** 友盟模块启动
[MobClick startWithAppkey:]application:didFinishLaunchingWithOptions:
App启动和退出事件application:didFinishLaunchingWithOptions:[MobClick startWithAppkey:]
App的启动事件可能会无法监听[MobClick startSession:nil]session
app里app使用不到.
*/
+ (void)startSession:(NSNotification *)notification;
/** 获取友盟sdk 版本号,目前友盟模块启动时自动调用,不要再使用,原有代码可以删除
*/
+ (NSString *)getAgentVersion; //
@end
//此协议的三个方法不再建议使用,建议用新方法代替
//+ (void)startWithAppkey:(NSString *)appKey reportPolicy:(ReportPolicy)rp channelId:(NSString *)cid;
//+ (void)checkUpdate:(id)delegate selector:(SEL)callBackSelector;
/** MobClickDelegate protocol
使
+ (void)startWithAppkey:(NSString *)appKey reportPolicy:(ReportPolicy)rp channelId:(NSString *)cid;
+ (void)checkUpdate:(id)delegate selector:(SEL)callBackSelector;
*/
@protocol MobClickDelegate <NSObject>
@optional
/*方法名:
* - (NSString *)appKey;
*:
* AppkeyAppkey错误log进行记录
*:
* Appkey是从友盟后台注册新App得到的
*
*/
- (NSString *)appKey;
/*方法名:
* - (NSString *)channelId;
*:
* ChannelID
*:
* @"Apple Store",@"产品主页"
* 使
*
*/
- (NSString *)channelId;
/*方法名:
* - (void)appUpdate:(NSMutableDictionary *)updateInfo;
*:
*
*:
* [MobClick checkUpdate]appUpdate
* updateInfo是与此app版本信息相关的参数
*
*
*
*/
- (void)appUpdate:(NSDictionary *)appUpdateInfo;
@end

View File

@ -1 +1 @@
bf891cff30d0a838748b877ec96cded1e540e349
c61504f40c4fbe912ff1d74677edf29234eb192c