|
23 | 23 | static NSString *const RNCallKitPerformEndCallAction = @"RNCallKitPerformEndCallAction"; |
24 | 24 | static NSString *const RNCallKitDidActivateAudioSession = @"RNCallKitDidActivateAudioSession"; |
25 | 25 | static NSString *const RNCallKitDidDisplayIncomingCall = @"RNCallKitDidDisplayIncomingCall"; |
| 26 | +static NSString *const RNCallKitDidPerformSetMutedCallAction = @"RNCallKitDidPerformSetMutedCallAction"; |
26 | 27 |
|
27 | 28 | @implementation RNCallKit |
28 | 29 | { |
@@ -65,7 +66,8 @@ - (void)dealloc |
65 | 66 | RNCallKitPerformAnswerCallAction, |
66 | 67 | RNCallKitPerformEndCallAction, |
67 | 68 | RNCallKitDidActivateAudioSession, |
68 | | - RNCallKitDidDisplayIncomingCall |
| 69 | + RNCallKitDidDisplayIncomingCall, |
| 70 | + RNCallKitDidPerformSetMutedCallAction |
69 | 71 | ]; |
70 | 72 | } |
71 | 73 |
|
@@ -185,6 +187,18 @@ - (void)dealloc |
185 | 187 | [self.callKitProvider reportOutgoingCallWithUUID:uuid connectedAtDate:[NSDate date]]; |
186 | 188 | } |
187 | 189 |
|
| 190 | +RCT_EXPORT_METHOD(setMutedCall:(NSString *)uuidString muted:(BOOL)muted) |
| 191 | +{ |
| 192 | +#ifdef DEBUG |
| 193 | + NSLog(@"[RNCallKit][setMutedCall] muted = %i", muted); |
| 194 | +#endif |
| 195 | + NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString]; |
| 196 | + CXSetMutedCallAction *setMutedAction = [[CXSetMutedCallAction alloc] initWithCallUUID:uuid muted:muted]; |
| 197 | + CXTransaction *transaction = [[CXTransaction alloc] init]; |
| 198 | + [transaction addAction:setMutedAction]; |
| 199 | + |
| 200 | + [self requestTransaction:transaction]; |
| 201 | +} |
188 | 202 |
|
189 | 203 | - (void)requestTransaction:(CXTransaction *)transaction |
190 | 204 | { |
@@ -440,4 +454,13 @@ - (void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSessio |
440 | 454 | #endif |
441 | 455 | } |
442 | 456 |
|
| 457 | +-(void)provider:(CXProvider *)provider performSetMutedCallAction:(CXSetMutedCallAction *)action |
| 458 | +{ |
| 459 | +#ifdef DEBUG |
| 460 | + NSLog(@"[RNCallKit][CXProviderDelegate][provider:performSetMutedCallAction]"); |
| 461 | +#endif |
| 462 | + [self sendEventWithName:RNCallKitDidPerformSetMutedCallAction body:@{ @"muted": @(action.muted) }]; |
| 463 | + [action fulfill]; |
| 464 | +} |
| 465 | + |
443 | 466 | @end |
0 commit comments