Skip to content

Instantly share code, notes, and snippets.

@Bucimis
Created September 13, 2019 19:49
Show Gist options
  • Save Bucimis/21b0258d65827a83cf20d4d8f030a9f6 to your computer and use it in GitHub Desktop.
Save Bucimis/21b0258d65827a83cf20d4d8f030a9f6 to your computer and use it in GitHub Desktop.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *tokenString;
if (@available(iOS 13.0, *)) {
NSUInteger dataLength = deviceToken.length;
if (dataLength == 0) {
return;
}
const unsigned char *dataBuffer = deviceToken.bytes;
NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
for (int i = 0; i < dataLength; ++i) {
[hexString appendFormat:@"%02x", dataBuffer[i]];
}
tokenString = [hexString copy];
} else {
tokenString = [NSString stringWithFormat:@"%@", deviceToken];
}
[[Appboy sharedInstance] registerPushToken:tokenString];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment