Best practices for calling CBLDatabase compact?

I’d need to keep track of the previous lastSequenceNumber so I can calculate the delta when the app goes into the background correct?

Correct.

we are missing some updates that sometimes never make it to the server.

You could try deferring the compaction until after the push replication goes idle. (You’ll need to start a background session with iOS to do this, so it’ll let you keep running a while after going to the background.)