CTCallCopyAddress()不适用于iOS9

时间:2016-03-28 18:55:43

标签: ios ios9 core-telephony

我已经获得了以下代码来解压来电,这在iOS 8.1上工作正常,但不适用于iOS 9。

extern CFStringRef CTCallCopyAddress(CFAllocatorRef, CTCall* call);

static void callback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
    NSString *notifyname=(__bridge NSString *)name;
    NSLog(@"Name: %@", notifyname);

    if ([notifyname isEqualToString:@"kCTCallStatusChangeNotification"])//phone call
    {
        NSDictionary *info = (__bridge NSDictionary*)userInfo;
        NSString *state=[[info objectForKey:@"kCTCallStatus"] stringValue];
        CTCall *call = (CTCall *)[info objectForKey:@"kCTCall"];
        CFStringRef stringRef = CTCallCopyAddress(NULL, call);
        NSString *caller = (__bridge NSString *)stringRef;

...
    CTTelephonyCenterAddObserver((__bridge CFNotificationCenterRef)(ct), NULL, callback, NULL, NULL, CFNotificationSuspensionBehaviorHold);

当通过Xcode运行时,我可以看到NSDictionary和CTCall对象都包含与iOS8相同的数据。但不同的是,在调用CTCallCopyAddress()之后使用iOS8,然后stringRef / caller将包含数字作为字符串,但iOS9为零。

是否有人发现CTCallCopyAddress的替代方法或机制是否能让它适用于iOS 9?

0 个答案:

没有答案