forked from react-native-webrtc/react-native-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ios: Add helper methods to access RTCAudioSession.audioSessionDidActi…
…vate and deactivate
- Loading branch information
Showing
5 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#import <objc/runtime.h> | ||
|
||
#import <React/RCTBridge.h> | ||
#import <React/RCTBridgeModule.h> | ||
|
||
#import "WebRTCModule.h" | ||
|
||
@implementation WebRTCModule (RTCAudioSession) | ||
|
||
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(audioSessionDidActivate) { | ||
[[RTCAudioSession sharedInstance] audioSessionDidActivate:[AVAudioSession sharedInstance]]; | ||
return nil; | ||
} | ||
|
||
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(audioSessionDidDeactivate) { | ||
[[RTCAudioSession sharedInstance] audioSessionDidDeactivate:[AVAudioSession sharedInstance]]; | ||
return nil; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { NativeModules, Platform } from 'react-native'; | ||
|
||
const { WebRTCModule } = NativeModules; | ||
|
||
export default class RTCAudioSession { | ||
/** | ||
* To be called when CallKit activates the audio session. | ||
*/ | ||
static audioSessionDidActivate() { | ||
// Only valid for iOS | ||
if (Platform.OS === "ios") { | ||
WebRTCModule.audioSessionDidActivate() | ||
} | ||
} | ||
|
||
/** | ||
* To be called when CallKit deactivates the audio session. | ||
*/ | ||
static audioSessionDidDeactivate() { | ||
// Only valid for iOS | ||
if (Platform.OS === "ios") { | ||
WebRTCModule.audioSessionDidDeactivate() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters