how can i cause a MFMailComposeResultFailed error - ios

I want to test a certain behaviour I made for when email sending failed,
but I can't get MFMailComposeResultFailed error. even when there is no internet connection, it still "sends" the email. how can this be done?

This is not possible, hence this kind of "errors" will not be delivered by the delegate. An this make sense, because "Mail" takes care of sending or queuing the Mails.
From the docs (MFMailComposeViewController)
Using this interface does not guarantee immediate delivery of the
corresponding email message. The user may cancel the creation of the
message, and if the user does choose to send the message, the message
is only queued in the Mail application outbox. This allows you to
generate emails even in situations where the user does not have
network access, such as in airplane mode. This interface does not
provide a way for you to verify whether emails were actually sent.
You could check the internet connection before displaying the MFMailComposeViewController. This is technical possible but not recommended. Mail will automatically send the mail if the device is connected to the internet again.
But you have to check if the device is configured to send a mail:
if ([MFMailComposeViewController canSendMail]){
//show MFMailComposeViewController
}else{
//show AlertView
}
Before using this class, you must always check to see if the current
device is configured to send email at all using the canSendMail
method. If the user’s device is not set up for the delivery of email,
you can notify the user or simply disable the email dispatch features
in your application. You should not attempt to use this interface if
the canSendMail method returns NO.
https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/#//apple_ref/c/tdef/MFMailComposeResult

Related

Remove a cell number from the Twilio unsubscribe list

I have a very simple alert mechanism to alert drivers "in-the-field" when a new pickup has been assigned to them. I have had an instance twice where a driver has responded with a STOP and became un-subscribed. Once discovered we acquired the proper opt-in documentation from them. Is there any way to re-subscribe a user that opted out and changed their mind on receiving the messaging. i.e. they issued the STOP to the incorrect SMS. And have deleted the original message to START. Or do I need to code something for them to opt back in
My SendGrid provides a method to remove suppression from email but am not finding anything like that here in Twilio.
They need to send a START to the number they previously opted out of, this is currently a requirement. You will also get an error when trying to send messages to them, to alert you they opted out.
Error 21610 - Attempt to send to unsubscribed recipient

How to intercept "Messages" sent from CallKit incoming call screen?

I'm using iOS 10's CallKit to receive incoming calls. The calls in my app do not come from "phone numbers" or "email addresses", but from an internal identifier in my protocol. I thus report incoming calls with the CXHandleType of CXHandleTypeGeneric (and not CXHandleTypePhoneNumber or CXHandleTypeEmailAddress), using a custom string as the "value" of the handle.
When I report the incoming call, and the phone is not locked, the user sees an incoming call screen, with the buttons "Remind Me", "Message", "Decline", and "Accept". If the user presses the "Message" button, and selects one of the message strings on the following menu, it tries to send that string as a text message through the Messages app, with the destination being the custom string I used as the "value" of the handle of the call, as though it were a phone number or email address, even though it isn't. This usually causes the message to fail to send due to an invalid destination, but, depending on the string, it might actually send to a valid destination the user did not want to send to; both outcomes are bad.
I am looking to see if there is a way to have the message not sent through the Messages app (which is always incorrect in my case), but instead be passed into my app so that I can send the message to the caller correctly through my internal protocol.
Update: the "Remind Me" and "Message" buttons no longer appear on iOS 10.1
"Message" button has appeared if support SiriKit in iOS 12.
(add INSendMessageIntent to intent's info.plist)
How to intercept:
Run the Intent Extension
Deal with handler(for intent:)
iOS 10.1 Beta 1 has changed this behavior to no longer show the 'Remind Me' or 'Message' buttons for CallKit VoIP apps, so I encourage you to re-test your app using that Beta OS.
If you would like the ability for incoming calls from your app to continue showing the 'Message' button but for your app receive the message request instead of the system's native Messages app, please file a bug with Apple to request this capability.

Sending notification or SMS in response to an event Xcode

In Xcode I want to make an app that when a certain condition is met, it will send an SMS to a predefined contact.
I am aware this is not directly possible, but what are the alternatives to make this happen?
It should send without confirmation to a pre-defined contact you have selected and have a pre-defined message
very simple: when event happen , your handler (IBAction method) sent a message to your server (e.g. web service) to send this pre-defined message.

How to send message with a single tap

I want to send message to multiple people with single tap i..e, without opening the MFMessageViewController .
I'll Configure the senders list and message to be send with NSUserDefaults.
Can we able to send without viewing the MFMessageViewController.
No, this is not possible with the Public SDK.
The user will always have to send the messages them selfs. This is probably done to make sure that you do not send 100 of messages to paid services.

email sent status from rails or actionmailer

I am developing a test application and running the whole thing on my work pc. I am using my corporate mail server to send mails. It works fine normally. I was wondering how to handle any conditions like if the mail server is not reachable from my pc.
As far as i have read about it, the rails application just sends the mail and that's it. There is no way to know if the mail reached the recipient, if the recipient mail id was correct etc.
Any thoughts on how to handle this scenario?
Thanks and Regards,
Anjali
I believe you're mixing together two problems here, those are quite unrelated really.
First problem - making sure that the email was accepted by the corporate mail server (that is mail relay in this case). To solve this you can either build a local queue of messages (store them in the database, queue server, whatever) - and send them with a separate worker process, that will pull each message from a queue, try to deliver it and delete it only if it was accepted by the mail relay.
Or, if you don't need low-level manual control of the process, you can set up a simple local mail server on your machine and instead if sending emails directly to your corporate mail relay, just give them to your local mail server. It will then make sure that the emails were delivered to the corporate properly.
But in both cases you won't get any info about where the message was delivered to the final recipient - like whether the email address was valid, user's mailbox was not full, etc.
Second problem - track mail delivery errors. To properly and completely solve this problem you need to catch all mail bounced back to you from the remote servers and analyze it, as many errors are unknown at the moment when the email is send - but they come back later in the form of mail bounces. If you catch and track these bounces you'll be able to catch errors likefull mailboxes, invalid emails, just temporarily delivery failures, etc.
It's the way it is done in mail lists management software - for example, phpList operates in exactly the same way.
I thought about this problem. My thought was to store the message into a separate model called "mailqueue" and then run a ruby script that will pull and delete a message from that mailqueue only if the corporate mail server is available (which I already have the code to do that, I believe). Of course, if there is a better way, I would welcome it as well.

Resources