You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

iOS 11中如何通过CallHistory.framework及私有框架获取通话记录?

Hey Jeff, let's break down your two questions about accessing call history on iOS 11:

Q1: How to access call records using CallHistory.framework in iOS 11?

First off, let's be clear: CallHistory.framework is a private Apple framework, so any app relying on it won't pass App Store review. That said, if you're building for internal use, testing, or non-distribution scenarios, here's how you can work with it:

  • Step 1: Dynamically load the private framework
    The framework is located at /System/Library/PrivateFrameworks/CallHistory.framework. Since it's not part of the public SDK, you need to load it at runtime using dlopen:

    void* frameworkHandle = dlopen("/System/Library/PrivateFrameworks/CallHistory.framework/CallHistory", RTLD_NOW);
    if (!frameworkHandle) {
        NSLog(@"Failed to load framework: %s", dlerror());
        return;
    }
    
  • Step 2: Access the core class and fetch records
    The primary class for retrieving call history is CHManager. You can reference it via objc_getClass and call its private methods. For iOS 11, the method to fetch recent calls is typically recentCallsWithLimit:offset::

    Class CHManagerClass = objc_getClass("CHManager");
    id manager = [[CHManagerClass alloc] init];
    // Fetch the last 100 call records
    NSArray* callRecords = [manager performSelector:NSSelectorFromString(@"recentCallsWithLimit:offset:") withObject:@(100) withObject:@(0)];
    
  • Step 3: Handle privacy permissions
    Even with the framework loaded, you need user consent to access call history. Add the NSCallUsageDescription key to your Info.plist with a clear explanation of why your app needs this data—otherwise, the system will block permission requests.

  • Key Caveats

    • Private APIs are undocumented, so method signatures could break with minor iOS 11 updates.
    • Sandbox restrictions will block access unless your app is signed with appropriate entitlements or runs on a jailbroken device.

Q2: Can I get iOS 11 call records via private frameworks without submitting to the App Store?

Yes, you can—but the approach depends on whether the target device is jailbroken, and there are important risks to consider:

For Jailbroken iOS 11 Devices

  • No sandbox barriers: Jailbreaking removes Apple's sandbox constraints, so your app can freely load private frameworks and access system data without special entitlements.
  • Distribution: You can share the app via Cydia, sideload it directly using tools like scp or file managers like Filza.
  • Risks: Jailbreak compatibility varies by tool and iOS 11 subversion, and jailbroken devices have reduced security.

For Non-Jailbroken iOS 11 Devices

  • Enterprise Signing: You'll need an Apple Enterprise Developer account to sign your app. Enterprise-signed apps can be sideloaded onto devices without App Store review.
  • Entitlements: Add the com.apple.coretelephony.callhistory.read entitlement to your provisioning profile. Note that Apple may revoke your enterprise certificate if they detect misuse of private APIs.
  • User Consent: Users still need to grant permission via the system prompt, triggered by your NSCallUsageDescription entry in Info.plist.

General Risks

  • API Instability: Private frameworks aren't supported by Apple, so even a small iOS 11 update could break your app's call history retrieval.
  • Security & Policy: Accessing private system data exposes your app to vulnerabilities, and Apple actively blocks apps that misuse private APIs—even those distributed outside the App Store.

内容的提问来源于stack exchange,提问作者Jeff

火山引擎 最新活动