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的运行次 ...
随机推荐
- 2015年,从毕业到工作的几点感悟(Android开发新人)
锄禾日当午,汗滴禾下土. 2015年,从毕业到工作的几点感悟(Android开发): 多用三方类库:(成长经验:尽量不要自己手动实现网络上已经有的优秀开源类库的功能,例如: 网络请求:常见 ...
- REST vs SOAP
REST vs SOAP These information searched from internet most from stackoverflow. Simple explanation ab ...
- Java魔法堂:finalize函数
一.finalize与GC 在GC第一次进行可达性分析时会将不可达而且该对象所属类重写finalize方法和finalize方法重未被执行过的对象追加到F-Queue当中,然后JVM会自动开启一个低优 ...
- LeetCode - 46. Permutations
46. Permutations Problem's Link -------------------------------------------------------------------- ...
- CaptureManagerSDK
Simple SDK for capturing, recording and streaming video and audio from web-cams on Windows OS by Win ...
- BufferHelp byte[] Stream string FileStream Image Bitmap
/******* * *** ***** ** ** * * * * * * * * ***** * * * * * * * * * * * * * * * ******* *** * ***** * ...
- 百度云推送-服务端 C# SDK
思路: 1.公司有项目需要做android和ios手机端推送消息的功能: 2.没有接触过这方面的知识,一头雾水,开始在网上一顿搜,网上倒是有不少解决方案,首先搜的是android的解决方案,因为ios ...
- SSH实例(7)
运行结果. 浏览课程: 添加课程: 还有删除课程,这里就不演示了.
- 解决之前上架的 App 在 iOS 9 会闪退问题 (更新:已有 Hotfix)
最新更新:(2015.10.02) 开发环境: Delphi 10 Seattle OS X El Capitan v10.11 需使用下列 HotfixID: 30398, PAServer Hot ...
- Firemonkey TEdit 切换不同 KeyboardType 样式
用代码切换 Edit 不同的键盘样式: procedure TForm1.Button1Click(Sender: TObject); begin Edit1.KeyboardType := TVir ...