如何检测用户是否收到短信?
How to detect if a user received a text message?
是否可以通过您的应用检测用户是否收到短信。如果这是可能的,需要执行哪些步骤才能实现?
不,你不能。没有 public API 可用于监控消息传递应用程序活动。所以你永远无法检测短信是否已发送或已接收。
AppDelegate 的方法 applicationWillResignActive
应该可以解决问题 (尽管除 SMS 消息外,它还会被调用).
收到的 SMS 消息被调用,引用自 Apple's documentation:
This method is called to let your app know that it is about to move from the active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the app and it begins the transition to the background state. An app in the inactive state continues to run but does not dispatch incoming events to responders.
这是我们历史上用来在收到文本时暂停游戏的东西。我还没有确认它在 iOS12 中有效,但在发布时这绝对有效,Apple 的文档甚至仍然声明此回调的 SMS 消息文本,这让我相信它是有效的。
是否可以通过您的应用检测用户是否收到短信。如果这是可能的,需要执行哪些步骤才能实现?
不,你不能。没有 public API 可用于监控消息传递应用程序活动。所以你永远无法检测短信是否已发送或已接收。
AppDelegate 的方法 applicationWillResignActive
应该可以解决问题 (尽管除 SMS 消息外,它还会被调用).
收到的 SMS 消息被调用,引用自 Apple's documentation:
This method is called to let your app know that it is about to move from the active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the app and it begins the transition to the background state. An app in the inactive state continues to run but does not dispatch incoming events to responders.
这是我们历史上用来在收到文本时暂停游戏的东西。我还没有确认它在 iOS12 中有效,但在发布时这绝对有效,Apple 的文档甚至仍然声明此回调的 SMS 消息文本,这让我相信它是有效的。