iOS Private API

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.