1

Can the DeviceCheck API generate a token when the device is offline?

if DCDevice.curDevice.isSupported {
    DCDevice.current.generateToken(completionHandler: { (data, error) in
        if let tokenData = data {
            print("Received token \(tokenData)")
        }
        else {
            print("Hit error: \(error!.localizedDescription)")
        }
    })
}
SPatel
  • 4,768
  • 4
  • 32
  • 51
  • 1
    You can get device token in offline mode too. Device tokens can change after updating the operating system, and always change when a device's data and settings are erased. – Keshu R. Dec 26 '19 at 11:05

2 Answers2

1

Device token can be received in offline mode too.

Device tokens can change after updating the operating system, and always change when a device's data and settings are erased

Keshu R.
  • 5,045
  • 1
  • 18
  • 38
0

The key can be generated offline by making use of generatekey API. However, while calling attestkey API to get the attestationObject, it will make a call to Apple's servers hence attestation will fail if tried in offline mode.

Some side notes to ensure the quality design of this solution -

  1. While making attestkey API call, it can take considerable time (even upto 4 seconds at times).
  2. Apple wants these calls to be made only when really needed and in a sensible way. In the documentation, it is mentioned HTTP error 429 will be thrown for too many requests. There is no information about a maximum number of requests per min/hour, unfortunately.
grow4gaurav
  • 3,145
  • 1
  • 11
  • 12