Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4110 #263

Merged
merged 21 commits into from
Dec 27, 2016
Merged

V4110 #263

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change push token injection
  • Loading branch information
nonelse committed Dec 19, 2016

Verified

This commit was signed with the committer’s verified signature.
Thegaram Péter Garamvölgyi
commit 0a72484c02b9b24b527a89e83104619edbfb2cb5
1 change: 0 additions & 1 deletion Adjust/ADJActivityHandler.h
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@
@property (nonatomic, assign) BOOL background;
@property (nonatomic, assign) BOOL delayStart;
@property (nonatomic, assign) BOOL updatePackages;
@property (nonatomic, copy) NSData* deviceToken;

- (id)init;

28 changes: 18 additions & 10 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
@@ -84,6 +84,7 @@ @interface ADJActivityHandler()
@property (nonatomic, weak) NSObject<AdjustDelegate> *adjustDelegate;
// copy for objects shared with the user
@property (nonatomic, copy) ADJConfig *adjustConfig;
@property (nonatomic, copy) NSData* deviceTokenData;

@end

@@ -157,7 +158,7 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig
} else {
self.internalState.updatePackages = self.activityState.updatePackages;
}
self.internalState.deviceToken = deviceToken;
self.deviceTokenData = deviceToken;

self.internalQueue = dispatch_queue_create(kInternalQueueName, DISPATCH_QUEUE_SERIAL);
[ADJUtil launchInQueue:self.internalQueue
@@ -603,6 +604,13 @@ - (void)initI:(ADJActivityHandler *)selfI
[selfI.logger info:@"Default tracker: '%@'", selfI.adjustConfig.defaultTracker];
}

if (selfI.deviceTokenData != nil) {
[selfI.logger info:@"Push token: '%@'", selfI.deviceTokenData];
if (selfI.activityState != nil) {
[selfI setDeviceToken:selfI.deviceTokenData];
}
}

selfI.foregroundTimer = [ADJTimerCycle timerWithBlock:^{
[selfI foregroundTimerFired];
}
@@ -683,7 +691,7 @@ - (void)processSessionI:(ADJActivityHandler *)selfI {
if (selfI.activityState == nil) {
selfI.activityState = [[ADJActivityState alloc] init];
selfI.activityState.sessionCount = 1; // this is the first session
selfI.activityState.deviceToken = [ADJUtil convertDeviceToken:self.internalState.deviceToken];
selfI.activityState.deviceToken = [ADJUtil convertDeviceToken:selfI.deviceTokenData];

[selfI transferSessionPackageI:selfI now:now];
[selfI.activityState resetSessionAttributes:now];
@@ -1046,22 +1054,22 @@ - (void)setDeviceTokenI:(ADJActivityHandler *)selfI
return;
}

// save new push token
selfI.activityState.deviceToken = deviceTokenString;
[selfI writeActivityStateI:selfI];

// send info package
double now = [NSDate.date timeIntervalSince1970];
ADJPackageBuilder * infoBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
activityState:selfI.activityState
config:selfI.adjustConfig
createdAt:now];

infoBuilder.deviceToken = deviceTokenString;
ADJActivityPackage * infoPackage = [infoBuilder buildInfoPackage:@"push"];

ADJActivityPackage * clickPackage = [infoBuilder buildInfoPackage:@"push"];

[selfI.sdkClickHandler sendSdkClick:clickPackage];

// save new push token
selfI.activityState.deviceToken = deviceTokenString;
[selfI writeActivityStateI:selfI];
[selfI.packageHandler addPackage:infoPackage];
[selfI.packageHandler sendFirstPackage];
}

#pragma mark - private
1 change: 0 additions & 1 deletion Adjust/ADJPackageBuilder.h
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@
@property (nonatomic, copy) NSDate *purchaseTime;

@property (nonatomic, copy) NSString *deeplink;
@property (nonatomic, copy) NSString *deviceToken;

@property (nonatomic, strong) NSDictionary *iadDetails;
@property (nonatomic, strong) NSDictionary* deeplinkParameters;
14 changes: 12 additions & 2 deletions Adjust/ADJPackageBuilder.m
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@ - (ADJActivityPackage *)buildInfoPackage:(NSString *)infoSource {

[ADJPackageBuilder parameters:parameters setString:infoSource forKey:@"source"];

[ADJPackageBuilder parameters:parameters setString:self.deviceToken forKey:@"push_token"];
[self injectPushToken:self.activityState intoParamters:parameters];

ADJActivityPackage *infoPackage = [self defaultActivityPackage];
infoPackage.path = @"/sdk_info";
@@ -237,11 +237,12 @@ - (void)injectConfig:(ADJConfig*) adjustConfig

- (void) injectActivityState:(ADJActivityState *)activityState
intoParamters:(NSMutableDictionary *)parameters {
[self injectPushToken:activityState intoParamters:parameters];

[ADJPackageBuilder parameters:parameters setInt:activityState.sessionCount forKey:@"session_count"];
[ADJPackageBuilder parameters:parameters setInt:activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setDuration:activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:activityState.deviceToken forKey:@"push_token"];

// Check if UUID was persisted or not.
// If yes, assign it to persistent_ios_uuid parameter.
@@ -253,6 +254,15 @@ - (void) injectActivityState:(ADJActivityState *)activityState
}
}

- (void)injectPushToken:(ADJActivityState *)activityState
intoParamters:(NSMutableDictionary *)parameters
{
if (activityState == nil) {
return;
}
[ADJPackageBuilder parameters:parameters setString:activityState.deviceToken forKey:@"push_token"];
}

- (NSString *)eventSuffix:(ADJEvent *)event {
if (event.revenue == nil) {
return [NSString stringWithFormat:@"'%@'", event.eventToken];