1

In swift, there is a apns method to get token like this.

    // Handle remote notification registration.
    func application(_ application: UIApplication,
                     didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let tokenComponents = deviceToken.map { data in String(format: "%02.2hhx", data) }
        ...
    }

Instead of swift change to obj-c, it seems there is no map method for NSData, how to code the same function like swift?

- (void)application:(UIApplication *)application
    didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
//  let tokenComponents = deviceToken.map { data in String(format: "%02.2hhx", data) }
  const tokenComponents = deviceToken.map?
}
ccd
  • 5,788
  • 10
  • 46
  • 96

0 Answers0