• Stars
    star
    145
  • Rank 245,919 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 12 years ago
  • Updated almost 12 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ABGetMe implementation for iOS using undocumented APIs (safely)

About

Unlike the Mac Address Book API, the iOS Address Book API does not come with the ABGetMe function. ABGetMe circumvents this limitation by trying to read My Info from the Contacts settings.

Contacts Settings

If My Info is not found, then ABGetMe tries to match the configured e-mail account addresses with the records of the address book to find the me record.

If the me record is still not found, then ABGetMe finally tries to extract the device owner's full name from the device name in order to find the me record. This technique was explained by John Feminella in his answer to How does Square know my name in their app's registration process? on Quora.

Requirements

  • ABGetMe requires iOS 4.0 or later.
  • ABGetMe can be compiled either with or without Automatic Reference Counting (ARC).

Usage

  1. Copy ABGetMe.h and ABGetMe.m into your Xcode project

  2. Use the ABGetMe() function and don’t forget to check if the result is not NULL.

     ABAddressBookRef addressBook = ABAddressBookCreate();
     ABRecordRef me = ABGetMe(addressBook);
     if (me) {
     	// do something with "me"
     }	
     CFRelease(addressBook);
    

Limitations

ABGetMe is not legally App Store compliant because it uses undocumented APIs which is proscribed by clause 3.3.1 of the iPhone Developer Program License Agreement. It is technically App Store compliant though as it will pass the App Store validation. Moreover, it should not crash even if the undocumented APIs change in the future.

  • Reading My Info from the Contacts settings uses undocumented APIs.
  • Reading configured e-mail account addresses uses undocumented APIs.
  • Reading the device name is a public API.

You can disable private APIs by setting ABGETME_ENABLE_PRIVATE_APIS to 0 instead of 1 at the top of the ABGetMe.m file. Note that disabling private APIs considerably reduces the chances of finding the me record. The only method left to find the me record when disabling private APIs is the last one (i.e. matching the device name) which only works if the device owner never changed the default device name.

More Repositories

1

XCDYouTubeKit

YouTube video player for iOS, tvOS and macOS
Objective-C
2,901
star
2

iOS-Artwork-Extractor

Extract iOS artwork and emoji symbols into png files, generate glossy buttons png files
Objective-C
2,615
star
3

xcproj

Command line tool for manipulating Xcode project files
Objective-C
317
star
4

XCDFormInputAccessoryView

Input accessory view with previous, next and done buttons
Objective-C
238
star
5

FontReplacer

Easily create nibs with custom fonts
Objective-C
229
star
6

NSUUID

NSUUID implementation for iOS < 6.0 and OS X < 10.8
Objective-C
157
star
7

XCDLumberjackNSLogger

CocoaLumberjack logger which sends logs to NSLogger
Objective-C
96
star
8

MPMoviePlayerController-XCDOverlayView

Overlay view synchronized with playback controls for MPMoviePlayerController
Objective-C
93
star
9

CLITool-InfoPlist

Xcode plugin to process Info.plist file for CLI Tool targets
Objective-C
53
star
10

Stealth-Messenger

Send email, SMS or tweet without any user interaction on iOS
Objective-C
45
star
11

otx

Mach-O disassembler
Objective-C
34
star
12

CLURLConnection

NSURLConnection done right
Objective-C
34
star
13

fulldescription

Recursively print instance variables of an Objective-C object.
Objective-C
30
star
14

SpotColor

Spot Color is a wrapper around the built-in Mac OS X color picker so you can use it as a stand alone app
Objective-C
27
star
15

quietxcode

Silences the "malloc: free_garbage: garbage ptr ..." Xcode warnings
Objective-C
15
star
16

pdfrasterize

Command line tool for converting PDF documents to various bitmap formats
Objective-C
13
star
17

NoLastUpgradeCheck

Xcode 4 plugin that prevents LastUpgradeCheck attribute alteration
Objective-C
13
star
18

otx-bblm

BBEdit/TextWrangler language module for otx disassemblies
C
12
star
19

crippng

QuickLook plugin to read crippled iPhone png files
C
12
star
20

Twexpand

SIMBL plugin for displaying full URLs in your favorite Twitter client
Objective-C
11
star
21

APELite-arm

Implementation of the APE Lite API for iPhone OS (ARM) using MobileSubstrate
C++
9
star
22

DocZoom

Usable Xcode documentation Pinch-to-Zoom
Objective-C
4
star
23

SingleFileAppDependencyContext

Experiments with single-file applications and Microsoft.Extensions.DependencyModel
C#
2
star
24

DbContextValidation

DbContext validation against an actual database
C#
2
star
25

iCalColors

SIMBL Plugin that allows you to customize today and selected day colors
Objective-C
1
star
26

RidGraph

Generate visualizable .NET runtime identifier graphs
C#
1
star
27

KeychainCredentials

Implementation of the System.Net.ICredentials interface using the macOS Keychain for .NET
C#
1
star
28

radars

Sample code for bugs submitted to bugreport.apple.com
Objective-C
1
star