產(chǎn)品說boss要對接appsflyer sdk
遇到了不少坑這里記錄下:
在app聯(lián)網(wǎng)時調(diào)用這個初始化
?? ? {
? ? ? ? ? ? ? ? ? ? dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
? ? ? ? ? ? ? ? ? ? ? ? [[AppsFlyerLib shared] setAppsFlyerDevKey:kAppsFlyerDevKey];
? ? ? ? ? ? ? ? ? ? ? ? [[AppsFlyerLib shared] setAppleAppID:kAppleID_str];
? ? ? ? ? ? ? ? ? ? ? ? [AppsFlyerLib shared].shouldCollectDeviceName =YES;
? ? ? ? ? ? ? ? ? ? ? ? [[AppsFlyerLib shared] setDelegate:self];
? ? ? ? ? ? ? ? ? ? ? ? [[AppsFlyerLib shared] setDeepLinkDelegate:self];
? ? ? ? ? ? ? ? ? ? ? ? // 20230606?// 20230606 AppsFlyer需要確保用戶已經(jīng)明確授權(quán)App跟蹤甩鳄。這個方法可能是用來延遲初始化SDK挂脑,直到用戶授權(quán)跟蹤發(fā)生稀火。這個waitForATTUserAuthorizationWithTimeoutInterval很重要要不然afid會拿不到
? ? ? ? ? ? ? ? ? ? ? ? [[AppsFlyerLib shared] waitForATTUserAuthorizationWithTimeoutInterval:120];
? ? ? ? ? ? ? ? ? ? ? ? //
? ? ? ? ? ? ? ? ? ? ? ? [[AppsFlyerLib shared] start];
? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? }
遵守代理:
- (void)didResolveDeepLink:(AppsFlyerDeepLinkResult *)result {
? ? switch(result.status) {
? ? ? ? case AFSDKDeepLinkResultStatusNotFound:
? ? ? ? ? ? NSLog(@"555-not found");
//? ? ? ? ? ? [CommonUtil showCommonToastWithStr:@"新安裝數(shù)據(jù) not found" hideAfterSeconds:2 andAfterPostAction:nil postObject:nil];
? ? ? ? ? ? break;
? ? ? ? case AFSDKDeepLinkResultStatusFailure:
? ? ? ? ? ? NSLog(@"555-link failure");
//? ? ? ? ? ? [CommonUtil showCommonToastWithStr:@"新安裝數(shù)據(jù) link failure" hideAfterSeconds:2 andAfterPostAction:nil postObject:nil];
? ? ? ? ? ? break;
? ? ? ? case AFSDKDeepLinkResultStatusFound:
? ? ? ? ? ? NSLog(@"555-link found");
? ? ? ? ? ? break;
? ? ? ? default:
? ? ? ? ? ? break;
? ? }
? ? AppsFlyerDeepLink*deepLink =? (AppsFlyerDeepLink *)result.deepLink;
//? ? deepLink.campaignId
? ? NSString*str =? [deepLinktoString];
? ? NSLog(@"str555:%@",str);
? ? //po deepLink
//? ? {"af_sub4":"","click_http_referrer":"","af_sub1":"","click_event":{"af_sub4":"","click_http_referrer":"","af_sub1":"","af_sub3":"","deep_link_value":"xxxticketxxx,xxxuidxxx","campaign":"","match_type":"probabilistic","af_sub5":"","campaign_id":"","media_source":"","af_sub2":""},"af_sub3":"","deep_link_value":"xxxticketxxx,xxxuidxxx","campaign":"","match_type":"probabilistic","af_sub5":"","media_source":"","campaign_id":"","af_sub2":""}
? ? if(deepLink !=nil) {
? ? ? ? // AppsFlyerDeepLink
? ? ? ? NSString*mydeeplinkValue =? deepLink.deeplinkValue;
? ? ? ? NSString*mymediaSource = deepLink.mediaSource;
? ? ? ? NSString*campaignId = deepLink.campaignId;
//? ? ? ? [CommonUtil showCommonToastWithStr:[NSString stringWithFormat:@"新安裝拿到數(shù)據(jù):%@",mydeeplinkValue] hideAfterSeconds:2 andAfterPostAction:nil postObject:nil];
? ? ? ? if(mydeeplinkValue) {
? ? ? ? ? ? [[NSUserDefaultsstandardUserDefaults]setObject:mydeeplinkValueforKey:@"AFDeepLinkValue"];
//? ? ? ? ? ? [self.afLinkBindReq zzAFLinkBind];
? ? ? ? ? ? [[AuditingManager sharedInstance]getAuditingNet:^{
? ? ? ? ? ? ? ? [BRAppDelegatehideHUD];
? ? ? ? ? ? ? ? if(![CommonUtilisXPLogined] && [CommonUtilisPassDeviceLogin]) {
? ? ? ? ? ? ? ? ? ? [[NSNotificationCenter defaultCenter]postNotificationName:@"extendDeviceLog" object:nil];
? ? ? ? ? ? ? ? ? ? NSLog(@"postNotificationName:------extendDeviceLog");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }];
? ? ? ? }
? ? ? ? if(mymediaSource) {
? ? ? ? ? ? [[NSUserDefaultsstandardUserDefaults]setObject:mymediaSourceforKey:@"AFMediaSource"];
? ? ? ? }
? ? ? ? [[NSUserDefaults standardUserDefaults] synchronize];
? ? }else{
? ? ? ? [[AuditingManager sharedInstance]getAuditingNet:^{
? ? ? ? ? ? [BRAppDelegatehideHUD];
? ? ? ? ? ? if(![CommonUtilisXPLogined] && [CommonUtilisPassDeviceLogin]) {
? ? ? ? ? ? ? ? [[NSNotificationCenter defaultCenter]postNotificationName:@"refreshDeviceUI" object:nil];
? ? ? ? ? ? }
? ? ? ? }];
? ? }
}
若是還是拿不到網(wǎng)頁點進來的 回調(diào)(上方的dele方法:DeepLinkDelegate)
那么就讓web人員在鏈接里加上:固定格式桥帆,必須帶:af_force_deeplink=true&deep_link_sub1-10=2