Fixes #376 by porting iOS fix.

https://github.com/couchbase/couchbase-lite-android/issues/376