Skip to content

Instantly share code, notes, and snippets.

@sashamace
Created August 15, 2011 18:09
Show Gist options
  • Select an option

  • Save sashamace/1147338 to your computer and use it in GitHub Desktop.

Select an option

Save sashamace/1147338 to your computer and use it in GitHub Desktop.
uauser diff
diff --git a/Airship/Common/UAUser.m b/Airship/Common/UAUser.m
index dce379f..fbe8fba 100755
--- a/Airship/Common/UAUser.m
+++ b/Airship/Common/UAUser.m
@@ -481,18 +481,28 @@ static UAUser *_defaultUser;
[self saveUserData];
+ // Make sure we do a full user update with any device tokens, we'll unset this if it is not needed
+ [UAirship shared].deviceTokenHasChanged = YES;
+
// Check for device token. If it was present in the request, it was just updated, so set the flag in Airship
if (request.postBody != nil) {
+
NSString *requestString = [[NSString alloc] initWithData:request.postBody encoding:NSUTF8StringEncoding];
NSDictionary *requestDict = [parser objectWithString:requestString];
+
[requestString release];
+
if (requestDict != nil && [requestDict objectForKey:@"device_tokens"] != nil) {
+
//created a user w/ a device token
UALOG(@"Created a user with a device token.");
+
NSArray *deviceTokens = [requestDict objectForKey:@"device_tokens"];
NSString *deviceToken = [deviceTokens objectAtIndex:0];
+
if ([[[[UAirship shared] deviceToken] lowercaseString] isEqualToString:[deviceToken lowercaseString]]) {
UALOG(@"Device token is unchanged");
+
[UAirship shared].deviceTokenHasChanged = NO;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment