It's possible to check SMS sending status? e.g.
MFMessageComposeViewController * smsPicker = [[MFMessageComposeViewController alloc] init];
smsPicker.messageComposeDelegate = self;
smsPicker.body = #"Body";
[self presentModalViewController:smsPicker animated:YES];
[smsPicker release];
I don't know why, but the delegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result; executing before sending and works if user cancelled SMS.
And I need to know, if SMS sent or failed (e.g. cell network error or something wrong). Thanks for future help!
You can use the result parameter messageComposeViewController:didFinishWithResult: to check the status of the message. Its type is MessageComposeResult:
enum MessageComposeResult {
MessageComposeResultCancelled,
MessageComposeResultSent,
MessageComposeResultFailed
};
Bear in mind that MessageComposeResultSent may only be interpreted as a successful queueing of the message for later sending. The actual send will occur when the device is able to send.
How can I check if device is able to send?
To test whether a device is capable of sending text messages, use MFMessageComposeViewController's canSendText class method. According to the documentation, you should always call this method before attempting to present the message compose view controller.
However, this will not tell you if the device is able to send the message now (in case you asked with this statement in mind: The actual send will occur when the device is able to send).
Unfortunately it does not account for cell network interruptions at the very least. For example when in airplane mode the delegate receives a MessageComposeResultSent!
I have filed a radar for this. Duplicating it may get the issue resolved sooner.
Related
I use Microsoft.Azure.NotificationHubs in VS2017. when I try to send a notification by SendAppleNativeNotificationAsync method this doesn't return notificationId, this is null. I have the Standard pricing for Notification Hub
enter image description here
Are you using Test Send by any chance? Please note that NotificationId is returned NULL while doing a test send. This is because you can get the result of Send operation in the output of Send* method itself. NotificationOutcome.Results property will have list of registrations this Send* was sent to. (Note that test sends are only meant for troubleshooting purposes and they target a maximum of 10 devices. Read through the above post for more info).
I worked with REST API I did a simple test and it worked correctly Send an APNS Native Notification, azure-notificationhubs here I found everything necessary for my problem
Is there a legal way to get body text and recipients list from MFMessageComposeViewController after SMS was sent(in didFinishWithResult callback delegate)?
I have an application which sends SMS and saves it in history. I'm using MFMessageComposeViewController for sending SMS. This is needed in order to save message correctly to history and perform searches.
I know there is no way to change body and recipients list after controller was shown, i want to get them.
I know there is phone's SMS history - but i need this in history of my application due to specific functionality of application according message body.
There is an official "legal" standard way to do this:
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
NSString *sms = controller.body;
Same with controller.recipients...
I am able to send Message to specific Person selected through XMPPframework IOS. I am receiving messages from others sent to me and I can see using NSLog in following method.
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
I have gone through What I want to know is, if any method available in XMPP to directly decode received chat message ? i.e. like If
- [message getChatMessage];
Or we need to implement on our own ? i.e decoding received XML and get requirement element string.
Please share if any one knows.
Well, you can get, for example, the body of the message by doing this:
NSString *body = [[message elementForName:#"body"] stringValue];
The values for other tags can be found like this. XMPP uses XML to structure its data, so the elementForName: and attributeForName: methods should give you the data you need.
I am using MFMailComposeViewController for sending feedback in my app. It works fine. But the problem here is, the user can edit/delete the "to" address. I want to make it as a non-editable one. May be, the user can add some mail addresses in "to" field.
But he/she should not delete the feedback address (Here, it is "support#xxxx.com").
Here is my code...
MFMailComposeViewController *composeWindow = [[MFMailComposeViewController alloc] init];
composeWindow.mailComposeDelegate = self;
NSString *str = #"Subject of the feedback";
[composeWindow setSubject:[str stringByAppendingString:[[UIDevice currentDevice]systemVersion]]];
NSArray *toRecipients = [NSArray arrayWithObject: #"support#xxxx.com"];
[composeWindow setToRecipients:toRecipients];
[self presentModalViewController:composeWindow animated:YES];
[composeWindow release];
Thanks in Advance
Rajkanth
You can not customize MFMailComposeViewController to avoid editing. Apple forbids this, and the reason is quite simple: it is the user and not you that must decide exactly what to send, to whom etc. The same applies for the UI controller allowing to send SMS (text) messages. And, of course, Apple does not allows sending an email or SMS without explicit interaction with the user. It is the user that must validate and send the email or SMS message. The validation process include the ability to cancel the message or to change any single property at will, including the "to" recipients.
All the other answers are correct. You can not change the interface of the MFMailComposeViewController. But you have other possibilities. ;-)
Three20 SDK includes also an Mail Composer. Try it out. I think it should be that far changeable, that the "to" field is not editable anymore.
I hope my answer is helpful for you.
Sandro Meier
EDIT
Three20 SDK was discontinued a while ago. So you shouldn't use it anymore for new projects. I advise you to use NimbusKit instead. This is also recommended by the Three20 SDK team. Sadly it does not include a MailComposeViewController
From the Apple documentation:
Important: The mail composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is not allowed to make further changes to the email content. The user may still edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields before presenting the interface.
I have a situation where i need to send details entered in the UITextfields to the administrator's mail ID without opening the MFMailComposeViewController.
This is a registration part of the application,so i will ask the users to enter their personal information like name,mail ID,DOB etc.,and i want to send these information as a mail to a hard coded ID which is the administrators mail ID.
I want this mail to be sent when the register button is pressed which is kept at the bottom of the same page.
I used the MFMailComposeViewController,without displaying the Composer view by avoiding the usage of this statement in order to prevent the modal view being popped up when i hit the register button
[self presentModalViewController:picker animated:YES]; and i use the
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error by invoking it using the statement
[self mailComposeController:picker didFinishWithResult:MFMailComposeResultSent error:nil];
where picker is the object of the MFMailComposeViewController
What should i do,to implement the same?
Kindly anybody advise me on how to achieve this.
Thanks a lot to everyone.
Thats not possible with MessageUI.framework. Instead you could set up a web service which sends the mail. Your app would connect to your server and sends the mail from there.