Sending notification or SMS in response to an event Xcode - ios

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.

Related

How to obtain final STATUS from a text sent to mobile phone

I am sending a text to a mobile number (US phone number) using the Programmable Messaging Quickstart for C# with .NET Core example. The message is sent and received successfully but the STATUS in the response shows "queued".
Is there a sample callback in C# to obtain the final status after the text is sent?
You have 3 options, either of the first two are suggested.
Subscribe to statusCallbacks, which will alert your application of the delivery status of the send message.
Use Event Streams to subscribe to specific message delivery event types (this option provides the ability to select different types of message delivery events).
Less efficient and not very scalable, make a request to the /Messages endpoint to determine the final disposition of the sent message (via its unique message SID).
Best Practices for SMS Message Logging

Ignore events generated from method invocations

I have the following case:
1) A user sends a direct message to my bot (which has been installed with the Slack app).
2) The message generates an event which is sent to a webhook on my server. The message gets processed, and a response is sent to the user (via the chat.postMessage api (https://api.slack.com/methods/chat.postMessage)).
3) Now, another event is generated (with type "message", and subtype "bot_message") and sent to my webhook.
Is it possible when sending a message (with the chat.postMessage method) to make Slack not generate a corresponding event? (Since I'm the one sending the message, it is completely unnecessary for me to receive an event telling me that I have indeed sent a message.)
No, I don't think it is possible. You can not subscribe to specific message sub_types.
I had the same issue when using the message events and I just told my bot to ignore all messages that have a sub_type.

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.

how can i cause a MFMailComposeResultFailed error

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

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.

Resources