DCDevice
A representation of a device that provides a unique, authenticated token.
Declaration
class DCDeviceMentioned in
Overview
Use the shared instance of the DCDevice class to generate a token that identifies a device. Call the generateToken(completionHandler:) method to get the token, and then send it to your server:
if DCDevice.current.isSupported { // Always test for availability.
DCDevice.current.generateToken { token, error in
guard error == nil else { /* Handle the error. */ }
// Send the token to your server.
}
}On your server, combine the token with an authentication key that you obtain from Apple, and use the result to request access to two per-device binary digits (bits). After authenticating the device, Apple passes the current values of the bits, along with the date they were last modified, to your server. Your server applies its business logic to this information and communicates the results to your app. For more information about server-side procedures, see Accessing and modifying per-device data.
Apple records the bits for you, and reports the bits back to you, but you’re responsible for keeping track of what the bits mean. You’re also responsible for determining when to reset the bits for a given device; for example, when a user sells the device to someone else.