小弟想获取手机某个时间以来所有的通话记录,比如获取自2009年9月9号以来,跟自己联系过的电话(呼叫或被呼叫)的电话号码和联系次数,不知道这个能不能获取到。
多谢了先!
------解决方案--------------------
查查ios-sdk的api先
------解决方案--------------------
肯定没有,有的话苹果审核也不会让你过的
------解决方案--------------------
我提供一个JB的方法,因为call history是以sqlite存储在/var/wireless/Library/CallHistory/call_history.db
所以只要load这个数据库做sql query即可。
------解决方案--------------------
Link-libsqlite3.dylib
#import <sqlite3.h>
- (void)readCallLogs
{
NSMutableArray* _dataArray = [[NSMutableArray alloc] init];
[_dataArray removeAllObjects];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *callHisoryDatabasePath = @"var/wireless/Library/CallHistory/call_history.db";
BOOL callHistoryFileExist = FALSE;
callHistoryFileExist = [fileManager fileExistsAtPath:callHisoryDatabasePath];
[fileManager release];
if(callHistoryFileExist)
{
if ([fileManager isReadableFileAtPath:callHisoryDatabasePath])
{
sqlite3 *database;
if(sqlite3_open([callHisoryDatabasePath UTF8String], &database) == SQLITE_OK)
{
sqlite3_stmt *compiledStatement;
NSString *sqlStatement = [NSString stringWithString:@"SELECT * FROM call;"];
int errorCode = sqlite3_prepare_v2(database, [sqlStatement UTF8String], -1, &compiledStatement, NULL);
if( errorCode == SQLITE_OK)
{
int count = 1;
while(sqlite3_step(compiledStatement) == SQLITE_ROW)
{
// Read the data from the result row