国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Ios攔截手機短信程序

2019-11-14 20:08:35
字體:
來源:轉載
供稿:網友
引用
1.手機要越獄,沒有越獄的話,下面的可以不用看了!  2.IOS 要5.0以上,4.xx的同上  首先,聲明下!由于公司移動開發的項目中,需要根據手機的內容進行邏輯處理,也就是要實現手機短信攔截,由于,本人一直搞的是java,對OC 語言還是比較陌生的,這段辛酸路總算熬出個苗頭!由于,公司中沒有人搞這個,遂只能網爬了,郁悶的發現,網上的代碼幾乎不能運行,在朋友的幫助下,成功的對手機短信進行了攔截!下面貼下研究的心得,由于IT眼沒有OC語言標簽,下面貼的OC語言用C++代替! 
引用
項目首先,導入CoreTelephony.framework,OK 不需要別的包了,僅此而已!  在AppleDelegate.m中寫上如下代碼: 
C++代碼  收藏代碼
  1. //extern id allIncomingMessages;  
  2. //extern int incomingMessageCount;  
  3.   
  4. extern NSString* const kCTSMSMessageReceivedNotification;  
  5. extern NSString* const kCTSMSMessageReplaceReceivedNotification;  
  6. extern NSString* const kCTSIMSupportSIMStatusNotInserted;  
  7. extern NSString* const kCTSIMSupportSIMStatusReady;  
  8.   
  9.   
  10. //typedef struct _CTCall CTCall;  
  11. extern NSString *CTCallCopyAddress(void*, CTCall *);   
  12. void* CTSMSMessageSend(id server,id msg);  
  13. typedef struct __CTSMSMessage CTSMSMessage;  
  14. NSString *CTSMSMessageCopyAddress(void *, CTSMSMessage *);  
  15. NSString *CTSMSMessageCopyText(void *, CTSMSMessage *);  
  16.   
  17. int CTSMSMessageGetRecordIdentifier(void * msg);  
  18. NSString * CTSIMSupportGetSIMStatus();  
  19. NSString * CTSIMSupportCopyMobileSubscriberIdentity();  
  20. id  CTSMSMessageCreate(void* unknow/*always 0*/,NSString* number,NSString* text);  
  21. void * CTSMSMessageCreateReply(void* unknow/*always 0*/,void * forwardTo,NSString* text);  
  22.   
  23. id CTTelephonyCenterGetDefault(void);  
  24. void CTTelephonyCenterAddObserver(id,id,CFNotificationCallback,NSString*,void*,int);  
  25. void CTTelephonyCenterRemoveObserver(id,id,NSString*,void*);  
  26. int CTSMSMessageGetUnreadCount(void);   
引用
回調函數: 
C++代碼  收藏代碼
  1. static void callback(CFNotificationCenterRef center,void *observer,CFStringRef name,const void *object, CFDictionaryRef userInfo){  
  2.       
  3. //    NSLog(@"%@",name);  
  4.      
  5.     NSString *strNotficationName=(NSString*)name;  
  6.       
  7.       
  8.     if ([strNotficationName isEqualToString:@"kCTMessageReceivedNotification"]) {  
  9.         int a=0;      
  10.     }  
  11.       
  12. //    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];  
  13.      @synchronized(nil) {  
  14.         if (!userInfo) return;  
  15.         if ([[(NSDictionary *)userInfo allKeys]  
  16.              containsObject:@"kCTMessageIdKey"]) // SMS Message  
  17.         {  
  18.   
  19.               
  20.             NSDictionary *info = (NSDictionary *)userInfo;  
  21.             CFNumberRef msgID = (CFNumberRef)[info objectForKey:@"kCTMessageTypeKey"];  
  22.             int result;  
  23.             CFNumberGetValue((CFNumberRef)msgID, kCFNumberSInt32Type, &result);   
  24.             Class CTTelephonyCenter=NSClassFromString(@"CTTelephonyCenter");  
  25.               
  26.             Class CTMessageCenter = NSClassFromString(@"CTMessageCenter");  
  27.             id mc = [CTMessageCenter sharedMessageCenter];  
  28.             int count=[mc incomingMessageCount];  
  29.             id mcarr=[mc allIncomingMessages];  
  30.     //        id incMsg =[mc incomingMessageWithId:result];  
  31.     //        if (count==0) {  
  32.     //            return;  
  33.     //        }  
  34.             id incMsg = [[mc allIncomingMessages] objectAtIndex:0];  
  35.               
  36.             int msgType = (int)[incMsg messageType];  
  37.               
  38.             if (msgType == 1) //experimentally detected number  
  39.             {  
  40.                 id phonenumber = [incMsg sender];  
  41.                   
  42.                 NSString *senderNumber = (NSString *)[phonenumber canonicalFormat];  
  43.             id incMsgPart = [[[[incMsg items] objectAtIndex:0] retain] retain];  
  44.             NSData *smsData = [[[incMsgPart data] retain] retain];  
  45. //            NSString *smsText = (NSString*)[[NSString alloc] initWithData:smsData encoding:NSASCIIStringEncoding] ;  
  46.               NSString *smsText =    [NSString stringWithUTF8String:[smsData bytes]];  
  47.   
  48.                 NSLog(@"senderNumber = %@,text =%@",senderNumber,smsText);  
  49.             }  
  50.           
  51.         }  
  52.           
  53.     }  
  54.   
  55. //    [pool release];  
  56.       
  57.       
  58.   
  59. }  
引用
注入監聽: 
C++代碼  收藏代碼
  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  
  2. {  
  3.     self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];  
  4.     // Override point for customization after application launch.  
  5.     self.window.backgroundColor = [UIColor whiteColor];  
  6.     [self.window makeKeyAndVisible];  
  7.     id ct = CTTelephonyCenterGetDefault();   
  8.     CTTelephonyCenterAddObserver(ct, NULL, callback, NULL, NULL, CFNotificationSuspensionBehaviorDrop);  
  9. }  

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 松阳县| 沧州市| 平江县| 乌拉特后旗| 垦利县| 曲靖市| 明光市| 沽源县| 望奎县| 滨海县| 图木舒克市| 于都县| 浏阳市| 巴彦县| 喀喇| 梁山县| 资溪县| 伊春市| 大宁县| 安福县| 陕西省| 区。| 仪征市| 巴马| 永吉县| 石首市| 井研县| 桐梓县| 舞阳县| 兴海县| 双柏县| 焦作市| 彰武县| 左权县| 安阳县| 福泉市| 隆子县| 黔东| 潼南县| 郎溪县| 乐东|