How to uniquely identify the device for my app?

Hi,

Overview

  • I have an app that is available on iOS, macOS, visionOS.
  • I should be able to differentiate between device 1 and device 2
  • I only care about my app

Purpose:

  • For core data / swift data history tracking I would like which device wrote the data

Question

  1. How do I get a unique id that will differentiate my app running on device 1 vs device2?
  2. How do I do it for iOS / macOS and visionOS?
  3. Or is my approach wrong?
Answered by kthchew in 897210022

You might just create a random UUID on first launch and store it somewhere on the device, writing it alongside each record. Or you could use identifierForVendor which should be the same across multiple apps by you (subject to the limitations in the docs), if that is important for this purpose.

Accepted Answer

You might just create a random UUID on first launch and store it somewhere on the device, writing it alongside each record. Or you could use identifierForVendor which should be the same across multiple apps by you (subject to the limitations in the docs), if that is important for this purpose.

Thanks a lot @kthchew

How to uniquely identify the device for my app?
 
 
Q