Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get notified in contact changed event in IOS? [duplicate]

Tags:

ios

swift

I wants to get notified when there is insert/update event to contacts of iPhone.

Is it possible to get notification to my app regarding specific contact changed event happened ?

Just a newbie... for IOS Swift.

I am not expecting full source code. Just wants to know whether its possible or not and also hint.

Thanks in advance.

like image 896
Mayur Kataria Avatar asked Mar 23 '15 11:03

Mayur Kataria


People also ask

How do I get notification history on my iPhone?

Notification Center shows your notifications history, allowing you to scroll back and see what you've missed. There are two ways to see your alerts from the Notification Center: From the Lock Screen, swipe up from the middle of the screen. From any other screen, swipe down from the center of the top of your screen.

How do I see notifications I already clicked on?

Pull down your Notification Shade once and then scroll down to the bottom of your notifications. You should now see a History button (Figure 3). The History button has been added to your Notification Shade. Tap History to access your past 24 hours of notifications (Figure 4).

What is automatic notification grouping?

Android 7+ Default behavior. Automatically groups your notifications after the device has 4 or more visible notifications for your app, even if you don't set a group key. Automatically generates the text for the summary notification for the grouped notifications.

How to change message notifications on iPhone?

Change message notifications on iPhone Manage notifications for messages. Go to Settings > Notifications > Messages. Turn Allow Notifications on or off. Set... Set the alert sound for messages. Go to Settings > Sounds & Haptics (on supported models) or Sounds (other models). Tap... Assign a ...

How do I Turn on/off text message notifications?

1 Go to Settings > Notifications > Messages. 2 Choose options, including the following: - Turn Allow Notifications on or off.- Set the position and locations of message notifications.- Choose the alert sound for message notifications.- Choose when message previews should appear. See More...

How do I change text message alert tones on my iPhone?

See Change iPhone sounds and vibrations. Open Contacts, then select a contact. Tap Edit, then tap Text Tone. Choose an option below Alert Tones. To allow alerts for messages sent by this contact even when Do Not Disturb is on, turn on Emergency Bypass. In the Messages list, touch and hold a conversation.

How do I set up vibration notifications on my iPhone?

See Set up Focus on iPhone and Schedule a notification summary. Go to Settings > Sounds & Haptics (on supported models) or Sounds (other models). Tap Text Tone, then do one of the following: Tap Vibration, then choose an option. Tap a sound below Alert Tones. Tap Tone Store to download an alert sound from the iTunes Store.


2 Answers

From iOS 9 you can register your class to observe CNContactStoreDidChangeNotification

NSNotificationCenter.defaultCenter().addObserver(
    self,
    selector: #selector(addressBookDidChange),
    name: NSNotification.Name.CNContactStoreDidChange,
    object: nil)

And then:

@objc func addressBookDidChange(notification: NSNotification){     
    //Handle event here...
}

as reported in Contacts Framework Reference

After a save is successfully executed, the contact store posts a CNContactStoreDidChangeNotification notification to the default notification center. If you cache any Contacts framework objects you need to refetch those objects, either by their identifiers, or with the predicates that were used to originally fetch them, and then release the cached objects. Note that cached objects are stale, but not invalid.

EDIT:

Note that Address Book and Address Book UI frameworks are now deprecated.

like image 192
andreacipriani Avatar answered Oct 04 '22 23:10

andreacipriani


In iOS it could be done using -

Register the external change call back notifier-

ABAddressBookRef ntificationaddressbook = ABAddressBookCreate();
    ABAddressBookRegisterExternalChangeCallback(ntificationaddressbook, MyAddressBookExternalChangeCallback, self);

Implement the call back -

void MyAddressBookExternalChangeCallback (ABAddressBookRef ntificationaddressbook,CFDictionaryRef info,void *context)
{
    // called when there is any change in AddressBook
}

For more details you can refer this link-

Detect what was changed from ABAddressBookRegisterExternalChangeCallback

like image 28
Sanjay Mohnani Avatar answered Oct 04 '22 21:10

Sanjay Mohnani