iOS追踪权限

iOS追踪权限,第1张

iOS中idfa是很常见的一个属性,但是现在苹果爸爸也要求权限设置了,其实跟网络、定位、通知等差不多设置,我踩过的坑小伙伴避免一下,正确步骤科普一下:
1、系统依赖库:

    iAd.framework、AdSupport.framework、Adserver.framework、AppTrackingTransparency.framework

2、 权限注册

3、d框

if (![Tools AskDatafromLocalofNSString:@"user-idfa"])
{
    if (@available(iOS 14, *)) {
            [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
                if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
                    NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
                    [Tools SaveDatatoLocalofContent:idfa key:@"user-idfa"];
                }
            }];
        } else {
            if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
                NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
                [Tools SaveDatatoLocalofContent:idfa key:@"user-idfa"];
            }
        }
}

**重点强调一遍:第三部的方法必须写在applicationDidBecomeActive:(UIApplication *)application而不是- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions
**重点强调两遍:第三部的方法必须写在applicationDidBecomeActive:(UIApplication *)application而不是- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions
**重点强调三遍:第三部的方法必须写在applicationDidBecomeActive:(UIApplication *)application而不是- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/994441.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存