Browse Source

Firebase token

Marino Faggiana 8 years ago
parent
commit
bea83f0da6
1 changed files with 6 additions and 11 deletions
  1. 6 11
      iOSClient/AppDelegate.m

+ 6 - 11
iOSClient/AppDelegate.m

@@ -440,7 +440,12 @@
     if (self.activeAccount.length == 0)
         return;
     
-    NSString *pushToken = [[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""];
+    // FIREBASE registered token
+    [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox];
+    NSString *pushToken = [[FIRInstanceID instanceID] token];
+    NSLog(@"Firebase InstanceID token: %@", pushToken);
+    
+   // NSString *pushToken = [[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""];
     NSString *pushTokenHash = [[CCCrypto sharedManager] createSHA512:pushToken];
     
     NSDictionary *devicePushKey = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DevicePushKey-Info" ofType:@"plist"]];
@@ -451,18 +456,8 @@
     NSString *devicePublicKey = [devicePushKey objectForKey:@"devicePublicKeyProduction"];
 #endif
     
-    NSLog(@"DEVICE TOKEN = %@", pushToken);
-    
     if ([devicePublicKey length] > 0 && [pushTokenHash length] > 0) {
         
-        // FIREBASE
-        [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox];
-        
-        NSString *refreshedToken = [[FIRInstanceID instanceID] token];
-        NSLog(@"InstanceID token: %@", refreshedToken);
-
-        
-        
         CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
     
         NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:pushToken, @"pushToken", pushTokenHash, @"pushTokenHash", devicePublicKey, @"devicePublicKey", nil];