-->

How to intercept “Messages” sent from CallKit inco

2019-02-17 17:34发布

问题:

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

回答1:

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.