0

I'm building an alcohol prevention app and one of the features is to block the user's contacts for a given period of time so that they don't irresponsibly make drunken calls/texts to people.

The current (and very old) version implements it by letting the user select in-app which contacts to block. Then, it directly changes the selected contacts' phone numbers to an invalid one. That way, even if the user goes to the Phone or Messages app, the call or text won't be sent to the contact because the number is invalid.

I very strongly dislike this approach because it screws up with your address book which can be synced across multiple devices. What I have in mind is to:

  • Create a separate ABGroup or ABSource of contacts for my app
  • Copy all the contacts from other groups and sources into my app's group or source
  • Falsify all the contacts' phone numbers in my app's group or source
  • Disable all the other groups or source in the main Contacts app.

My question is: Is this possible? I looked into the ABSource and ABGroup references but can't find properties to disable them, but I'm hoping it's available somewhere in the SDK and that I'm just being blind.

If it's not possible, I'd be happy to hear any ideas for alternative implementations (iCloud backups, write original data into a file and screw up everything then put it back later, etc).

Cœur
  • 37,241
  • 25
  • 195
  • 267
Matthew Quiros
  • 13,385
  • 12
  • 87
  • 132
  • What do you mean disable ABSource? For example I have my Google account with calendar, contacts, notes checked. You want your app to disable the contacts link/source? – Black Frog Apr 07 '15 at 16:26
  • @BlackFrog If you open the Contacts app, you'll see a `Groups` button in the upper left which launches a modal that has a checklist of sources (accounts?) for your contacts. I want to create my own from inside the app, and then programatically uncheck the other sources, but leave my group checked so that the user only has wrong numbers. – Matthew Quiros Apr 07 '15 at 16:28
  • 1
    Ok, I see the Groups you are referring to. You want to disable all groups (All Contacts) which would make the Contacts app display nothing. I don't believe Apple would release a public API to control settings in it's own Contacts app. – Black Frog Apr 07 '15 at 19:21
  • Yeah I figured that. :( And apparently, even if you disable sources from inside the Contacts app, that doesn't disable the groups when the contact chooser is launched from other apps--for example, in the Messages and Phone apps when you press the same `Groups` button on the upper left. – Matthew Quiros Apr 08 '15 at 02:39

0 Answers0