Every IMAP message is assigned a UID that is specific to the user, as in two users may receive two different messages, but be assigned the same UID. [aka UID != UUID] If your software is issuing a simple FETCH 1:* (FLAGS)
the server will respond with a sequentially numbered list disregarding the message's UID. Any command in which you want to deal specifically with a message's UID you must be sure that you're issuing it properly, as in FETCH UID 1:* (FLAGS)
.
eg:
a1 fetch 1:* (flags)
* 1 FETCH (FLAGS (\Seen))
* 2 FETCH (FLAGS (\Seen))
* 3 FETCH (FLAGS (\Seen))
* 4 FETCH (FLAGS (\Seen))
* 5 FETCH (FLAGS (\Answered \Seen))
* 6 FETCH (FLAGS (\Seen))
* 7 FETCH (FLAGS (\Seen))
* 8 FETCH (FLAGS (\Seen))
* 9 FETCH (FLAGS (\Seen))
* 10 FETCH (FLAGS (\Seen))
versus:
a8 uid fetch 1:* (flags)
* 1 FETCH (UID 1 FLAGS (\Seen))
* 2 FETCH (UID 2 FLAGS (\Seen))
* 3 FETCH (UID 3 FLAGS (\Seen))
* 4 FETCH (UID 4 FLAGS (\Seen))
* 5 FETCH (UID 5 FLAGS (\Answered \Seen))
* 6 FETCH (UID 6 FLAGS (\Seen))
* 7 FETCH (UID 8 FLAGS (\Seen))
* 8 FETCH (UID 9 FLAGS (\Seen))
* 9 FETCH (UID 10 FLAGS (\Seen))
* 10 FETCH (UID 11 FLAGS (\Seen))
That said, I don't understand why you need to track the UIDs separately to synchronize across multiple devices. So long as each device is gathering its information from the IMAP server they will be in sync by default. You're essentially re-implementing functionality that already exists in any IMAP server.