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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)