[Tutorial] Send SMS with iPhone modem

Discussion in 'iOS Development' started by Cyanidepoison, Feb 12, 2009.

  1. Jeepston

    Jeepston New Member

    Joined:
    May 17, 2009
    Messages:
    45
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    I think I've figured it out:



    PHP:

    void CTSMSMessageSend
    (void *, CTSMSMessage*);
    void *ct CTTelephonyCenterGetDefault();

    CFStringRef address CFStringCreateWithCString(NULL"+XXXXXXXXXXXX"kCFStringEncodingUTF8);
    CFStringRef text CFStringCreateWithCString(NULL"Text of message"kCFStringEncodingUTF8);

    CTSMSMessage *msg_to_send CTSMSMessageCreate(NULLaddresstext);
        
    CTSMSMessageSend(ctmsg_to_send);
    Tested it a couple of times on 2G with 2.2. Seems to work.

    Cyanidepoison, thank you for your help!
    ------------------double post merged------------------
    Hmm.... messages sent this way are not written into standard sms.db and are not shown im MobileSMS App. Seems like I will need to add them there manually....
  2. Cyanidepoison

    Cyanidepoison Active Member

    Joined:
    Jan 18, 2008
    Messages:
    1,076
    Likes Received:
    2
    Good job!

    You've just done your first bit of reverse engineering!

    Please Register or Log in to view images



    Sadly, though, this isn't working as I think you think it is on 3.0.
    It sends one message, but then I can't send anymore until I reboot, again.
    ------------------double post merged------------------
    Code:
        BOOL success = [[CTMessageCenter sharedMessageCenter]  sendSMSWithText:@"a message" serviceCenter:nil toAddress:@"a number"];
    
    Class dump CoreTelephony on 3.x to use that... much simpler solution.
  3. Jeepston

    Jeepston New Member

    Joined:
    May 17, 2009
    Messages:
    45
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    Nice, thanks! Now I am working with 2.2 and later will port it to 3.0. So this will be useful.
  4. BennyLava

    BennyLava New Member

    Joined:
    Jun 5, 2008
    Messages:
    3
    Likes Received:
    0
    I've been sending with
    Code:
    BOOL success = [[CTMessageCenter sharedMessageCenter]  sendSMSWithText:@"a message" serviceCenter:nil toAddress:@"a number"];
    
    But success always returns true. Is there anyone to tell if the message was infact sent?
  5. Cyanidepoison

    Cyanidepoison Active Member

    Joined:
    Jan 18, 2008
    Messages:
    1,076
    Likes Received:
    2
    I have no idea, when I wrote that line of code I thought the bool value that was returned was the success.
  6. zurich

    zurich New Member

    Joined:
    Jul 20, 2010
    Messages:
    2
    Likes Received:
    0
    Does this only work on a jail broken iPhone?

    Using XCode 3.2.3 with a target iPhone device on iOS 4.0 (not jailbroken) I've tried to use this but the open always fails.

    int fd = open("/dev/tty.debug", O_RDWR | 0x20000 | O_NOCTTY);

    if(fd == -1)
    {
    perror("Error: ");
    exit(1);
    }

    Any ideas why?
  7. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    You do need a jailbroken device.
    Apple doesn't allow sandboxed apps to mess with the hardware, especially because they don't even run under root.
    (Even if you somehow manage to run your app as root, which is basically impossible, the sandbox's enforcements are still in effect.)

    What are you trying to do? Maybe this could be accomplished using Core Telephony or some other private framework.
  8. dineshkumarm12

    dineshkumarm12 New Member

    Joined:
    Feb 24, 2010
    Messages:
    3
    Likes Received:
    0
    Device:
    2G iPod touch
    Where I could find the CTSMSMessage header files?

    Where I could find the CTSMSMessage header files?I found out CTMessageCenter header files...I want to try with CTSMSMessage to add in coretelephony framework

Share This Page