Back in October 2019, Apple changed the way they were getting device tokens for remote push notifications. Is there any progress on updating the engine code (IOSAppDelegate.cpp) to account for these changes?
I’m not the greatest at converting the objective-c to C++ (let alone UE4 C++), but it appears the new method should be this:
+ (NSString *)hexadecimalStringFromData:(NSData *)data
{
NSUInteger dataLength = data.length;
if (dataLength == 0) {
return nil;
}
const unsigned char *dataBuffer = (const unsigned char *)data.bytes;
NSMutableString *hexString = [NSMutableString stringWithCapacity : (dataLength * 2)];
for (int i = 0; i < dataLength; ++i) {
[hexString appendFormat : @"%02x", dataBuffer[i]];
}
return[hexString copy];
}
Whereas the current code is this:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
if (FApp::IsUnattended())
{
return;
}
TArray<uint8> Token;
Token.AddUninitialized([deviceToken length]);
memcpy(Token.GetData(), [deviceToken bytes], [deviceToken length]);
const char *data = (const char*)([deviceToken bytes]);
NSMutableString *token = [NSMutableString string];
for (NSUInteger i = 0; i < [deviceToken length]; i++) {
[token appendFormat : @"%02.2hhX", data[i]];
}
UE_LOG(LogTemp, Display, TEXT("Device Token: %s"), *FString(token));
FFunctionGraphTask::CreateAndDispatchWhenReady([Token]()
{
FCoreDelegates::ApplicationRegisteredForRemoteNotificationsDelegate.Broadcast(Token);
}, TStatId(), NULL, ENamedThreads::GameThread);
}
If anyone has already updated the source and would like to share their changes, that’d be super helpful. Our game is already in production, and the most recent change for iOS kind of screwed our push notification updates we were planning on implementing.
Thanks in advance.