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的更多相关文章

  1. umeng 渠道统计 android

    1.配置AndroidManifest.xml,添加权限 <uses-permission android:name="android.permission.ACCESS_NETWOR ...

  2. 统计iOS产品不同渠道的下载量

    如何统计iOS产品不同渠道的下载量? 一.前言 在开发过程中,Android可能会打出来很多的包,用于标识不同的商店下载量.原来觉得苹果只有一个商店:AppStore,如何做出不同来源的统计呢?本篇文 ...

  3. App渠道统计方法全面解析 总有一种适合你

    一.App渠道统计对于App推广运营的重要性 (理解App渠道统计重要性的老司机,请直接移步到第二部分) App服务的竞争重点已经由功能竞争转向市场和运营的竞争,而App的推广与运营离不开App渠道统 ...

  4. openinstall渠道统计工具介绍

    大家好,今天给大家介绍一下如何使用openinstall 来实现APP 渠道统计,做运营推广的朋友应该对渠道统计并不陌生,之前一般都是让技术的同事打渠道包方式进行渠道统计,而且只有安卓才能打渠道包.o ...

  5. 免打包:简单、灵活、便捷的APP渠道统计方法

    相信做过APP运营推广的小伙伴们应该对APP渠道统计并不陌生吧.APP推广运营人员需要根据数据来评估渠道推广的效果,找到最适合自家APP的渠道,有针对性的投放,不断完善推广策略,这样才能更加精准.有效 ...

  6. 如何统计iOS产品不同渠道的下载量?

    一.前言 在开发过程中,Android可能会打出来很多的包,用于标识不同的商店下载量.原来觉得苹果只有一个商店:AppStore,如何做出不同来源的统计呢?本篇文章就是告诉大家如何做不同渠道来源统计. ...

  7. 统计iOS项目的总代码行数的方法

    打开终端, 用cd命令 定位到工程所在的目录,然后调用以下命名即可把每个源代码文件行数及总数统计出来: find . "(" -name "*.m" -or - ...

  8. 统计 iOS 设备锁定、解锁次数-b

    今天下了个软件,可以记录手机解锁的次数和使用时间,当然啦,App 必须在后台运行着.当时比较纳闷的是有什么 API 可以接收设备解锁事件或通知的,Google 了下,还真有哎——我是链接:http:/ ...

  9. 使用私有api统计ios app运行时间及次数

    利用<iphone SprintBoard部分私有API总结>中提到的私有API,可以做很多越狱以前实现不了的事情. 比如,利用一个后台运行的app,监控该iphone上所有app的运行次 ...

随机推荐

  1. [New Portal]Windows Azure Virtual Machine (14) 在本地制作数据文件VHD并上传至Azure(1)

    <Windows Azure Platform 系列文章目录> 之前的内容里,我介绍了如何将本地的Server 2012中文版 VHD上传至Windows Azure,并创建基于该Serv ...

  2. javascript时间戳和日期字符串相互转换

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C ...

  3. 地图定位IOS8之后的定位

    从ios8开始,苹果进一步加强了对用户隐私的保护. 当app想要访问用户的隐私信息时  系统不再自动弹出一个对话框让用户授权 解决方法: (1)调用ios8.0的API 主动请求用户授权 - (voi ...

  4. 基于git的源代码管理模型——git flow

    基于git的源代码管理模型--git flow A successful Git branching model

  5. JS数字键盘

    JS数字键盘,JS小键盘 CSS代码: #numberkeyboard { border: 1px solid #b3b3b3; background: #f2f3f7; height: 285px; ...

  6. LINQ的Union方法

    2个集合合并,有相同的只取中其一个: source code: , , }; , , }; var result = a.Union(b); result.ForEach(delegate (int ...

  7. IN31志愿者“孝行天下,感恩父母”晚会

    IN31是一群志愿者,为社会倾力奉献与引发爱的公益组织.成功举办第一场孝行天下的大型公益活动

  8. [小工具]CSS内嵌样式自动提取器

    逐行分析,将内联样式提取出来,并自动编号代替的一个小工具软件 注:style=""(此处必须是标准的双引号!) http://files.cnblogs.com/quejuwen/ ...

  9. Win10 QQ五笔默认中文,InputMode默认中文

    Win10系统安装了QQ五笔后,InputMode默认英文,必须用鼠标点或者按 Ctrl+空格才能转换为中文.非常不方便. 即使将微软拼音默认为中文也不管用,解决方法如下: 设置后,无论你打开运行.记 ...

  10. xamarin.ios 实现圆形进度条

    using System; using UIKit; using System.Drawing; using CoreAnimation; namespace PMM { public class P ...