views:

50

answers:

1

Hi all,

I am new to iPhone developement.

Here is my question. I would like to do a 'device texting capability' check on my iPhone simulator before I deploy it to my phone. This is the code I wrote in the .m file. This is the function which is called when my SMS button is triggered.

    Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
 if (messageClass != nil)
 {
   NSLog (@" \ntxting\n");
  // We must always check whether the current device is configured for sending messages
  if ([messageClass canSendText] == TRUE)
  {
   NSLog (@"canSendText is not passingg"); //Not entering this loop
   [self displayTextSheet];
  }

The problem is that the if-loop does not enter. I was wondering if the Messageview controller does not pop up in the simulator at all and only for the phone.

Please advice.

Update: I have added a NSLog in the messageClass if loop and that gets printed. so messageClass is not 'nil'

+1  A: 

The simulator cannot send SMSs, thus [messageClass canSendText] returns NO when run there and your if clause is not executed.

Jason Jenkins
@Jason: I tried a NSLog inside the ( messageClass !=nil ) and it worked ... Any other suggestions ?
tomkaith13
See my edited response. The class is present on the simulator, but it returns NO to canSendText as expected since the simulator cannot send SMSs.
Jason Jenkins
@Jason: Thnx :) .. will try on the device.
tomkaith13