mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Only registering APNS token once, not once for every iOS-notification-enabled feed.
This commit is contained in:
parent
28f78ab4e2
commit
abad6e4986
1 changed files with 8 additions and 1 deletions
|
@ -535,12 +535,19 @@
|
|||
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||
const char *data = [deviceToken bytes];
|
||||
NSMutableString *token = [NSMutableString string];
|
||||
static NSMutableString *seenToken = nil;
|
||||
|
||||
for (NSUInteger i = 0; i < [deviceToken length]; i++) {
|
||||
[token appendFormat:@"%02.2hhX", data[i]];
|
||||
}
|
||||
|
||||
NSLog(@" -> APNS token: %@", token);
|
||||
if (seenToken && [seenToken isEqualToString:token]) {
|
||||
NSLog(@" -> Already registered APNS token: %@", token);
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@" -> Registering APNS token: %@", token);
|
||||
seenToken = token;
|
||||
NSString *url = [NSString stringWithFormat:@"%@/notifications/apns_token/", self.url];
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
[params setObject:token forKey:@"apns_token"];
|
||||
|
|
Loading…
Add table
Reference in a new issue