Use Objective-c to get iphone imsi serial number _c language

Source: Internet
Author: User

Get the iphone's IMSI serial number

#include <dlfcn.h>
#define PRIVATE_PATH "/system/library/privateframeworks/coretelephony.framework/ Coretelephony "
-void Getimsi () {
#if! Target_iphone_simulator
  void *kit = Dlopen (private_path,rtld_lazy);  
  NSString *imsi = nil;
  int (*ctsimsupportcopymobilesubscriberidentity) = Dlsym (Kit, "ctsimsupportcopymobilesubscriberidentity");
  IMSI = (nsstring*) ctsimsupportcopymobilesubscriberidentity (nil);
  Dlclose (kit);  
  Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "IMSI"
                          message:imsi delegate:self
                     cancelbuttontitle:@ "OK"
                     Otherbuttontitles:nil];
  [Alert show];
  [Alert release];
#endif
}

Get operators through IMSI

NSString *imsi = ctsimsupportcopymobilesubscriberidentity ();
NSString *usermobiletype = [statisticsoperation getcarrier:imsi];
 The Getcarrier method is as follows
+ (NSString *) Getcarrier: (NSString *) IMSI {
  if (imsi = = Nil | | [Imsi isequaltostring:@ "SIM not Inserted"]) {return
    @ "Unknown";
  }
  else {
    if ([[Imsi substringwithrange:nsmakerange (0, 3)] isequaltostring:@ "460"]) {
      Nsinteger MNC = [[IMSI Substringwithrange:nsmakerange (3, 2)] intvalue];
      Switch (MNC) {case: case:
        ' return
          @ ' Mobile ';
          break;
        Case:  
          "Unicom";
          break;
        Case:  
          "Telecom";
          break;
        Case: Return
          @ "Tietong";
          break;
        Default: Break
          ;
  }}} return @ "Unknown";
}

Get cell phone number

+ (nsstring*) getphonenumber
{
     NSString *num = [[Nsuserdefaults standarduserdefaults] stringforkey:@ " Sbformattedphonenumber "];
     NSLog (@ "Phone number:%@", num);
     return num;
}

The above mentioned is the entire content of this article, I hope you can enjoy.

Related Article

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.