Bug 43923 - Notification for CNContactStore change never fires
Summary: Notification for CNContactStore change never fires
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.6 (iOS 9.3)
Hardware: PC Windows
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-08-31 22:36 UTC by russ
Modified: 2016-09-02 17:22 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test Case (10.30 KB, application/zip)
2016-09-02 17:17 UTC, Alex Soto [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description russ 2016-08-31 22:36:41 UTC
When observing CNContactStore.NotificationDidChange, we are unable to get it to ever actually fire when making external changes to the contact list.  Tried on both 9.3 Simulator and a 9.3 device.

Simple example:
NSNotificationCenter.DefaultCenter.AddObserver(
	CNContactStore.NotificationDidChange, (obj) =>
	{
		log.Write("Success");
	});

Then background, go to your Contacts, add a new one or modify one, then foreground the app again.  The action never fires.

The ABAddressBook version works just fine, but that's now deprecated and we're reluctant to use it.
Comment 1 Alex Soto [MSFT] 2016-09-02 17:17:20 UTC
Created attachment 17319 [details]
Test Case
Comment 2 Alex Soto [MSFT] 2016-09-02 17:22:36 UTC
Hello, I have created a small sample demoing what you are trying to achieve and it works for me. Please let me know if this solves your issue.

You can use the strongly typed notification CNContactStore.Notifications.ObserveNotificationDidChange instead.

In order to use the Contacts and Contacts UI api you need to ask user permission for it and also the reason for it in your info.plist under the NSContactsUsageDescription key.

Feel free to reopen the bug if this does not solve your issue.

Cheers!