在iOS 6中以编程方式获取通话logging
我正在开发使用iOS 6的iOS应用程序。我需要以编程方式从iOS设备获取通话logging 。 我尽我所能,得到了一个解决scheme,但它只适用于iOS 5以下。是否有可能在上面的iOS 5或iOS 6?
在我的ios5设备中,通话logging的位置是
“/private/var/wireless/Library/CallHistory/call_history.db”
这里是我的代码来检索通话logging
- (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]; } }
希望能帮助到你!
你没有得到通话loggingbcoz在ios 5 call_history.db不在读模式。所以你不读这个call_history.db flie.you只读这个数据库在越狱。
- 在iPhone SDK上等待CLLocationManagerDelegate的didUpdateToLocation方法时,UITableView不会填充
- 如何设置UICollectionViewCell的位置?
- 在外部库协议中添加和使用新方法时出现警告
- NSDate格式化问题与Twitter的JSON API
- 我可以使用类方法作为委托callback吗?
- 我无法把头转过来 – (void)playInputClick;
- 将UITabBarController与UINavigationController结合使用
- 使用另一个UINavigationController推送视图控制器
- 什么时候应该使用UIImageJPEGRepresentation和UIImagePNGRepresentation上传不同的图像格式到服务器?