Go Back   iPod touch, iPhone, and iPad forum - Multi-Touch Fans > iPhone OS / iOS Ecosystem > iPhone OS Development

What are you waiting for? Join the hundreds of thousands of other iPod touch and iPhone users in our community. Talk about the latest apps and accessories, or post your question on the forums! All visitors must register before they can post and answer questions and participate in our lively community, so register for free today!
Reply
 
Thread Tools Search this Thread
  #11  
Old 01-09-2010
Multi-Touch Amateur
Join Date: Jan 2010
 
iPhone 3GS (Black) 32GB
3.1.2 jailbroken
Hi everyone,

Since you guy seems to know quite a lot about intercepting and process sms (mms) on the iPhone and I'm stuck, I would like to ask for some help.
I'm trying to build a "Map-application" for tracking pets with GSM/GPS collars and I manage to send the request to the collar with:

Code:
BOOL success = [[CTMessageCenter sharedMessageCenter]  sendSMSWithText:@"POSREQ" serviceCenter:nil toAddress:@"NUMBER"];
I also have the code to extract the position from the sms-text but I haven't managed to get the phonenumber and sms-text from the reply.
In the callback I catch the "kCTMessageReceivedNotification" but I can't extract the parts that I need (phonenumber and textpart).

I also have problems with ""-MSHookMessage", referenced from" when trying to use the HOOK method mentioned earlier, but it's not so important right now.
__________________
  #12  
Old 01-12-2010
Jeepston's Avatar
Multi-Touch Admirer
Join Date: May 2009
 
iPhone 3GS (Black) 16GB
3.1.2 jailbroken
Intercepting kCTMessageReceivedNotification is somewhat harder way (for me) than HOOKing into CKSMSService _receivedMessage:replace:

Anyway, here is the code how to get SMS data from CTMessage:
Objective C Code:
NSDictionary *info = (NSDictionary *)userInfo;
    CFNumberRef msgID = (CFNumberRef)[info objectForKey:@"kCTMessageIdKey"];
    int result;
    CFNumberGetValue((CFNumberRef)msgID, kCFNumberSInt32Type, &result);
   
    Class CTMessageCenter = NSClassFromString(@"CTMessageCenter");
    id mc = [CTMessageCenter sharedMessageCenter];
    id incMsg = [mc incomingMessageWithId: result];
   
    int msgType = (int)[incMsg messageType];
   
    if (msgType == 1) //experimentally detected number
    {
        id phonenumber = [incMsg sender];
       
        NSString *senderNumber = (NSString *)[phonenumber canonicalFormat];
        id incMsgPart = [[incMsg items] objectAtIndex:0];
        NSData *smsData = [incMsgPart data];
        NSString *smsText = [[NSString alloc] initWithData:smsData encoding:NSUTF8StringEncoding];
    }
  #13  
Old 01-13-2010
Multi-Touch Amateur
Join Date: Jan 2010
 
iPhone 3GS (Black) 32GB
3.1.2 jailbroken
Thanks that gave me a little help, but I don't get any information about the SMS.
The "result" from "CFNumberGetValue" is a negative value and after that the "incMsg" is "0x0", and subsequently everything after that fails. Shouldn't the "result" value be positive?

By the way, I'm trying to use Xcode with private frameworks only, no Mobile Substrate or similar.

Thanks again.
Sponsored Links
  #14  
Old 01-14-2010
Jeepston's Avatar
Multi-Touch Admirer
Join Date: May 2009
 
iPhone 3GS (Black) 16GB
3.1.2 jailbroken
this code was tested in command-line utility (hence, no MobileSubstrate - just added an observer for kCTMessageReceivedNotification) and it was working fine...
  #15  
Old 01-14-2010
Multi-Touch Amateur
Join Date: Jan 2010
 
iPhone 3GS (Black) 32GB
3.1.2 jailbroken
Do you mind sharing the util and code? It would be very helpful :-).
  #16  
Old 01-14-2010
Jeepston's Avatar
Multi-Touch Admirer
Join Date: May 2009
 
iPhone 3GS (Black) 16GB
3.1.2 jailbroken
see attachment
Attached Files
File Type: zip smsInfo.zip (1.37 MB, 166 views)
  #17  
Old 01-14-2010
Multi-Touch Amateur
Join Date: Jan 2010
 
iPhone 3G (Black) 8GB
3.1 jailbroken
>>MadCoke
your app must be present in folder Application on your device

try load your app not via xCode
  #18  
Old 01-14-2010
Multi-Touch Amateur
Join Date: Jan 2010
 
iPhone 3GS (Black) 32GB
3.1.2 jailbroken
Thanks for all you help, I got it to work.
Actually I think it has work quite a while now but when using the debugger and breakpoints to check for the info I wanted, the messagedata has already been removed by the regular SMS-application.
So by putting the breakpoint after the message has been processed I got what I wanted.

Thanks again :-)
  #19  
Old 01-14-2010
Multi-Touch Amateur
Join Date: Jan 2010
 
iPhone 3G (Black) 8GB
3.1 jailbroken
>>MadCoke
Did You add HOOk of message for your project via xCode?
I can't remove system notification in XCode
  #20  
Old 01-14-2010
Multi-Touch Amateur
Join Date: Jan 2010
 
iPhone 3GS (Black) 32GB
3.1.2 jailbroken
No, I didn't get the HOOK working, I got "_MSHookMessage", referenced from" error when try to use it. I have to live with the "SMS alert" for the moment, anyway I want to give the user a alert when a new position comes. If I understand the HOOK method you have to use Mobile substrate?
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -7. The time now is 02:41 PM.

Recent blog posts: Recent threads:

Powered by vBulletin®
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 2007 - 2010 Vigorous Media LLC - All Rights Reserved.


no new posts
Page generated in 0.06774 seconds with 10 queries