0 Replies
      Latest reply on Jun 15, 2019 1:18 PM by ManuelMB
      ManuelMB Level 3 Level 3 (175 points)

        In WWDC 2019 session In-App Purchases and Using Server-to-Server Notifications they say that in our server we must have in a database a field for the userId.

         

        I think that a good candidate to use as userId for iOS and tvOS would be identifierForVendor:

         

        UIDevice.current.identifierForVendor?.uuidString

         

        And for macOS the GUID but the info that I found in the Apple documentation uses Objective-C instead of Swift:

         

        https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html#//apple_ref/doc/uid/TP40010573-CH1-SW14

         

        Is there info about who to do it using Swift somewhere or should I use Objective-C?

         

        I also found some code of Swift in github, but I do not now if really get the real Mac UUID and also if this method is allowed by Apple.

         

            func macSerialNumber() -> String {
                let platformExpert: io_service_t = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
        
                guard let serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, kIOPlatformSerialNumberKey as CFString, kCFAllocatorDefault, 0) else { fatalError("Can not get serialNumberAsCFString") }
        
                IOObjectRelease(platformExpert);
        
                return (serialNumberAsCFString.takeUnretainedValue() as? String) ?? ""
            }
        
            func applicationDidFinishLaunching(_ aNotification: Notification) {
                print("Unique Device Identifier: \(macSerialNumber())")
            }