umeng 渠道统计ios
1、 使用前提:需要在工程中添加依赖框架:AdSupport.framework 和 Security.framework
2、在AppDelegate.m文件中的-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中调用以下代码, 传入Appkey。
OpenUDID.h可从https://github.com/ylechelle/OpenUDID下载。
#import <AdSupport/ASIdentifierManager.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
#import "OpenUDID.h" +(void)requestTrackWithAppkey:(NSString *)appkey
{
if (!appkey || ![appkey length])
{
return;
} ASIdentifierManager *asIM = [[ASIdentifierManager alloc] init];
NSString *idfa = [asIM.advertisingIdentifier UUIDString];
NSString *idfv = [[UIDevice currentDevice].identifierForVendor UUIDString];
NSString *openudid = [OpenUDID value];
NSString *mac = [self macString];
// NSString *utdid = [UTDevice utdid]; size_t size;
// Set 'oldp' parameter to NULL to get the size of the data
// returned so we can allocate appropriate amount of space
sysctlbyname("hw.machine", NULL, &size, NULL, );
// Allocate the space to store name
char *name = malloc(size);
// Get the platform name
sysctlbyname("hw.machine", name, &size, NULL, );
// Place name into a string
NSString *machine = [NSString stringWithCString:name encoding:NSUTF8StringEncoding];
// Done with this
free(name);
machine=(NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)machine,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8));
mac=(NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)mac,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8));
NSString *requestURL = [[NSString alloc] initWithFormat:@"https://ar.umeng.com/stat.htm?ak=%@&device_name=%@&idfa=%@&openudid=%@&idfv=%@&mac=%@",appkey,machine,idfa,openudid,idfv,mac]; NSError *error = nil;
NSHTTPURLResponse *response = nil;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:requestURL]];
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if (responseData)
{
//
// NSLog(@"ok");
} } + (NSString * )macString{
int mib[];
size_t len;
char *buf;
unsigned char *ptr;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl; mib[] = CTL_NET;
mib[] = AF_ROUTE;
mib[] = ;
mib[] = AF_LINK;
mib[] = NET_RT_IFLIST; if ((mib[] = if_nametoindex("en0")) == ) {
printf("Error: if_nametoindex error\n");
return NULL;
} if (sysctl(mib, , NULL, &len, NULL, ) < ) {
printf("Error: sysctl, take 1\n");
return NULL;
} if ((buf = malloc(len)) == NULL) {
printf("Could not allocate memory. error!\n");
return NULL;
} if (sysctl(mib, , buf, &len, NULL, ) < ) {
printf("Error: sysctl, take 2");
free(buf);
return NULL;
} ifm = (struct if_msghdr *)buf;
sdl = (struct sockaddr_dl *)(ifm + );
ptr = (unsigned char *)LLADDR(sdl);
NSString *macString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
*ptr, *(ptr+), *(ptr+), *(ptr+), *(ptr+), *(ptr+)];
free(buf); return macString;
}
umeng 渠道统计ios的更多相关文章
- umeng 渠道统计 android
1.配置AndroidManifest.xml,添加权限 <uses-permission android:name="android.permission.ACCESS_NETWOR ...
- 统计iOS产品不同渠道的下载量
如何统计iOS产品不同渠道的下载量? 一.前言 在开发过程中,Android可能会打出来很多的包,用于标识不同的商店下载量.原来觉得苹果只有一个商店:AppStore,如何做出不同来源的统计呢?本篇文 ...
- App渠道统计方法全面解析 总有一种适合你
一.App渠道统计对于App推广运营的重要性 (理解App渠道统计重要性的老司机,请直接移步到第二部分) App服务的竞争重点已经由功能竞争转向市场和运营的竞争,而App的推广与运营离不开App渠道统 ...
- openinstall渠道统计工具介绍
大家好,今天给大家介绍一下如何使用openinstall 来实现APP 渠道统计,做运营推广的朋友应该对渠道统计并不陌生,之前一般都是让技术的同事打渠道包方式进行渠道统计,而且只有安卓才能打渠道包.o ...
- 免打包:简单、灵活、便捷的APP渠道统计方法
相信做过APP运营推广的小伙伴们应该对APP渠道统计并不陌生吧.APP推广运营人员需要根据数据来评估渠道推广的效果,找到最适合自家APP的渠道,有针对性的投放,不断完善推广策略,这样才能更加精准.有效 ...
- 如何统计iOS产品不同渠道的下载量?
一.前言 在开发过程中,Android可能会打出来很多的包,用于标识不同的商店下载量.原来觉得苹果只有一个商店:AppStore,如何做出不同来源的统计呢?本篇文章就是告诉大家如何做不同渠道来源统计. ...
- 统计iOS项目的总代码行数的方法
打开终端, 用cd命令 定位到工程所在的目录,然后调用以下命名即可把每个源代码文件行数及总数统计出来: find . "(" -name "*.m" -or - ...
- 统计 iOS 设备锁定、解锁次数-b
今天下了个软件,可以记录手机解锁的次数和使用时间,当然啦,App 必须在后台运行着.当时比较纳闷的是有什么 API 可以接收设备解锁事件或通知的,Google 了下,还真有哎——我是链接:http:/ ...
- 使用私有api统计ios app运行时间及次数
利用<iphone SprintBoard部分私有API总结>中提到的私有API,可以做很多越狱以前实现不了的事情. 比如,利用一个后台运行的app,监控该iphone上所有app的运行次 ...
随机推荐
- Azure China (6) SAP 应用在华登陆 Windows Azure 公有云
<Windows Azure Platform 系列文章目录> 2014年07月11日 由世纪互联运营的 Windows Azure 为 SAP 应用提供公有云平台 2014 年 ...
- Azure Automation (3) 定期将某个Azure订阅下的所有虚拟机开关机
<Windows Azure Platform 系列文章目录> 本文介绍的是国内由世纪互联运维的Azure China. 在笔者之前的文章中,我们介绍了使用Azure Automation ...
- velocity的一些用法
velocity模板其实就是java不分语法的翻译,用到的属性还是java的方法,get,set,等 1.截取部分字段substring 原始字符串:$!ag.tagValue,也许很长,前端页面展示 ...
- Entity Framework想说爱你不容易,这么多的报错,这么多的限制,该如何解决?
首先看一下采用MODEL FIRST的方式设计的实体模型对象关系图: 注意:EntityOne中有导航属性:EntityTwo 在如下代码中的几种情况进行新增操作,均会报错,新增都不会成功: stat ...
- UsefulSQL
FindObject: ---在当前Server上找某某object,注意只需修改"要找的object"就可以使用EXEC sp_MSforeachdb 'use ? ;IF EX ...
- linux的计划
我接触linux也有好几年了,至少有5年了.最近公司在搞内部培训,人人都可以报名培训别人.想到自己在linux浸淫多年,应该出来出一份力.一直以来想就linux写一个专题.今天刚好在做相关的ppt,借 ...
- Windows Phone 8.1中AppBarToggleButton的绑定问题
在WP8.1中,应用栏按钮已经可以支持绑定了,而且提供了一种AppBarToggleButton类型,相当于一种开关按钮,这种按钮有一个属性IsChecked,标记是否为选中状态. 于是想当然的,将I ...
- SQLServer存储过程中事务的使用
create proc usp_Stock @GoodsId int, @Number int, @StockPrice money, @SupplierId int, @EmpId int, ), ...
- Android去掉listView,gridView等系统自带阴影
当我们使用listView的时候,拉到顶,或是拉到底部的时候,我们会发现有系统自带的阴影效果出现,不同手机出现的颜色可能还会不一样. 在以前我始终都有注意到此问题,一直以为是系统自带的,不能去掉.也没 ...
- [DBW]格式化时间
Date.prototype.format = function(format) { //author: meizz let o = { , //月份 "d+": this.get ...