1

Here are some steps by following I'm getting different UUID eachtime.

  1. Install app
  2. get UUID
  3. Ask permission for location and push notification (cause I need it in login page)
  4. allowing both permission
  5. get UUID (Here I'm getting different UUID which I got in step 2)
  6. Login to firebase via facebook
  7. Logout firebase and facebook
  8. get UUID (Here I'm getting different UUID which I got in step 2 and 5)
  9. Again login to firebase via facebook
  10. Again logout
  11. get UUID (Here I'm getting different UUID which I got in step 2, 5 and 8)

Here is my code for getting UUID.

let uuid = NSUUID().uuidString.lowercased()

Why I'm getting different UUID each time?

Mrugesh Tank
  • 3,495
  • 2
  • 29
  • 59
  • because that is what UUIDs are there for. *If* you get the same UUID twice you seriously broke something. – luk2302 Sep 13 '18 at 09:15
  • Are you trying to get a device id? – luk2302 Sep 13 '18 at 09:15
  • 4
    It seems like you are mistaking _UUID_ for _UDID_. _UUID_ is just a random identifier, so every time that piece of code is run you're supposed to get a new ID. _UDID_ on the other hand is the unique identifier of the device and hence that's constant. – Dávid Pásztor Sep 13 '18 at 09:16
  • 3
    You are calling `NSUUID.init()` with `NSUUID()`. From the doc: `Initializes a new UUID with RFC 4122 version 4 random bytes.` RANDOM. You are misunderstanding the purpose here. – Larme Sep 13 '18 at 09:30
  • So I need to store somewhere and use that each time I need? – Mrugesh Tank Sep 13 '18 at 09:32
  • You can have a unique token with help of apple API - func generateToken(completionHandler completion: @escaping (Data?, Error?) -> Void). This will uniquely identify the device. – Himanshu Sraswat Sep 13 '18 at 09:44

0 Answers0