|
19 | 19 | #import "AIAdjustFactory.h" |
20 | 20 |
|
21 | 21 | static NSString * const kActivityStateFilename = @"AdjustIoActivityState"; |
| 22 | +static NSString * const kAdjustPrefix = @"adjust_"; |
22 | 23 | static const char * const kInternalQueueName = "io.adjust.ActivityQueue"; |
23 | | -static NSString * const kAdjustPrefix = @"adjust_"; |
24 | 24 |
|
25 | | -static const uint64_t kTimerInterval = 60 * NSEC_PER_SEC; // 1 minute |
26 | | -static const uint64_t kTimerLeeway = 1 * NSEC_PER_SEC; // 1 second |
| 25 | +static const uint64_t kTimerInterval = 60 * NSEC_PER_SEC; // 1 minute |
| 26 | +static const uint64_t kTimerLeeway = 1 * NSEC_PER_SEC; // 1 second |
27 | 27 |
|
28 | 28 |
|
29 | 29 | #pragma mark - |
@@ -317,32 +317,37 @@ - (void)revenueInternal:(double)amount |
317 | 317 | } |
318 | 318 |
|
319 | 319 | - (void) readOpenUrlInternal:(NSURL *)url { |
320 | | - NSString* queryString = [url query]; |
321 | | - NSArray* queryArray = [queryString componentsSeparatedByString:@"&"]; |
| 320 | + NSArray* queryArray = [url.query componentsSeparatedByString:@"&"]; |
322 | 321 | NSMutableDictionary* adjustDeepLinks = [NSMutableDictionary dictionary]; |
323 | 322 |
|
324 | 323 | for (NSString* fieldValuePair in queryArray) { |
325 | 324 | NSArray* pairComponents = [fieldValuePair componentsSeparatedByString:@"="]; |
| 325 | + if (pairComponents.count != 2) continue; |
| 326 | + |
326 | 327 | NSString* key = [pairComponents objectAtIndex:0]; |
327 | | - if ([key hasPrefix:kAdjustPrefix] && [pairComponents count] == 2) { |
328 | | - NSString* value = [pairComponents objectAtIndex:1]; |
329 | | - NSString* keyWOutPrefix = [key substringFromIndex:[kAdjustPrefix length]]; |
330 | | - if ([keyWOutPrefix length] > 0 && [value length] > 0) { |
331 | | - [adjustDeepLinks setObject:value forKey:keyWOutPrefix]; |
332 | | - } |
333 | | - } |
334 | | - } |
| 328 | + if (![key hasPrefix:kAdjustPrefix]) continue; |
335 | 329 |
|
336 | | - if ([adjustDeepLinks count] != 0) { |
337 | | - AIPackageBuilder *reattributionBuilder = [[AIPackageBuilder alloc] init]; |
338 | | - reattributionBuilder.deeplinkParameters = adjustDeepLinks; |
339 | | - [self injectGeneralAttributes:reattributionBuilder]; |
340 | | - AIActivityPackage *reattributionPackage = [reattributionBuilder buildReattributionPackage]; |
341 | | - [self.packageHandler addPackage:reattributionPackage]; |
342 | | - [self.packageHandler sendFirstPackage]; |
| 330 | + NSString* value = [pairComponents objectAtIndex:1]; |
| 331 | + if (value.length == 0) continue; |
| 332 | + |
| 333 | + NSString* keyWOutPrefix = [key substringFromIndex:kAdjustPrefix.length]; |
| 334 | + if (keyWOutPrefix.length == 0) continue; |
343 | 335 |
|
344 | | - [self.logger info:@"Reattribution %@", adjustDeepLinks]; |
| 336 | + [adjustDeepLinks setObject:value forKey:keyWOutPrefix]; |
345 | 337 | } |
| 338 | + |
| 339 | + if (adjustDeepLinks.count == 0) { |
| 340 | + return; |
| 341 | + } |
| 342 | + |
| 343 | + AIPackageBuilder *reattributionBuilder = [[AIPackageBuilder alloc] init]; |
| 344 | + reattributionBuilder.deeplinkParameters = adjustDeepLinks; |
| 345 | + [self injectGeneralAttributes:reattributionBuilder]; |
| 346 | + AIActivityPackage *reattributionPackage = [reattributionBuilder buildReattributionPackage]; |
| 347 | + [self.packageHandler addPackage:reattributionPackage]; |
| 348 | + [self.packageHandler sendFirstPackage]; |
| 349 | + |
| 350 | + [self.logger debug:@"Reattribution %@", adjustDeepLinks]; |
346 | 351 | } |
347 | 352 |
|
348 | 353 | #pragma mark - private |
|
0 commit comments