gpt4 book ai didi

ios - CTTelephonyCenterAddObserver 不通知接收短信

转载 作者:可可西里 更新时间:2023-11-01 03:45:42 24 4
gpt4 key购买 nike

我有一个应用程序,我想在收到短信时使用react;在 iOS 7 之前,这可以通过像这样注册到 CTTelephonyCenter 来实现:

        id center = CTTelephonyCenterGetDefault();
CTTelephonyCenterAddObserver(center,
NULL,
callback,
NULL,
NULL,
CFNotificationSuspensionBehaviorHold);

并在回调中检查 kCTMessageReceivedNotification。这在 iOS 8 中不再起作用,因为我收到的通知类型比 iOS 7 少得多,而且与消息接收无关。我认为这是关于一项新的权利,但还不能确定是否是这样,以及需要什么权利。有人知道如何解决这个问题吗?

最佳答案

您需要在第四个参数中指定通知名称:

id center = CTTelephonyCenterGetDefault();
CTTelephonyCenterAddObserver(center,
NULL,
callback,
CFSTR("kCTMessageReceivedNotification"),
NULL,
CFNotificationSuspensionBehaviorHold);

从 iOS 8 开始,您无法通过 NULL 作为通知名称来接收所有 CoreTelephony 通知。现在您必须准确地告诉它您想要观察哪些通知。

8.3 更新

从 iOS 8.3 开始,至少 kCTMessageReceivedNotification 需要接收授权(可能是所有通知的情况,但不确定)

<key>com.apple.CommCenter.fine-grained</key>
<array>
<string>spi</string>
</array>

关于ios - CTTelephonyCenterAddObserver 不通知接收短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26932913/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com