Subscription to an event of Address Book in iOS - ios

When a new contact is added to the address book, I need to do something to it. At least I need to get some contact identifiers for later use. As you may guess, I would like to my app works in background or maybe starts in the background when a new contact is added.
Is this even possible in iOS? If yes, how?
Thank you.

ABAddressBookRegisterExternalChangeCallback
Registers a callback to receive notifications when the Address Book database is modified.
You can get the updated contact with help of this : Detect what was changed from ABAddressBookRegisterExternalChangeCallback

Related

Block a caller/contact from user's contact list in iOS

Presently I'm developing an iOS app to block unwanted contact/caller from user's contact list.
In this app user will be shown a list of contact from his phone book and user can mark block/unblock a contact/caller,Now if a contact/caller mark as blocked the app should block the call(it might ring once and then be disconnected automatically).
can any one suggest me how it is possible? please.
Reference: https://itunes.apple.com/in/app/call-bliss-silence-calls-text/id575698521?mt=8
Thank you so much.
iPhones/iOS already have a block contact/caller option

How whatsapp get updated contacts from addressbook faster in iOS?

My findings
I am designing a logic to sync contact with my Backend. I gone through some apps that doing same thing in IOS. I will take the example of WhatsApp, I found that When I update any contact in Native Addressbook, it reflect that change into Whatsapp withing a fraction.
My Concern
I just want to know that how it is syncing in a very faster way. Even a new contact gets synced with its Remote server and get displayed on contact, and with the ability to initiate Whatsapp chat if that number is registered one.
Summary of Queries
So, in nutshell my queries are,
How Whatsapp is syncing the contact?
How whatsapp is getting just updated contact list from Native Addressbook (if it's doing so) ?
How whatsapp is just getting just new Contact added in addressbook, is there anything that manages like timestamp or anything else?
I know the following things are there like,
ABAddressBookGetPersonCount
ABAddressBookGetPersonWithRecordID
ABAddressBookCopyArrayOfAllPeople
Using the ABAddressBookGetPersonCount i can know if any new contacts are there but still how i will be able to know its Record ID without iterating each contact using ABAddressBookCopyArrayOfAllPeople
So i am just asking for the way to get just updated list.
The way to do this is by registering an external change callback. This way, your app will be notified of any changes to the address book as soon as they happen.

Delete user from server if they delete app

Is it possible to delete a user from a server if they delete your app from their phone?
I am using UUID to create users so they do not have to register but I do not want users to delete the app then rejoin and have a new uuid while the old one is still in the database.
Are there any alternatives to using UUID to avoid registering. Apparently UDID which would have been ideal has been deprecated for IOS 6 and upwards.
Please help, thanks in advance.
Alternatively,
You can create a service in App that ping server once a day. if any device didnt respond from long time then delete it from database.
You can't know if user deleted your app or not. So the method you mentioned is not possible.
One-way is, if you are using any advertisement in your app, you will get the advertisement identifier. It's unique for a device, so if user installs your app again, you will get the same advertisement identifier and you can identify the user. But I won't recommend this method, as I can sell my phone at anytime and the new owner can use your app. But he will be considered as old user in this scenario.
So my suggestion is keep a login for individual users. There are a lot of pitfalls in this approach also. You can't identify whether the app is deleted or not. Also same user can create multiple usernames and use it from same device.
You can save DeviceId into database associated with your user and then check if that device is already registered, delete old one and set new UUID. You can get DeviceId like following:
[[UIDevice currentDevice] identifierForVendor].UUIDString;
This will be the same for all your apps(on the appstore) but unique for device
I think that you can't catch delete event with your application.
Also, check this link as well:
Can I know when the user delete my app?
instead of catching a delete event what you can do is store the user info in your database, if the same user tries to join again throw a prompt indicating the user is already present and don't allow him to sign up

Getting contacts who own an iDevice

Is there a way through addressbookUi framework to get only the contacts who own an iDevice? The check for example is done in the messages app for iMessage. But is this available for developers? Or is there another way to check for this? Thank you in advance..
You could check, for each address book record, if there is a phone number of type "iPhone" (represented by the constant kABPersonPhoneIPhoneLabel). There's really no way of knowing for sure which of the contacts "owns an iDevice" anyway, but if there is an iPhone number for them in the address book record, then there's a good chance of them using an iPhone. Of course, it's another story altogether how that information got in your address book, and whether it is reliable.
No there isn't... The SMS app would be checking with apples servers to see if the phone number is registered with iMessage or not.
This is not a publicly accessible API.
I guess you could hash then send the users number to your own remote database and then compare contact numbers in another users address book against your database to see if they are users of your app... It's not really what you asked to do but it's the closest solution I could think up

Notifications on remote change

I'm developing an application which holds a list of objects.
The user should be able to favorite some of these objects, which then gets saved for easy access. Simple enough, right.
However, in addition to that, I want it so that the application notifies the user (using a notification, like when you get a new SMS), whenever one of the favorited objects have had something changed (in my application the objects represent a pub, and a change to the pub is when it has a new event scheduled). The change is done on a remote server, using a webpage.
When my app is active I can just poll the server every few minutes and compare the properties of the object, and if I see a change notify the user.
But how will I do to make this work when my app is NOT in the foreground? I want the user to get a notification even if he/she is not currently running my app.
The app does not have any login-functionality, so I can't send out specific push notifications to specific users. So the only thing the server might have access to is perhaps the device ID. I.e. there is no real way for the server to know which favorites a device ID holds.
Is there some smart way to do this? On Android I can just use polling but as iOS doesn't allow code to run in the background in the same way I don't really know how to do.
All help greatly appreciated. Even if it's just a "I don't think that's possible".
Just create a table that associates device ID with favorites. When a favorite changes, send that device ID a push notification
The user is the device ID

Resources