Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS DeviceCheck API - GenerateToken gives error Code 0

I'm trying to implement the new iOS 11 DeviceCheck API (https://developer.apple.com/documentation/devicecheck), but token generation always fails. I've tried on simulator and iPhone SE, with wifi and mobile data. Apple ID in settings is my normal, non-sandbox account.

This is an existing app for an organization - from the docs it sounds like the only configuration requirement is to make sure App ID is set up in the apple developer portal.

Anyone else having this issue?

The exact error message is:

The operation couldn’t be completed. (com.apple.devicecheck.error error 0.)

This is the code I'm using, nothing fancy.

if #available(iOS 11.0, *) {
        let device = DCDevice.current
        if (device.isSupported) {
            device.generateToken(completionHandler: { (data, error) in
                if let token = data{
                    print("token: \(token)")
                }else if let error = error{
                    print("error: \(error.localizedDescription)")
                }
            })
        } else {
            print("devicecheck not supported")
        }
    }
like image 753
Miles Ressler Avatar asked Apr 28 '26 06:04

Miles Ressler


1 Answers

In my case, this error was caused by my iPhone's time being horribly out of sync. I manually changed the device's time to be the actual, current time (Settings → General → Date & Time). After that, the error went away and I was able to generate tokens.

like image 84
abertsch Avatar answered Apr 29 '26 20:04

abertsch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!