Для iOS я использую google-api-objectivec-client-for-restДля Android я использую метод с contentResolver и ContentValues
calendar-provider
Я понимаю, что на стороне iOS используется Rest API, а на стороне iOS — Rest API. другая сторона Android использует контент провайдер.
Чтобы не дублировать события, я использовал идентификатор из Android, который представляет собой длинное значение. При реализации на iOS я обнаружил, что идентификатор представляет собой строку (очень длинную, а не целое число).
На iOS я обнаружил:
Код: Выделить всё
**
* Opaque identifier of the event. When creating new single or recurring
* events, you can specify their IDs. Provided IDs must follow these rules:
* - characters allowed in the ID are those used in base32hex encoding, i.e.
* lowercase letters a-v and digits 0-9, see section 3.1.2 in RFC2938
* - the length of the ID must be between 5 and 1024 characters
* - the ID must be unique per calendar Due to the globally distributed nature
* of the system, we cannot guarantee that ID collisions will be detected at
* event creation time. To minimize the risk of collisions we recommend using
* an established UUID algorithm such as one described in RFC4122.
* If you do not specify an ID, it will be automatically generated by the
* server.
* Note that the icalUID and the id are not identical and only one of them
* should be supplied at event creation time. One difference in their semantics
* is that in recurring events, all occurrences of one event have different ids
* while they all share the same icalUIDs.
*
* identifier property maps to 'id' in JSON (to avoid Objective C's 'id').
*
@property(nonatomic, copy, nullable) NSString *identifier;
Я пытался найти Opaque ID со стороны Android, но не смог найти его в документации. И это, вероятно, сделано специально, потому что ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, googleID) на самом деле занимает большую длину, чем идентификатор.
Я нашел аналогичный ответ здесь и я последовал этому, установив собственный UID на стороне Android для параметра CalendarContract.Events.UID_2445. (так как не генерируется автоматически, даже если я пытаюсь выполнить запрос после вставки)
Код: Выделить всё
UUID.randomUUID().toString()
.replace("-", "")
.lowercase()
Я попытался получить все события и столбцы, чтобы узнать, смогу ли я получить их, выполнив запрос, но на самом деле это не поле.
Например, на стороне Android я установил uID = 62b92a9f626c4a7da7653f7f5c758d04
но на iOS я получаю следующее:
[img]https://i.sstatic .net/T9EcDHJj.png[/img]
Эта разница между API была сделана специально?
Следует ли мне использовать rest API на Android, чтобы получить то же самое? Я не нашел ничего готового.
Как синхронизировать события между Android и iOS, если сгенерированные идентификаторы событий различаются?
Подробнее здесь: https://stackoverflow.com/questions/793 ... nt-id-long
Мобильная версия