return self.reduce("", {$0 + String(format: "%02.2hhx", $1)}) } } @objc public class DeviceTokenManager: NSObject { private static let key:String = "knocker.device.token" static let defaults = UserDefaults.standard public static func store(_ deviceToken: Data) { defaults.set(deviceToken.toHexString(), forKey: key) defaults.synchronize() } public static func retrieve() -> String? { return defaults.object(forKey: key) as? String } public static func clear() { defaults.removeObject(forKey: key) } } 19/51