About UDID

随着iOS5中UDID方法的弃用,本文探讨了替代方案,包括使用MAC地址和自定义UUID来唯一标识设备或用户,同时考虑隐私问题。
部署运行你感兴趣的模型镜像

How to Replace the UDID

iOS 5 is still in beta, yet Techcrunch revealed a few weeks ago that Apple will deprecate the -[UIDevice uniqueIdentifier] method in iOS 5. This method returns a device’s UDID, the 40 character hex string that uniquely identifies each device.

Many developers use this value to anonymously track usage of their apps or to create user accounts on an app-related web service without requiring the user to register an account manually. Unfortunately, the nature of the UDID also makes it easy to track users across multiple apps if those apps talk to the same webservice such as an ad network or analytics service, as so many apps do.

Apple apparently considers this a big enough privacy problem to phase out developer access to the UDID (and rightly so if you ask me). So what should you do if your app relies on the UDID at the moment?

Don’t Panic

Keep in mind that the method has just been deprecated in iOS 5, not removed. So for the time being, nothing really changes. Apple probably won’t remove it until the release of iOS 6 or even later, so you have plenty of time to consider alternatives.

The MAC Address as a Replacement

Every network adapter on the planet needs a unique MAC address to identify itself on the network. Since every iOS device has at least one network interface, the MAC address can serve as a full replacement for the UDID. Check out this code on GitHub by Georg Kitz to find out how to access it on an iOS device.

You don’t need to access private APIs to retrieve the MAC address so this should be safe for the App Store. Still, Apple clearly intends to block access to identifiers that can be used to track user behavior across multiple apps. Depending on what you use this identifier for, I would expect Apple to reject apps that do “malicious” user tracking based on the MAC address in the future.

Rather than blindly replacing the UDID with the MAC address, I urge you to think about your actual requirements. Do you really need a unique hardware identifier? I would argue that in most cases, a uniqueuser identifier is much more useful.

Do You Really Need a Hardware Identifier

Both the UDID and the MAC address are device identifiers. As such, they don’t tell you anything about a specific user. While the iPhone and iPod touch are primarily personal devices and thus normally only used by one person, this is less true for the iPad, which gets often shared by a family. Also, most people will replace their device with a new one sooner or later, and often they will sell their old device or give it away to a family member.

This is a real problem if your webservice equates the hardware identifier with a specific user when it really should have been tracking users instead of devices all along. So we would have to replace the UDID with a user ID. Such a user identifier should survive software updates, full system restores and device replacements, which is more than the UDID or MAC address can do. Ideally, it should also identify the same user on multiple devices (such as an iPhone and an iPad). Admittedly, that is not possible with the simple solution I present here.

Self-made UUIDs

To create our own unique identifier, we use the Core Foundation function CFUUIDCreate(). It returns a reference to an opaque type CFUUIDRef, which we can convert into a string with theCFUUIDCreateString function.

It is good practice to wrap these calls in a small NSString category so that we can reuse them easily (UUIDs come in handy in many cases, for example if you need to generate unique filenames):

@interface NSString (UUID)

+ (NSString *)uuid;

@end


@implementation NSString (UUID)

+ (NSString *)uuid
{
    NSString *uuidString = nil;
    CFUUIDRef uuid = CFUUIDCreate(NULL);
    if (uuid) {
        uuidString = (NSString *)CFUUIDCreateString(NULL, uuid);
        CFRelease(uuid);
    }
    return [uuidString autorelease];
}

@end

Now, in our code, we generate a fresh UUID on the first launch of our app and store it to the user defaults database:

#define UUID_USER_DEFAULTS_KEY @"UUID"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:UUID_USER_DEFAULTS_KEY] == nil) {
        [defaults setObject:[NSString uuid] forKey:UUID_USER_DEFAULTS_KEY];
        [defaults synchronize];
    }
    
    ...

That way, our UUID will automatically be backed up and restored to a new device.

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

/** * @internal appDemoDxChDbReset function * @endinternal * * @brief DxCh DB reset. (part of 'System reset') * * @param[in] devNum - device number * @param[in] needHwReset - indication to do HW reset * @param[in] needFullDbCleanUp - indication to do full DB reset (or skip it to minimal) * * @retval GT_OK - on success, * @retval GT_FAIL - otherwise. */ GT_STATUS appDemoDxChDbReset ( IN GT_U8 devNum, IN GT_BOOL needHwReset, IN GT_BOOL needFullDbCleanUp ) { GT_STATUS rc; /* To hold funcion return code */ static GT_CHAR devMustNotResetPort_str[100]; CPSS_PORTS_BMP_STC portBmp;/* bmp for port */ GT_U32 port;/* port iterator */ struct { GT_U32 regAddr; GT_U32 value; } regsToRestore[] = { /* Unit Default ID (UDID) Register */ { 0x00000204, 0 }, /* Window n registers (n=0..5) * Base Address, * Size, * High Address Remap, * Window Control */ { 0x020c, 0 }, { 0x0210, 0 }, { 0x23c, 0}, { 0x0254, 0 }, { 0x0214, 0 }, { 0x0218, 0 }, { 0x240, 0}, { 0x0258, 0 }, { 0x021c, 0 }, { 0x0220, 0 }, { 0x244, 0}, { 0x025c, 0 }, { 0x0224, 0 }, { 0x0228, 0 }, { 0x248, 0}, { 0x0260, 0 }, { 0x022c, 0 }, { 0x0230, 0 }, { 0x24c, 0}, { 0x0264, 0 }, { 0x0234, 0 }, { 0x0248, 0 }, { 0x250, 0}, { 0x0258, 0 }, /* address completion are used by LSP of MSYS for eth port PHY managment */ { 0x0124, 0 }, { 0x0128, 0 }, { 0x012c, 0}, { 0x0130, 0 }, { 0x0134, 0 }, { 0x0138, 0 }, { 0x013c, 0}, /* SMI Master controller configuration is used for BobK systems for MSYS eth port PHY managment */ { SMI_MNG_ADDRESS_MARK_CNS, 0 }, /* must be last before {0,0} */ { 0, 0 }/* END */ }; GT_U32 ii; GT_UINTPTR deviceBaseAddrOnPex; GT_U32 doMgDecodingRestore; CPSS_PP_INTERFACE_CHANNEL_ENT ifChannel; /* DIAG device channel access type */ GT_U32 value; GT_BOOL doByteSwap; GT_U32 supportMgWindowsRegisters = 1; GT_U32 mgOffset; GT_U32 *unitBasePtr; if(PRV_CPSS_IS_DEV_EXISTS_MAC(devNum) == 0) { return (GT_STATUS)GT_ERROR; } if (PRV_CPSS_SIP_5_CHECK_MAC(devNum)) { /* all SIP5 devices should use PEX_MBUS driver with 8 regions address completion. */ ifChannel = CPSS_CHANNEL_PEX_MBUS_E; } else { ifChannel = CPSS_CHANNEL_PEX_E; } #ifdef ASIC_SIMULATION doMgDecodingRestore = 0; if (!PRV_CPSS_SIP_5_CHECK_MAC(devNum) && !PRV_CPSS_DXCH_IS_AC3_BASED_DEVICE_MAC(devNum)) { /* the memory space was not implemented ... and not really needed */ supportMgWindowsRegisters = 0; } #else doMgDecodingRestore = 1; #endif if(PRV_CPSS_SIP_6_CHECK_MAC(devNum) || (PRV_CPSS_PP_MAC(devNum)->devFamily == CPSS_PP_FAMILY_DXCH_AC5_E)) { supportMgWindowsRegisters = 0; /* we skip the MG 'save' and 'restore' because the 'init phase' in the appDemo is calling to : extern GT_STATUS prvNoKmDrv_configure_dma_per_devNum(IN GT_U8 devNum , IN GT_U32 portGroupId); that initialize the MG[0] of the device. and the 'cpss init phase2' will copy it from MG[0] to all other MGs */ } if (PRV_CPSS_SIP_7_CHECK_MAC(devNum)) { /* NO MG unit(s) */ supportMgWindowsRegisters = 0; doMgDecodingRestore = 0; mgOffset = 0;/* not used , but for compiler warning only */ } else { unitBasePtr = NULL; rc = prvCpssDxChUnitBaseTableGet(devNum, &unitBasePtr); if ((GT_NOT_APPLICABLE_DEVICE != rc) && (rc != GT_OK)) { return rc; } mgOffset = (NULL == unitBasePtr)?0:unitBasePtr[PRV_CPSS_DXCH_UNIT_MG_E]; for(ii = 0; ii < sizeof(regsToRestore)/sizeof(regsToRestore[0]); ii++) { if(0 == regsToRestore[ii].regAddr) { break; } regsToRestore[ii].regAddr += mgOffset; } } if(needHwReset == GT_FALSE) { doMgDecodingRestore = 0; } /*osPrintf("appDemoDxChDbReset - start \n");*/ if(GT_TRUE == needFullDbCleanUp) { /* IP LPM DB Clear - main LBM DB deleted, all prefixes removed, all VR removed */ rc = prvIpLpmLibReset(); CPSS_ENABLER_DBG_TRACE_RC_MAC("prvIpLpmLibReset", rc); if (rc != GT_OK) { return rc; } #ifdef IMPL_TM if(PRV_CPSS_PP_MAC(devNum)->tmInfo.tmHandle != NULL) { /* TM DB Clear */ rc = cpssTmClose(devNum); CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssTmClose", rc); if (rc != GT_OK) { return rc; } } #endif /*IMPL_TM*/ /* reset TCAM related DBs */ appDemoDxChTcamDbReset(); /* Reset FDB Manager SW Db */ rc = prvCpssDxChFdbManagerAllDbDelete(); CPSS_ENABLER_DBG_TRACE_RC_MAC("prvCpssDxChFdbManagerAllDbDelete", rc); if(rc != GT_OK) { return rc; } /* Reset Exact Match Manager SW Db */ rc = prvCpssDxChExactMatchManagerAllDbDelete(); CPSS_ENABLER_DBG_TRACE_RC_MAC("prvCpssDxChExactMatchManagerAllDbDelete", rc); if(rc != GT_OK) { return rc; } } else { BYPASS_DB_CLEANUP_MAC(prvIpLpmLibReset); BYPASS_DB_CLEANUP_MAC(cpssTmClose); BYPASS_DB_CLEANUP_MAC(appDemoDxChTcamDbReset); } if(supportMgWindowsRegisters) { /* fill-in registers restore DB by run time values */ for(ii = 0 ; regsToRestore[ii].regAddr != 0; ii++) { if(SMI_MNG_ADDRESS_MARK_CNS == regsToRestore[ii].regAddr) { if(PRV_CPSS_DXCH_PP_MAC(devNum)->hwInfo.gop_lms.notSupported == GT_TRUE) { regsToRestore[ii].regAddr = PRV_CPSS_DXCH_DEV_REGS_VER1_MAC(devNum)->GOP.SMI[0].SMIMiscConfiguration; } else { /* BC2 A0 - MSYS does not use this register. mark as last one and not used */ regsToRestore[ii].regAddr = 0; } } } } CPSS_PORTS_BMP_PORT_CLEAR_ALL_MAC(&portBmp); cpssOsBzero(devMustNotResetPort_str, sizeof(devMustNotResetPort_str)); /* power down all ports */ for(port = 0 ; port < CPSS_MAX_PORTS_NUM_CNS /*support 256 ports in bc2*/; port++) { if(prvCpssDxChPortRemotePortCheck(devNum,port)) { /* we allow remote ports ... see logic below */ } else if(GT_FALSE == appDemoDxChIsPhysicalPortHoldMac(devNum,port)) { /* skip ports without MAC */ continue; } cpssOsSprintf(devMustNotResetPort_str,"devMustNotResetPort_str_d[%d]p[%d]",devNum,port); if(appDemoStaticDbEntryGet(devMustNotResetPort_str,&value)== GT_OK) { if(value) { /* port 90 is used for MAC 62 in BobK. Power down of SERDES for this port kills OOB port. Skip this ports. */ osPrintf("appDemoDxChDbReset : SKIP reset of port [%d] because 'MUST NOT RESET' flag \n", port); continue; } } if(portMgr) { /* support port manager operation */ (void)appDemoPortInitSeqDeletePortStage(devNum, port); } else { /* set the port in bmp */ CPSS_PORTS_BMP_PORT_SET_MAC(&portBmp,port); rc = cpssDxChPortModeSpeedSet(devNum, &portBmp, GT_FALSE, /*don't care*/CPSS_PORT_INTERFACE_MODE_SGMII_E, /*don't care*/CPSS_PORT_SPEED_1000_E); if (rc != GT_OK) { /* do not break .. maybe port not exists but we not have here knowledge about it */ if(port < PRV_CPSS_PP_MAC(devNum)->numOfPorts) { /* give indication about ports that are supposed to be in 'valid range' note that for BC2 ports 60..63 could give 'false alarm' indication */ /*osPrintf("cpssDxChPortModeSpeedSet : failed on port[%d] \n", port);*/ } } } /* Remote ports are not HW reset: Restore HW defaults */ if (needHwReset && prvCpssDxChPortRemotePortCheck(devNum,port)) { cpssDxChPortForceLinkPassEnableSet(devNum,port,GT_FALSE); cpssDxChPortForceLinkDownEnableSet(devNum,port,GT_FALSE); } /* remove the port from bmp */ CPSS_PORTS_BMP_PORT_CLEAR_MAC(&portBmp,port); } if(needHwReset == GT_TRUE) { CPSS_HW_INFO_STC *hwInfoPtr; hwInfoPtr = cpssDrvHwPpHwInfoStcPtrGet(devNum, 0); if (hwInfoPtr == NULL) return GT_FAIL; deviceBaseAddrOnPex = hwInfoPtr->resource.switching.start; osPrintf("deviceBaseAddrOnPex = 0x %p \n",deviceBaseAddrOnPex); doByteSwap = GT_FALSE; if(supportMgWindowsRegisters) { /* read the registers */ for(ii = 0 ; regsToRestore[ii].regAddr != 0; ii++) { rc = prvCpssDrvHwPpReadRegister(devNum,regsToRestore[ii].regAddr,&(regsToRestore[ii].value)); CPSS_ENABLER_DBG_TRACE_RC_MAC("prvCpssDrvHwPpReadRegister", rc); if (rc != GT_OK) { return rc; } } rc = cpssDxChDiagRegRead(deviceBaseAddrOnPex, ifChannel, CPSS_DIAG_PP_REG_INTERNAL_E, mgOffset + 0x50, &value, doByteSwap); CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssDxChDiagRegRead", rc); if (rc != GT_OK) { return rc; } if(value == 0xAB110000) { doByteSwap = GT_TRUE; } } } else { deviceBaseAddrOnPex = 0;/* dummy.. will not be used */ doByteSwap = GT_FALSE; /* dummy.. will not be used */ } if(appDemoDbEntryGet("mgcamEnable", &value) == GT_OK) { /* disable MGCAM before remove device */ appDemoMgCamEnableSet(devNum, GT_FALSE); } if(needHwReset == GT_TRUE) { /* logic above generates interrupts. Provide time for CPU to take care of them. */ cpssOsTimerWkAfter(100); /* do 'atomic' device remove after device reset */ rc = doAtomicDeviceResetAndRemove(devNum); CPSS_ENABLER_DBG_TRACE_RC_MAC("doAtomicDeviceResetAndRemove", rc); if (rc != GT_OK) { return rc; } } else { if(skipRemoveDeviceFromCpss_get()) { osPrintf("appDemoDxChDbReset : DO NOT 'remove device from cpss' --- SKIP the remove device operation \n"); } else { /* do device remove without device reset */ osPrintf("appDemoDxChDbReset : 'remove device from cpss' \n"); rc = cpssDxChCfgDevRemove(devNum); CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssDxChCfgDevRemove", rc); if (rc != GT_OK) { return rc; } } } /* let the device minimal time for reset before we restore next registers */ osTimerWkAfter(1); if(doMgDecodingRestore && supportMgWindowsRegisters) { osPrintf("appDemoDxChDbReset : (after soft reset) restore 'MG Registers/Address Decoding' configurations \n"); rc = cpssDxChDiagRegRead(deviceBaseAddrOnPex, ifChannel, CPSS_DIAG_PP_REG_INTERNAL_E, mgOffset + 0x50, &value, doByteSwap); CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssDxChDiagRegRead", rc); if (rc != GT_OK) { return rc; } /*osPrintf("cpssDxChDiagRegRead:deviceBaseAddrOnPex[0x%x] reg[0x50] with value[%d] doByteSwap[%d] \n", deviceBaseAddrOnPex,value,doByteSwap);*/ /* restore the registers of : <MG_IP> MG_IP/MG Registers/Address Decoding/Base Address %n 0x0000020C + n*8: where n (0-5) represents BA and: <MG_IP> MG_IP/MG Registers/Address Decoding/Size (S) %n 0x00000210 + n*0x8: where n (0-5) represents SR and: <MG_IP> MG_IP/MG Registers/Address Decoding/High Address Remap %n 0x0000023c + n*0x4: where n (0-5) represents HA and : <MG_IP> MG_IP/MG Registers/Address Decoding/Window Control Register%n 0x00000254 + n*4: where n (0-5) represents n */ if(supportMgWindowsRegisters) { /* write the saved registers */ /* since the device was removed from cpss ... we must use the 'diag' functions to write to the device ... */ /* restore the registers */ for(ii = 0 ; regsToRestore[ii].regAddr != 0; ii++) { rc = cpssDxChDiagRegWrite(deviceBaseAddrOnPex, ifChannel, CPSS_DIAG_PP_REG_INTERNAL_E, regsToRestore[ii].regAddr, regsToRestore[ii].value, doByteSwap); CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssDxChDiagRegWrite", rc); if (rc != GT_OK) { return rc; } } } } osPrintf("appDemoDxChDbReset - ended \n"); return GT_OK; 貌似是/* do device remove without device reset */ osPrintf("appDemoDxChDbReset : 'remove device from cpss' \n"); rc = cpssDxChCfgDevRemove(devNum);这里报错,分析下原因
10-21
标题基于Python的汽车之家网站舆情分析系统研究AI更换标题第1章引言阐述汽车之家网站舆情分析的研究背景、意义、国内外研究现状、论文方法及创新点。1.1研究背景与意义说明汽车之家网站舆情分析对汽车行业及消费者的重要性。1.2国内外研究现状概述国内外在汽车舆情分析领域的研究进展与成果。1.3论文方法及创新点介绍本文采用的研究方法及相较于前人的创新之处。第2章相关理论总结和评述舆情分析、Python编程及网络爬虫相关理论。2.1舆情分析理论阐述舆情分析的基本概念、流程及关键技术。2.2Python编程基础介绍Python语言特点及其在数据分析中的应用。2.3网络爬虫技术说明网络爬虫的原理及在舆情数据收集中的应用。第3章系统设计详细描述基于Python的汽车之家网站舆情分析系统的设计方案。3.1系统架构设计给出系统的整体架构,包括数据收集、处理、分析及展示模块。3.2数据收集模块设计介绍如何利用网络爬虫技术收集汽车之家网站的舆情数据。3.3数据处理与分析模块设计阐述数据处理流程及舆情分析算法的选择与实现。第4章系统实现与测试介绍系统的实现过程及测试方法,确保系统稳定可靠。4.1系统实现环境列出系统实现所需的软件、硬件环境及开发工具。4.2系统实现过程详细描述系统各模块的实现步骤及代码实现细节。4.3系统测试方法介绍系统测试的方法、测试用例及测试结果分析。第5章研究结果与分析呈现系统运行结果,分析舆情数据,提出见解。5.1舆情数据可视化展示通过图表等形式展示舆情数据的分布、趋势等特征。5.2舆情分析结果解读对舆情分析结果进行解读,提出对汽车行业的见解。5.3对比方法分析将本系统与其他舆情分析系统进行对比,分析优劣。第6章结论与展望总结研究成果,提出未来研究方向。6.1研究结论概括本文的主要研究成果及对汽车之家网站舆情分析的贡献。6.2展望指出系统存在的不足及未来改进方向,展望舆情
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值