1. 程式人生 > >iOS App中斷處理

iOS App中斷處理

- (void)handleInterruption:(NSNotification *)noti
{
    AVAudioSessionInterruptionType type = [noti.userInfo[AVAudioSessionInterruptionTypeKey] intValue];
    if (AVAudioSessionInterruptionTypeBegan == type) {
        _appIsInterrupt = YES;
        [_livePush pausePush];
        NSLog(@"AVAudioSessionInterruptionTypeBegan
"); }
if (AVAudioSessionInterruptionTypeEnded == type) { _appIsInterrupt = NO; if (!_appIsBackground && !_appIsInActive && !_appIsInterrupt) { [_livePush resumePush]; } NSLog(@"AVAudioSessionInterruptionTypeEnded"); } }