Difficulty obtaining capability to SMS via MFMessageComposeViewController in the iPhone simulator

北战南征 提交于 2019-12-02 16:31:48

问题


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:


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



来源:https://stackoverflow.com/questions/3619307/difficulty-obtaining-capability-to-sms-via-mfmessagecomposeviewcontroller-in-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!