samedi 9 août 2014

objective c - difficultés à obtenir des capacités de SMS par l'intermédiaire de MFMessageComposeViewController dans le simulateur iPhone - Stack Overflow


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'




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



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'



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


0 commentaires:

Enregistrer un commentaire