Looking to convert a push token (`NSData` ) to a s...
# ios
j
Looking to convert a push token (
NSData
) to a string in Kotlin This is what I have done previously
Copy code
let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
    var tokenString = ""

    for i in 0..<deviceToken.length {
        tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
    }

    print("tokenString: \(tokenString)")
When trying to do in KMM I run into issues KMM
Copy code
actual typealias PushToken = NSData

fun PushToken.toString(): String {
     // Unsure of what to do here  
}
Has anyone done anything similar?
1
a
We are doing this in Swift successfully from the application didRegisterForRemoteNotificationsWithDeviceToken delegate:
Copy code
deviceToken.map { String(format: "%02x", $0) }.joined()
That gives us a human readable string version of the device token, which we send to servers.