开发者

Difficulty obtaining capability to SMS via MFMessageComposeViewController in the iPhone simulator

开发者 https://www.devze.com 2023-01-14 22:53 出处:网络
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 .

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. Thi开发者_运维百科s 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'


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

0

精彩评论

暂无评论...
验证码 换一张
取 消