#import AVFoundation/AVFoundation.h
//取得錄音權限
- (BOOL)canRecord
{
__block BOOL bCanRecord = YES;
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending)
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
if ([audioSession respondsToSelector:@selector(requestRecordPermission:)]) {
[audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
if (granted) {
bCanRecord = YES;
} else {
bCanRecord = NO;
}
}];
}
}
return bCanRecord;
}
#pragma mark - Audio Recorder √
/*開始錄音*/
- (void)startToRecord:(id)sender
{
if (![self canRecord]) {
[[[UIAlertView alloc] initWithTitle:nil
message:[NSString stringWithFormat:@"%@需要訪問你的麥克風。\n請起用麥克風-設定/隱私/麥克風", [TIXAAppMonitor sharedMonitor].appName]
delegate:nil
cancelButtonTitle:@"好"
otherButtonTitles:nil] show];
return;
}
}