简体   繁体   English

如何截获从CallKit来电屏幕发送的“消息”?

[英]How to intercept “Messages” sent from CallKit incoming call screen?

I'm using iOS 10's CallKit to receive incoming calls. 我正在使用iOS 10的CallKit接收来电。 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. 因此,我将CXHandleTypeCXHandleTypeGeneric (而不是CXHandleTypePhoneNumberCXHandleTypeEmailAddress )报告为传入呼叫,并使用自定义字符串作为句柄的“值”。

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. 我正在查看是否有一种方法可以使消息不通过Messages应用程序发送(在我的情况下总是不正确),而是传递到我的应用程序中,以便我可以通过我的应用程序正确地将消息发送给呼叫者内部协议。


Update: the "Remind Me" and "Message" buttons no longer appear on iOS 10.1 更新: “提醒我”和“消息”按钮不再出现在iOS 10.1上

"Message" button has appeared if support SiriKit in iOS 12. (add INSendMessageIntent to intent's info.plist) 如果在iOS 12中支持SiriKit,则会出现“消息”按钮。(将INSendMessageIntent添加到intent的info.plist中)

How to intercept: 如何拦截:

  1. Run the Intent Extension 运行意图扩展
  2. Deal with handler(for intent:) 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. iOS 10.1 Beta 1更改了此行为,不再显示CallKit VoIP应用程序的“提醒我”或“消息”按钮,因此,我建议您使用该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. 如果您希望应用程序的来电功能继续显示“消息”按钮,但又希望应用程序接收消息请求而不是系统的本机“消息”应用程序,请向Apple提交错误以请求此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM