广告推广APP下载MAC、IDFA设备标识获取

广告主通过推广链接记录用户点击,应用激活时回调推广方接口。在iOS中,APP唯一标识通常使用iTunes ID,用户设备标识则依赖于MAC地址(iOS 7以上无效)和IDFA。代码示例展示了如何在iOS获取MAC地址。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

对于每个推广的应用,广告主提供一个推广链接,推广方将该链接作为推广应用的点击链接。当用户点击推广应用时,首先会跳转到广告主侧,广告主记录下用户的点击信息,然后返回重定向至推广应用的下载地址。

当广告主接收到推广应用的激活报告,若核对上了通过推广带过去的点击,则回调推广方提供的应用激活回调接口。


Ø  说明:在双方进行数据对接时的APP唯一标识。

Ø  生成策略:推荐使用应用的iTunes id作为APP唯一标识。例如所推广应用的iTunes链接为以下地址则取444934666作为APP唯一标识。

https://itunes.apple.com/cn/app/qq/id444934666?mt=8

   对接用户标识

Ø  说明:用户设备的唯一标识,标明是谁(用户)产生的这个激活。

Ø  生成策略: WIFI MAC地址、IDFA等设备标识。如下:

标识

支持系统

描述

示例

MAC

<= iOS 6

大写并且带冒号的WIFI MAC地址

1C:AB:A7:D6:E7:83

MAC MD5

<= iOS 6

大写带冒号的原始WIFI MAC地址MD5加密再转为大写

D88CA207E18EEB9732ACEE07E082AE67

IDFA

>= iOS 6

原始Identifier for Advertising,参考地址

511F7987-6E2F-473A-BFED-E4C52CB5A6DC

Ø  注意:

在iOS 7及以上系统版本,将获取到无效的MAC地址 02:00:00:00:00:00,该地址经过MD5加密后的值为 0F607264FC6318A92B9E13C65DB7CD3C。所以,如果设备的MAC地址是上述的无效值,不要采信MAC地址,而使用IDFA进行核对。


-(NSString *) macaddress

{

    int mgmtInfoBase[6];

    char *msgBuffer =NULL;

    size_t length;

    unsignedchar macAddress[6];

    structif_msghdr *interfaceMsgStruct;

    structsockaddr_dl *socketStruct;

    NSString *errorFlag =NULL;

    // Setup the management Information Base (mib)

    mgmtInfoBase[0] =CTL_NET; // Request network subsystem

    mgmtInfoBase[1] =AF_ROUTE; // Routing table info

    mgmtInfoBase[2] =0;

    mgmtInfoBase[3] =AF_LINK; // Request link layer information

    mgmtInfoBase[4] =NET_RT_IFLIST; // Request all configured interfaces

    // With all configured interfaces requested, get handle index

    if ((mgmtInfoBase[5] =if_nametoindex("en0")) ==0)

        errorFlag = @"if_nametoindex failure";

    else

    {

        // Get the size of the data available (store in len)

        if (sysctl(mgmtInfoBase,6, NULL, &length,NULL, 0) <0)

            errorFlag = @"sysctl mgmtInfoBase failure";

        else

        {

            // Alloc memory based on above call

            msgBuffer =(char*)malloc(length) ;

            if ((msgBuffer) ==NULL)

                errorFlag = @"buffer allocation failure";

            else

            {

                // Get system information, store in buffer

                if (sysctl(mgmtInfoBase,6, msgBuffer, &length, NULL,0) < 0)

                    errorFlag = @"sysctl msgBuffer failure";

            }

        }

    }

    // Befor going any further...

    if (errorFlag !=NULL)

    {

        // DLog(@"Error: %@", errorFlag);

        return errorFlag;

    }

    // Map msgbuffer to interface message structure

    interfaceMsgStruct = (structif_msghdr *) msgBuffer;

    // Map to link-level socket structure

    socketStruct = (structsockaddr_dl *) (interfaceMsgStruct +1);

    // Copy link layer address data in socket structure to an array

    memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen,6);

    // Read from char array into a string object, into traditional Mac address format

    NSString *macAddressString = [NSStringstringWithFormat:@"%02X%02X%02X%02X%02X%02X"

                                  macAddress[0], macAddress[1], macAddress[2], 

                                  macAddress[3], macAddress[4], macAddress[5]]; 

    // DLog(@"Mac Address: %@", macAddressString); 

    // Release the buffer memory 

    free(msgBuffer);

    

    NSLog(@"mac = %@",macAddressString);

    

    return macAddressString; 


IDFA

1、添加框架
AdSupport.framework
2、添加头文件
#import <AdSupport/ASIdentifierManager.h>
3、使用语句
NSString *adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值