Alterplay / APAddressBook

Easy access to iOS address book
MIT License
1.38k stars 193 forks source link

how to get notified on changes in phone book #149

Closed techwizardg closed 7 years ago

techwizardg commented 7 years ago

This is not a bug but do not know where to post.

We are using this library to manage iPhone contacts in our app. WE have a requirement where any change in native phone book our app need to be notified.when the app is in background and changes are done in native phone book and when the app comes to foreground,

This method is not getting called when app is in foreground/background [addressBook startObserveChangesWithCallback:^ { // reload contacts }];

This is not getting called.

Every time a change is done in native phone book we are storing the time and every time we do not want to reload contacts but want to query contacts which created/modified time is greater than stored time

Is that possible

belkevich commented 7 years ago

1) Try example in this repo. It uses startObserveChangesWithCallback: and it should be called when app returns to foreground. Of course, there are no callback if app was terminated in background 2) You can add filter for contacts that have creation/modification date greater then stored one. But what if contact was removed? It's unable to find removed contacts. So, I think it's better to reload all contacts.

techwizardg commented 7 years ago

Contact removed is taken care as i need to worry only if the contact is our app user.That i wld get to know as record id stored in our app will not match and that is an indication of deleted records On Wed, 4 Jan 2017 at 9:05 PM, Alexey Belkevich notifications@github.com wrote:

  1. Try example in this repo. It uses startObserveChangesWithCallback: and it should be called when app returns to foreground. Of course, there are no callback if app was terminated in background
  2. You can add filter for contacts that have creation/modification date greater then stored one. But what if contact was removed? It's unable to find removed contacts. So, I think it's better to reload all contacts.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Alterplay/APAddressBook/issues/149#issuecomment-270400083, or mute the thread https://github.com/notifications/unsubscribe-auth/AM14ijNwZmfc2xN1JCcljQNWIDrlIyVRks5rO7wygaJpZM4LalY0 .

belkevich commented 7 years ago

Ok, then you should check Filter contacts in readme. And don't forget to include APContactFieldRecordDate to fieldMask property.

techwizardg commented 7 years ago

Thx On Wed, 4 Jan 2017 at 9:20 PM, Alexey Belkevich notifications@github.com wrote:

Ok, then you should check Filter contacts in readme https://github.com/Alterplay/APAddressBook/blob/master/README.md. And don't forget to include APContactFieldRecordDate to fieldMask property.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Alterplay/APAddressBook/issues/149#issuecomment-270404509, or mute the thread https://github.com/notifications/unsubscribe-auth/AM14il2Ol5ImFJwx6dhoDA79mwyX4WuPks5rO7_ggaJpZM4LalY0 .