The iOS API is divided into four types:
Published API (Public API) (or documented API )
There are also two categories: private API : Private API and non-public API : Unpublished API ( or undocumented API) .
Private api is placed in the privateframeworks api api frameworks api
According to Apple, the undisclosed API is not mature enough, and may also change the API, and so on fully formed will become the public API, but currently do not provide commitment to it, Is that the system version may become invalid after the upgrade. The private API is an API that Apple explicitly cannot use . Although there is a difference between the two, it is similar to the specific use method.
Private APIs are subject to audit pass-through but not online, but there are also Google Voice apps that are audited using private APIs, so the details of a specific audit are unclear.
Example one:
Get a native number using a private api--coretelephony
The steps are as follows:
1) Import Coretelephony This private framework
2) Add the Scarlet Letter to the XXX.M section:
#import "Xxx.h"
extern nsstring*ctsettingcopymyphonenumber ();
@implementation
+ (NSString *) mynumber{
return Ctsettingcopymyphonenumber ();
}
@end
3) Call NSLog (@ "mynumber=%@", [Xxxmynumber]) elsewhere, which is the native number
In addition, the unique identification code of the machine and other information can be used [Uidevice Currentdevice] Uniqueidentifier,name and other properties to obtain
Other information:
Callblocking on IPhone4
Using Private API
Coretelephony Framework is needed
extern nsstring* Const kctsmsmessagereceivednotification;
extern nsstring* constkctsmsmessagereplacereceivednotification;
extern nsstring* Const kctsimsupportsimstatusnotinserted;
extern nsstring* Const Kctsimsupportsimstatusready;
typedef struct __CTCALL Ctcall;
extern nsstring *ctcallcopyaddress (void*, Ctcall *);
void* ctsmsmessagesend (ID server,id msg);
typedef struct __CTSMSMESSAGE ctsmsmessage;
NSString *ctsmsmessagecopyaddress (void *, ctsmsmessage *);
NSString *ctsmsmessagecopytext (void *, ctsmsmessage *);
int ctsmsmessagegetrecordidentifier (void * msg);
NSString * Ctsimsupportgetsimstatus ();
NSString * ctsimsupportcopymobilesubscriberidentity ();
ID ctsmsmessagecreate (void* unknow,nsstring* number,nsstring*text);
void * Ctsmsmessagecreatereply (void* unknow,void *forwardto,nsstring* text);
ID cttelephonycentergetdefault (void);
Voidcttelephonycenteraddobserver (Id,id,cfnotificationcallback,nsstring*,void*,int);
void Cttelephonycenterremoveobserver (id,id,nsstring*,void*);
int ctsmsmessagegetunreadcount (void);
static void Callback (Cfnotificationcenterref center, Void*observer, cfstringref name, const void *object, Cfdictionaryrefuserinfo)
{
NSString *notifyname= (NSString *) name;
if ([notifynameisequaltostring:@ "Kctcallstatuschangenotification"])//phonecall
{
Nsdictionary *info = (nsdictionary*) userInfo;
NSString *state=[[info objectforkey:@ "Kctcallstatus"]stringvalue];
if ([State isequaltostring:@ "5"])//disconnect
NSLog (@ "unanswered:%@", state);
}
else if ([notifynameisequaltostring:@ "Kctcallidentificationchangenotification"])
{
Ctcallcenter *center = [[Ctcallcenter alloc] init];
Center.calleventhandler = ^ (Ctcall *call) {
NSLog (@ "call:%@", [call description]);
// };
Nsdictionary *info = (nsdictionary *) UserInfo;
Ctcall *call = (Ctcall *) [info objectforkey:@ "Kctcall"];
NSString *caller = ctcallcopyaddress (NULL, call);
NSLog (@ "Phone number:%@", caller);
Ctcalldisconnect (call);
}
else if ([notifynameisequaltostring:@ "Kctregistrationdatastatuschangednotification"])
{
}
else if ([notifynameisequaltostring:@ "Kctsmsmessagereceivednotification"])
{//api Expired
if ([[(Nsdictionary *) UserInfo AllKeys]
containsobject:@ "Kctsmsmessage"])//SMS Message
{
Ctsmsmessage *message = (Ctsmsmessage *)
[(Nsdictionary *) userInfo objectforkey:@ "Kctsmsmessage"];
NSString *address = ctsmsmessagecopyaddress (NULL, message);
NSString *text = Ctsmsmessagecopytext (NULL, message);
Nsarray *lines = [text componentsseparatedbystring:@ "\ n"];
printf ("%s%d\n", [Address cString], [lines count]);
printf ("%s\n", [text cString]);
Fflush (stdout);
}
}
else if ([notifynameisequaltostring:@ "Kctmessagereceivednotification"])//receivedsms
{
Nsdictionary *info = (nsdictionary *) UserInfo;
Cfnumberref MsgID = (cfnumberref) [infoobjectforkey:@ "Kctmessageidkey"];
int result;
Cfnumbergetvalue ((cfnumberref) MsgID, Kcfnumbersint32type,&result);
}
else if ([notifynameisequaltostring:@ "Kctindicatorssignalstrengthnotification"])//signal
{
}
else if ([notifynameisequaltostring:@ "Kctregistrationstatuschangednotification"])//networkregistration status
{
}
else if ([notifynameisequaltostring:@ "Kctregistrationdatastatuschangednotification"])
{
}
else if ([notifynameisequaltostring:@ "Kctregistrationcellchangednotification"])
{
}
else if ([notifynameisequaltostring:@ "Kctindicatorradiotransmitnotification"])
{
}
int Unread=ctsmsmessagegetunreadcount ();
if (unread>0)
NSLog (@ "Unread sms:%d", unread);
NSLog (@ "name:%@-detail:%@", notifyname,userinfo);
}
static void Signalhandler (int sigraised)
{
printf ("\ninterrupted.\n");
Exit (0);
}
—————–
ID ct = Cttelephonycentergetdefault ();
Cttelephonycenteraddobserver (CT, NULL, callback, NULL, null,cfnotificationsuspensionbehaviorhold);
Handle interrupts
sig_t Oldhandler = Signal (SIGINT, Signalhandler);
if (Oldhandler = = Sig_err)
{
printf ("Could not establish new signal handler");
Exit (1);
}
Run loop lets me catch notifications
printf ("Starting run loop and watching for notification.\n");
Cfrunlooprun ();
iOS Private API