Home iOS Development ios – Firebase Messaging and APNS token received from Appdelete both are different

ios – Firebase Messaging and APNS token received from Appdelete both are different

0

[ad_1]

I am trying to get the device token in react native project.

Below is the code implemented in React Native:

Result Token: f0sns4E3NxxxxxxxxTd:APA00bG-xxxxxxxxxxxxxxxxx__xxxxxxxxxxxxxxxj0cC3ksfzdxxxxxxxxxx-XXXXXXXXXXXCoidSFmzAB7IXuj36vXXXXXXXXlVxtqXXXXXXXXXX-phOXXXXXxZSVBXXXXX

const getDeviceToken = await firebase.messaging().getAPNSToken();
  if (getDeviceToken) {
    console.log('getDeviceToken:', getDeviceToken);
  }

Below is the code implemented in iOS side

Result token is : XXXXXXXX51b9aeXXXXX255b4dbXXXXXXXXfbd5ceaXXXXX72d8bd4XXXXXXXX


- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    NSString *strDeviceToken = [self fetchDeviceToken:deviceToken];
    NSLog(@"strDeviceToken =>%@", strDeviceToken);
}

- (NSString *)fetchDeviceToken:(NSData *)deviceToken {
    NSUInteger len = deviceToken.length;
    if (len == 0) {
        return nil;
    }
    const unsigned char *buffer = deviceToken.bytes;
    NSMutableString *hexString  = [NSMutableString stringWithCapacity:(len * 2)];
    for (int i = 0; i < len; ++i) {
        [hexString appendFormat:@"%02x", buffer[i]];
    }
    return [hexString copy];
}

Why both tokens are different. I am trying to implement push notification using firebase service. Which method should i implement.

[ad_2]