根据我最初的问题
Ionic native push registration format changed?
我需要解析/转换
{"registrationId":"{length=32,bytes=0x459ca46ab66f4fe790220809215176d6...21b3436d13e78c64}","registrationType":"APNS"}
为字符串。看来字节后的值是我所需要的。 如何使用Typescript / javascript从该缓冲区解析出推送令牌? 目标C解决方案似乎已经存在,但是现在我正在寻找打字稿解决方案。
https://onesignal.com/blog/ios-13-introduces-4-breaking-changes-to-notifications/
+ (NSString *)stringFromDeviceToken:(NSData *)deviceToken {
NSUInteger length = deviceToken.length;
if (length == 0) {
return nil;
}
const unsigned char *buffer = deviceToken.bytes;
NSMutableString *hexString = [NSMutableString stringWithCapacity:(length * 2)];
for (int i = 0; i < length; ++i) {
[hexString appendFormat:@"%02x", buffer[i]];
}
return [hexString copy];
}