项目中使用友盟统计功能是非常方便的,首先得先到友盟开放平台去看看文档,话不多说,正在就把我写的一个demo
送给有需要的朋友,这里我封装了友盟统计的功能,只需要导入这个类,就可以很方便的使用:
-
- #import <Foundation/Foundation.h>
-
- @interface HYBUMAnalyticsHelper : NSObject
-
- + (void)UMAnalyticStart;
-
- + (void)beginLogPageView:(__unsafe_unretained Class)pageView;
-
- + (void)endLogPageView:(__unsafe_unretained Class)pageView;
-
- @end
-
- #import "HYBUMAnalyticsHelper.h"
- #import "MobClick.h"
-
- #define kUMAnalyticsAppKey @"546c4457fd98c5cb9a00319d"
-
- @implementation HYBUMAnalyticsHelper
-
- + (void)UMAnalyticStart {
- [MobClick startWithAppkey:kUMAnalyticsAppKey reportPolicy:BATCH channelId:@"App Store"];
-
-
- NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
- [MobClick setAppVersion:version];
-
- #if DEBUG
-
- [MobClick setLogEnabled:YES];
- #endif
- return;
- }
-
- + (void)beginLogPageView:(__unsafe_unretained Class)pageView {
- [MobClick beginLogPageView:NSStringFromClass(pageView)];
- return;
- }
-
- + (void)endLogPageView:(__unsafe_unretained Class)pageView {
- [MobClick endLogPageView:NSStringFromClass(pageView)];
- return;
- }
-
- @end
想要看看源代码,就去我的github里下载吧:https://github.com/632840804/UMAnalyticsDemo