2012-11-01 27 views
1

我正在開發使用的是iOS 6,我需要從iOS設備獲得通話記錄編程的的iOS應用。我盡了最大的努力,得到了一個解決方案,但它只能在iOS 5下運行。 是否可以在iOS 5或iOS 6上運行?編程獲取通話記錄的iOS 6

+6

你介意分享你當前的解決方案嗎? – Codo

+0

OP說他試過[this。](http://iosstuff.wordpress.com/2011/08/19/accessing-iphone-call-history/) – 2012-11-02 10:39:40

+0

瀏覽http://iosstuff.wordpress.com/2011/08/19/accessible-iphone-call-history/ 我在iOS 4中獲得通話記錄但是它不適用於iOS 5和iOS 5以上,請幫助我。 –

回答

0

你沒有在ios 5中獲得通話記錄bcoz call_history.db沒有在讀取mode.so你沒有看到這個call_history.db flie.you只能在越獄中閱讀這個數據庫。

+0

確定同意在ios 5 call_history.db但call_history.db在ios5或ios6中的位置是什麼 – Ajay

1
在我的iOS5設備

,通話記錄位置

「/private/var/wireless/Library/CallHistory/call_history.db」

,這裏是我的代碼來檢索調用日誌

- (void)getCallHistory 
{ 
    self.callHistories = [NSMutableArray array]; 

FMDatabase *db = [FMDatabase databaseWithPath:@"/private/var/wireless/Library/CallHistory/call_history.db"]; 

    NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]; 

if([db open]) { 
    FMResultSet *rs = [db executeQuery:@"select address, date, flags, duration from call order by date"]; 
    while ([rs next]) { 
     int dateInt = [rs intForColumn:@"date"]; 
     NSDate *date = [NSDate dateWithTimeIntervalSince1970:dateInt]; 
     NSDateFormatter *df = [[NSDateFormatter alloc] init]; 
     [df setDateFormat:@"YYYY-MM-dd HH:mm"]; 
     NSString *dateString = [df stringFromDate:date]; 

     int flagsInt = [rs intForColumn:@"flags"]; 
     NSString *flags = @"?"; 
     switch (flagsInt) { 
      case 4: flags = @"<-"; break; 
      case 5: flags = @"->"; break; 
      default: break; 
     } 

     int durationInt = [rs intForColumn:@"duration"]; 
     NSString *duration = [NSString stringWithFormat:@"%d:%02d", durationInt/60, durationInt % 60]; 

     NSString *logLine = [NSString stringWithFormat:@"%@ %@ %@ (%@)", dateString, flags, [rs stringForColumn:@"address"], duration]; 
     [callHistories addObject:logLine]; 
    } 
    [rs close]; 

    rs = [db executeQuery:@"select bytes_rcvd, bytes_sent from data where pdp_ip = 0"]; 
    while ([rs next]) { 
     double bytes_sent = [rs doubleForColumn:@"bytes_sent"]; 
     double bytes_rcvd = [rs doubleForColumn:@"bytes_rcvd"]; 

     self.prettyBytesSent = [[NSNumber numberWithDouble:bytes_sent] prettyBytes]; 
     self.prettyBytesReceived = [[NSNumber numberWithDouble:bytes_rcvd] prettyBytes]; 
    } 

    [rs close]; 

    [db close]; 
    } 

} 

希望它有幫助!

+0

這適用於所有沒有越獄的iPhone? –