環境
- iPhone8
- iOS13.1.2
- Xcode11.1 GM
原因
- Objective-cの下記のコードで渡るdeviceTokenの中身が変わっていた
SampleAppDelegate.m
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// iOS12:<00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000>
// iOS13:{length = 32, bytes = 0x00000000 00000000 00000000 00000000 ... 00000000 00000000 }
NSString *token = deviceToken.description;
}
対応
SampleAppDelegate.m
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *token = [self hexadecimalStringFromData:deviceToken];
}
-(NSString *)hexadecimalStringFromData:(NSData *)data {
NSUInteger dataLength = data.length;
if (dataLength == 0) {
return nil;
}
const unsigned char *dataBuffer = data.bytes;
NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
for (int i = 0; i < dataLength; ++i) {
[hexString appendFormat:@"%02x", dataBuffer[i]];
}
return [hexString copy];
}