Codying style: naming, formatting, comments
This commit is contained in:
parent
e5309a6482
commit
5e79bbecef
|
@ -79,11 +79,11 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
C6F99C3A204DE6BE0001F710 /* AppDelegate.swift */,
|
||||
C6F99C3C204DE6BE0001F710 /* ViewController.swift */,
|
||||
C6F99C3E204DE6BE0001F710 /* Main.storyboard */,
|
||||
C6F99C41204DE6BE0001F710 /* Assets.xcassets */,
|
||||
C6F99C43204DE6BE0001F710 /* LaunchScreen.storyboard */,
|
||||
C6F99C46204DE6BE0001F710 /* Info.plist */,
|
||||
C6F99C43204DE6BE0001F710 /* LaunchScreen.storyboard */,
|
||||
C6F99C3E204DE6BE0001F710 /* Main.storyboard */,
|
||||
C6F99C3C204DE6BE0001F710 /* ViewController.swift */,
|
||||
);
|
||||
path = src;
|
||||
sourceTree = "<group>";
|
||||
|
|
|
@ -38,9 +38,9 @@
|
|||
B386B85D20981A75000DEF7A /* Invite.m in Sources */ = {isa = PBXBuildFile; fileRef = B386B85620981A75000DEF7A /* Invite.m */; };
|
||||
C6245F5D2053091D0040BE68 /* image-resize@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6245F5B2053091D0040BE68 /* image-resize@2x.png */; };
|
||||
C6245F5E2053091D0040BE68 /* image-resize@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6245F5C2053091D0040BE68 /* image-resize@3x.png */; };
|
||||
C69EFA0C209A0F660027712B /* JMCallKitNotifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA09209A0F650027712B /* JMCallKitNotifier.swift */; };
|
||||
C69EFA0C209A0F660027712B /* JMCallKitEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA09209A0F650027712B /* JMCallKitEmitter.swift */; };
|
||||
C69EFA0D209A0F660027712B /* JMCallKitProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA0A209A0F660027712B /* JMCallKitProxy.swift */; };
|
||||
C69EFA0E209A0F660027712B /* JMCallKitEventListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA0B209A0F660027712B /* JMCallKitEventListener.swift */; };
|
||||
C69EFA0E209A0F660027712B /* JMCallKitListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA0B209A0F660027712B /* JMCallKitListener.swift */; };
|
||||
C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A3425E204EF76800E062DD /* DragGestureController.swift */; };
|
||||
C6CC49AF207412CF000DFA42 /* PiPViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */; };
|
||||
C6F99C15204DB63E0001F710 /* JitsiMeetView+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */; };
|
||||
|
@ -86,9 +86,9 @@
|
|||
B386B85620981A75000DEF7A /* Invite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Invite.m; sourceTree = "<group>"; };
|
||||
C6245F5B2053091D0040BE68 /* image-resize@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "image-resize@2x.png"; path = "src/picture-in-picture/image-resize@2x.png"; sourceTree = "<group>"; };
|
||||
C6245F5C2053091D0040BE68 /* image-resize@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "image-resize@3x.png"; path = "src/picture-in-picture/image-resize@3x.png"; sourceTree = "<group>"; };
|
||||
C69EFA09209A0F650027712B /* JMCallKitNotifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitNotifier.swift; sourceTree = "<group>"; };
|
||||
C69EFA09209A0F650027712B /* JMCallKitEmitter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitEmitter.swift; sourceTree = "<group>"; };
|
||||
C69EFA0A209A0F660027712B /* JMCallKitProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitProxy.swift; sourceTree = "<group>"; };
|
||||
C69EFA0B209A0F660027712B /* JMCallKitEventListener.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitEventListener.swift; sourceTree = "<group>"; };
|
||||
C69EFA0B209A0F660027712B /* JMCallKitListener.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitListener.swift; sourceTree = "<group>"; };
|
||||
C6A3425E204EF76800E062DD /* DragGestureController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DragGestureController.swift; sourceTree = "<group>"; };
|
||||
C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiPViewCoordinator.swift; sourceTree = "<group>"; };
|
||||
C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JitsiMeetView+Private.h"; sourceTree = "<group>"; };
|
||||
|
@ -112,12 +112,12 @@
|
|||
0BCA49681EC4BBE500B793EE /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
75635B0820751D6D00F29C9F /* joined.wav */,
|
||||
75635B0920751D6D00F29C9F /* left.wav */,
|
||||
0BC4B8681F8C01E100CE8B21 /* CallKitIcon.png */,
|
||||
C6245F5B2053091D0040BE68 /* image-resize@2x.png */,
|
||||
C6245F5C2053091D0040BE68 /* image-resize@3x.png */,
|
||||
0BCA496B1EC4BBF900B793EE /* jitsi.ttf */,
|
||||
75635B0820751D6D00F29C9F /* joined.wav */,
|
||||
75635B0920751D6D00F29C9F /* left.wav */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
|
@ -144,25 +144,24 @@
|
|||
0BD906E71EC0C00300C8C18E /* src */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C69EFA02209A0EFD0027712B /* callkit */,
|
||||
B386B84F20981A11000DEF7A /* invite */,
|
||||
C6A3426B204F127900E062DD /* picture-in-picture */,
|
||||
0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
|
||||
0BB9AD7C1F60356D001C08DB /* AppInfo.m */,
|
||||
0BB9AD7A1F5EC8F4001C08DB /* CallKit.m */,
|
||||
0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
|
||||
C69EFA02209A0EFD0027712B /* callkit */,
|
||||
0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */,
|
||||
0BD906E91EC0C00300C8C18E /* Info.plist */,
|
||||
0B7C2CFC200F51D60060D076 /* LaunchOptions.m */,
|
||||
B386B84F20981A11000DEF7A /* invite */,
|
||||
0BD906E81EC0C00300C8C18E /* JitsiMeet.h */,
|
||||
0B412F161EDEC65D00B1A0A6 /* JitsiMeetView.h */,
|
||||
0B412F171EDEC65D00B1A0A6 /* JitsiMeetView.m */,
|
||||
C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */,
|
||||
0B412F1B1EDEC80100B1A0A6 /* JitsiMeetViewDelegate.h */,
|
||||
0B7C2CFC200F51D60060D076 /* LaunchOptions.m */,
|
||||
0B44A0181F902126009D1D64 /* MPVolumeViewManager.m */,
|
||||
0B93EF7C1EC9DDCD0030D24D /* RCTBridgeWrapper.h */,
|
||||
0B93EF7D1EC9DDCD0030D24D /* RCTBridgeWrapper.m */,
|
||||
C6A3426B204F127900E062DD /* picture-in-picture */,
|
||||
0BCA495D1EC4B6C600B793EE /* POSIX.m */,
|
||||
0BCA495E1EC4B6C600B793EE /* Proximity.m */,
|
||||
0B93EF7C1EC9DDCD0030D24D /* RCTBridgeWrapper.h */,
|
||||
0B93EF7D1EC9DDCD0030D24D /* RCTBridgeWrapper.m */,
|
||||
);
|
||||
path = src;
|
||||
sourceTree = "<group>";
|
||||
|
@ -170,11 +169,11 @@
|
|||
9C3C6FA2341729836589B856 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0BB9AD781F5EC6D7001C08DB /* Intents.framework */,
|
||||
0BB9AD761F5EC6CE001C08DB /* CallKit.framework */,
|
||||
0B93EF7A1EC608550030D24D /* CoreText.framework */,
|
||||
0BCA49631EC4B76D00B793EE /* WebRTC.framework */,
|
||||
0BB9AD781F5EC6D7001C08DB /* Intents.framework */,
|
||||
03F2ADC957FF109849B7FCA1 /* libPods-JitsiMeet.a */,
|
||||
0BCA49631EC4B76D00B793EE /* WebRTC.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
|
@ -208,8 +207,9 @@
|
|||
C69EFA02209A0EFD0027712B /* callkit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C69EFA0B209A0F660027712B /* JMCallKitEventListener.swift */,
|
||||
C69EFA09209A0F650027712B /* JMCallKitNotifier.swift */,
|
||||
0BB9AD7A1F5EC8F4001C08DB /* CallKit.m */,
|
||||
C69EFA09209A0F650027712B /* JMCallKitEmitter.swift */,
|
||||
C69EFA0B209A0F660027712B /* JMCallKitListener.swift */,
|
||||
C69EFA0A209A0F660027712B /* JMCallKitProxy.swift */,
|
||||
);
|
||||
path = callkit;
|
||||
|
@ -407,10 +407,10 @@
|
|||
0BCA495F1EC4B6C600B793EE /* AudioMode.m in Sources */,
|
||||
0B44A0191F902126009D1D64 /* MPVolumeViewManager.m in Sources */,
|
||||
0BCA49611EC4B6C600B793EE /* Proximity.m in Sources */,
|
||||
C69EFA0C209A0F660027712B /* JMCallKitNotifier.swift in Sources */,
|
||||
C69EFA0C209A0F660027712B /* JMCallKitEmitter.swift in Sources */,
|
||||
C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */,
|
||||
C69EFA0D209A0F660027712B /* JMCallKitProxy.swift in Sources */,
|
||||
C69EFA0E209A0F660027712B /* JMCallKitEventListener.swift in Sources */,
|
||||
C69EFA0E209A0F660027712B /* JMCallKitListener.swift in Sources */,
|
||||
0B412F191EDEC65D00B1A0A6 /* JitsiMeetView.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -39,7 +39,7 @@ static NSString * const RNCallKitPerformSetMutedCallAction
|
|||
static NSString * const RNCallKitProviderDidReset
|
||||
= @"providerDidReset";
|
||||
|
||||
@interface RNCallKit : RCTEventEmitter <JMCallKitEventListener>
|
||||
@interface RNCallKit : RCTEventEmitter <JMCallKitListener>
|
||||
@end
|
||||
|
||||
@implementation RNCallKit
|
||||
|
@ -112,12 +112,12 @@ RCT_EXPORT_METHOD(setProviderConfiguration:(NSDictionary *)dictionary) {
|
|||
dictionary);
|
||||
#endif
|
||||
|
||||
if (![JMCallKitProxy hasProviderBeenConfigurated]) {
|
||||
if (![JMCallKitProxy isProviderConfigured]) {
|
||||
[self configureProviderFromDictionary:dictionary];
|
||||
}
|
||||
|
||||
// register to receive CallKit proxy events
|
||||
[JMCallKitProxy addListener: self];
|
||||
[JMCallKitProxy addListener:self];
|
||||
}
|
||||
|
||||
// Start outgoing call
|
||||
|
@ -130,11 +130,8 @@ RCT_EXPORT_METHOD(startCall:(NSString *)callUUID
|
|||
NSLog(@"[RNCallKit][startCall] callUUID = %@", callUUID);
|
||||
#endif
|
||||
|
||||
NSUUID *callUUID_ = [[NSUUID alloc] initWithUUIDString:callUUID];
|
||||
|
||||
// Don't start a call action if there's
|
||||
// an active call for this UUID
|
||||
// (i.e. JitsiMeetView was configured from an incoming call
|
||||
// Don't start a new call if there's an active call for the specified
|
||||
// callUUID. JitsiMeetView was configured for an incoming call.
|
||||
if ([JMCallKitProxy hasActiveCallForUUID:callUUID]) {
|
||||
resolve(nil);
|
||||
return;
|
||||
|
@ -142,6 +139,7 @@ RCT_EXPORT_METHOD(startCall:(NSString *)callUUID
|
|||
|
||||
CXHandle *handle_
|
||||
= [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handle];
|
||||
NSUUID *callUUID_ = [[NSUUID alloc] initWithUUIDString:callUUID];
|
||||
CXStartCallAction *action
|
||||
= [[CXStartCallAction alloc] initWithCallUUID:callUUID_
|
||||
handle:handle_];
|
||||
|
@ -156,8 +154,8 @@ RCT_EXPORT_METHOD(reportCallFailed:(NSString *)callUUID
|
|||
reject:(RCTPromiseRejectBlock)reject) {
|
||||
NSUUID *callUUID_ = [[NSUUID alloc] initWithUUIDString:callUUID];
|
||||
[JMCallKitProxy reportCallWith:callUUID_
|
||||
endedAt:nil
|
||||
reason:CXCallEndedReasonFailed];
|
||||
endedAt:nil
|
||||
reason:CXCallEndedReasonFailed];
|
||||
resolve(nil);
|
||||
}
|
||||
|
||||
|
@ -167,7 +165,7 @@ RCT_EXPORT_METHOD(reportConnectedOutgoingCall:(NSString *)callUUID
|
|||
reject:(RCTPromiseRejectBlock)reject) {
|
||||
NSUUID *callUUID_ = [[NSUUID alloc] initWithUUIDString:callUUID];
|
||||
[JMCallKitProxy reportOutgoingCallWith:callUUID_
|
||||
connectedAt:nil];
|
||||
connectedAt:nil];
|
||||
resolve(nil);
|
||||
}
|
||||
|
||||
|
@ -188,9 +186,9 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
|
|||
BOOL hasVideo = [(NSNumber*)options[@"hasVideo"] boolValue];
|
||||
|
||||
[JMCallKitProxy reportCallUpdateWith:callUUID_
|
||||
handle:nil
|
||||
displayName:displayName
|
||||
hasVideo:hasVideo];
|
||||
handle:nil
|
||||
displayName:displayName
|
||||
hasVideo:hasVideo];
|
||||
|
||||
resolve(nil);
|
||||
}
|
||||
|
@ -229,9 +227,10 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
|
|||
|
||||
NSString *ringtoneSound = dictionary[@"ringtoneSound"];
|
||||
|
||||
[JMCallKitProxy configureCallKitProviderWithLocalizedName:localizedName
|
||||
ringtoneSound:ringtoneSound
|
||||
iconTemplateImageData:iconTemplateImageData];
|
||||
[JMCallKitProxy
|
||||
configureProviderWithLocalizedName:localizedName
|
||||
ringtoneSound:ringtoneSound
|
||||
iconTemplateImageData:iconTemplateImageData];
|
||||
}
|
||||
|
||||
- (void)requestTransaction:(CXTransaction *)transaction
|
||||
|
@ -242,7 +241,7 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
|
|||
#endif
|
||||
|
||||
[JMCallKitProxy request:transaction
|
||||
completion:^(NSError * _Nullable error) {
|
||||
completion:^(NSError * _Nullable error) {
|
||||
if (error) {
|
||||
NSLog(
|
||||
@"[RNCallKit][requestTransaction] Error requesting transaction (%@): (%@)",
|
||||
|
@ -255,7 +254,7 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
|
|||
}];
|
||||
}
|
||||
|
||||
#pragma mark - JitsiMeetCallKitListener
|
||||
#pragma mark - JMCallKitListener
|
||||
|
||||
// Called when the provider has been reset. We should terminate all calls.
|
||||
- (void)providerDidReset {
|
||||
|
@ -307,7 +306,7 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
|
|||
NSLog(@"[RNCallKit][CXProviderDelegate][provider:performStartCallAction:]");
|
||||
#endif
|
||||
[JMCallKitProxy reportOutgoingCallWith:UUID
|
||||
startedConnectingAt:nil];
|
||||
startedConnectingAt:nil];
|
||||
}
|
||||
|
||||
// The following just help with debugging:
|
|
@ -18,7 +18,7 @@ import AVKit
|
|||
import CallKit
|
||||
import Foundation
|
||||
|
||||
internal final class JMCallKitNotifier: NSObject, CXProviderDelegate {
|
||||
internal final class JMCallKitEmitter: NSObject, CXProviderDelegate {
|
||||
|
||||
private var listeners = Set<JMCallKitEventListenerWrapper>()
|
||||
|
||||
|
@ -26,14 +26,14 @@ internal final class JMCallKitNotifier: NSObject, CXProviderDelegate {
|
|||
|
||||
// MARK: - Add/remove listeners
|
||||
|
||||
func addListener(_ listener: JMCallKitEventListener) {
|
||||
func addListener(_ listener: JMCallKitListener) {
|
||||
let wrapper = JMCallKitEventListenerWrapper(listener: listener)
|
||||
objc_sync_enter(listeners)
|
||||
listeners.insert(wrapper)
|
||||
objc_sync_exit(listeners)
|
||||
}
|
||||
|
||||
func removeListener(_ listener: JMCallKitEventListener) {
|
||||
func removeListener(_ listener: JMCallKitListener) {
|
||||
let wrapper = JMCallKitEventListenerWrapper(listener: listener)
|
||||
objc_sync_enter(listeners)
|
||||
listeners.remove(wrapper)
|
||||
|
@ -50,7 +50,9 @@ internal final class JMCallKitNotifier: NSObject, CXProviderDelegate {
|
|||
|
||||
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
|
||||
objc_sync_enter(listeners)
|
||||
listeners.forEach { $0.listener?.performAnswerCall?(UUID: action.callUUID) }
|
||||
listeners.forEach {
|
||||
$0.listener?.performAnswerCall?(UUID: action.callUUID)
|
||||
}
|
||||
objc_sync_exit(listeners)
|
||||
|
||||
action.fulfill()
|
||||
|
@ -58,7 +60,9 @@ internal final class JMCallKitNotifier: NSObject, CXProviderDelegate {
|
|||
|
||||
func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
|
||||
objc_sync_enter(listeners)
|
||||
listeners.forEach { $0.listener?.performEndCall?(UUID: action.callUUID) }
|
||||
listeners.forEach {
|
||||
$0.listener?.performEndCall?(UUID: action.callUUID)
|
||||
}
|
||||
objc_sync_exit(listeners)
|
||||
|
||||
action.fulfill()
|
||||
|
@ -68,7 +72,7 @@ internal final class JMCallKitNotifier: NSObject, CXProviderDelegate {
|
|||
objc_sync_enter(listeners)
|
||||
listeners.forEach {
|
||||
$0.listener?.performSetMutedCall?(UUID: action.callUUID,
|
||||
isMuted: action.isMuted)
|
||||
isMuted: action.isMuted)
|
||||
}
|
||||
objc_sync_exit(listeners)
|
||||
|
||||
|
@ -79,14 +83,15 @@ internal final class JMCallKitNotifier: NSObject, CXProviderDelegate {
|
|||
objc_sync_enter(listeners)
|
||||
listeners.forEach {
|
||||
$0.listener?.performStartCall?(UUID: action.callUUID,
|
||||
isVideo: action.isVideo)
|
||||
isVideo: action.isVideo)
|
||||
}
|
||||
objc_sync_exit(listeners)
|
||||
|
||||
action.fulfill()
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
|
||||
func provider(_ provider: CXProvider,
|
||||
didActivate audioSession: AVAudioSession) {
|
||||
objc_sync_enter(listeners)
|
||||
listeners.forEach {
|
||||
$0.listener?.providerDidActivateAudioSession?(session: audioSession)
|
||||
|
@ -94,11 +99,32 @@ internal final class JMCallKitNotifier: NSObject, CXProviderDelegate {
|
|||
objc_sync_exit(listeners)
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
|
||||
func provider(_ provider: CXProvider,
|
||||
didDeactivate audioSession: AVAudioSession) {
|
||||
objc_sync_enter(listeners)
|
||||
listeners.forEach {
|
||||
$0.listener?.providerDidDeactivateAudioSession?(session: audioSession)
|
||||
$0.listener?.providerDidDeactivateAudioSession?(
|
||||
session: audioSession)
|
||||
}
|
||||
objc_sync_exit(listeners)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate struct JMCallKitEventListenerWrapper: Hashable {
|
||||
|
||||
public var hashValue: Int
|
||||
|
||||
internal weak var listener: JMCallKitListener?
|
||||
|
||||
public init(listener: JMCallKitListener) {
|
||||
self.listener = listener
|
||||
self.hashValue = listener.hash
|
||||
}
|
||||
|
||||
public static func ==(lhs: JMCallKitEventListenerWrapper,
|
||||
rhs: JMCallKitEventListenerWrapper) -> Bool {
|
||||
// XXX We're aware that "[t]wo instances with equal hash values are not
|
||||
// necessarily equal to each other."
|
||||
return lhs.hashValue == rhs.hashValue
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ import AVKit
|
|||
import CallKit
|
||||
import Foundation
|
||||
|
||||
@objc public protocol JMCallKitEventListener: NSObjectProtocol {
|
||||
@objc public protocol JMCallKitListener: NSObjectProtocol {
|
||||
|
||||
@available(iOS 10.0, *)
|
||||
@objc optional func providerDidReset()
|
||||
|
@ -44,20 +44,3 @@ import Foundation
|
|||
@available(iOS 10.0, *)
|
||||
@objc optional func providerTimedOutPerformingAction(action: CXAction)
|
||||
}
|
||||
|
||||
internal struct JMCallKitEventListenerWrapper: Hashable {
|
||||
|
||||
public var hashValue: Int
|
||||
|
||||
internal weak var listener: JMCallKitEventListener?
|
||||
|
||||
public init(listener: JMCallKitEventListener) {
|
||||
self.listener = listener
|
||||
self.hashValue = listener.hash
|
||||
}
|
||||
|
||||
public static func ==(lhs: JMCallKitEventListenerWrapper,
|
||||
rhs: JMCallKitEventListenerWrapper) -> Bool {
|
||||
return lhs.hashValue == rhs.hashValue
|
||||
}
|
||||
}
|
|
@ -21,133 +21,137 @@ import Foundation
|
|||
@available(iOS 10.0, *)
|
||||
@objc public final class JMCallKitProxy: NSObject {
|
||||
|
||||
override private init() {}
|
||||
private override init() {}
|
||||
|
||||
// MARK: - CallKit proxy
|
||||
|
||||
internal static let cxProvider: CXProvider = {
|
||||
let config = CXProviderConfiguration(localizedName: "")
|
||||
let provider = CXProvider(configuration: config)
|
||||
return provider
|
||||
private static let provider: CXProvider = {
|
||||
let configuration = CXProviderConfiguration(localizedName: "")
|
||||
return CXProvider(configuration: configuration)
|
||||
}()
|
||||
|
||||
internal static let cxCallController: CXCallController = {
|
||||
return CXCallController()
|
||||
}()
|
||||
|
||||
internal static let callKitNotifier: JMCallKitNotifier = {
|
||||
return JMCallKitNotifier()
|
||||
}()
|
||||
|
||||
internal static var cxProviderConfiguration: CXProviderConfiguration? {
|
||||
private static var providerConfiguration: CXProviderConfiguration? {
|
||||
didSet {
|
||||
guard let providerConfiguration = cxProviderConfiguration else { return }
|
||||
cxProvider.configuration = providerConfiguration
|
||||
cxProvider.setDelegate(callKitNotifier, queue: nil)
|
||||
guard let configuration = providerConfiguration else { return }
|
||||
provider.configuration = configuration
|
||||
provider.setDelegate(emitter, queue: nil)
|
||||
}
|
||||
}
|
||||
|
||||
/// Enables the proxy in between callkit and the consumers of the SDK
|
||||
/// Default to enabled, set to false when you don't want to use callkit
|
||||
private static let callController: CXCallController = {
|
||||
return CXCallController()
|
||||
}()
|
||||
|
||||
private static let emitter: JMCallKitEmitter = {
|
||||
return JMCallKitEmitter()
|
||||
}()
|
||||
|
||||
/// Enables the proxy in between CallKit and the consumers of the SDK.
|
||||
/// Defaults to enabled, set to false when you don't want to use CallKit.
|
||||
@objc public static var enabled: Bool = true {
|
||||
didSet {
|
||||
if enabled == false {
|
||||
cxProvider.setDelegate(nil, queue: nil)
|
||||
provider.setDelegate(nil, queue: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc public static func hasProviderBeenConfigurated() -> Bool {
|
||||
return cxProviderConfiguration != nil
|
||||
}
|
||||
|
||||
@objc public static func configureCallKitProvider(localizedName: String,
|
||||
ringtoneSound: String?,
|
||||
iconTemplateImageData: Data?) {
|
||||
@objc public static func configureProvider(localizedName: String,
|
||||
ringtoneSound: String?,
|
||||
iconTemplateImageData: Data?) {
|
||||
let configuration = CXProviderConfiguration(localizedName: localizedName)
|
||||
configuration.ringtoneSound = ringtoneSound
|
||||
configuration.iconTemplateImageData = iconTemplateImageData
|
||||
|
||||
configuration.maximumCallGroups = 1
|
||||
configuration.maximumCallsPerCallGroup = 1
|
||||
configuration.ringtoneSound = ringtoneSound
|
||||
configuration.supportedHandleTypes = [CXHandle.HandleType.generic]
|
||||
configuration.supportsVideo = true
|
||||
cxProviderConfiguration = configuration
|
||||
|
||||
providerConfiguration = configuration
|
||||
}
|
||||
|
||||
@objc public static func addListener(_ listener: JMCallKitEventListener) {
|
||||
callKitNotifier.addListener(listener)
|
||||
@objc public static func isProviderConfigured() -> Bool {
|
||||
return providerConfiguration != nil
|
||||
}
|
||||
|
||||
@objc public static func removeListener(_ listener: JMCallKitEventListener) {
|
||||
callKitNotifier.removeListener(listener)
|
||||
@objc public static func addListener(_ listener: JMCallKitListener) {
|
||||
emitter.addListener(listener)
|
||||
}
|
||||
|
||||
@objc public static func removeListener(_ listener: JMCallKitListener) {
|
||||
emitter.removeListener(listener)
|
||||
}
|
||||
|
||||
@objc public static func hasActiveCallForUUID(_ callUUID: String) -> Bool {
|
||||
let activeCallForUUID = cxCallController.callObserver.calls.first {
|
||||
let activeCallForUUID = callController.callObserver.calls.first {
|
||||
$0.uuid == UUID(uuidString: callUUID)
|
||||
}
|
||||
guard activeCallForUUID != nil else { return false }
|
||||
return true
|
||||
}
|
||||
|
||||
@objc public static func reportNewIncomingCall(UUID: UUID,
|
||||
handle: String?,
|
||||
displayName: String?,
|
||||
hasVideo: Bool,
|
||||
completion: @escaping (Error?) -> Void) {
|
||||
@objc public static func reportNewIncomingCall(
|
||||
UUID: UUID,
|
||||
handle: String?,
|
||||
displayName: String?,
|
||||
hasVideo: Bool,
|
||||
completion: @escaping (Error?) -> Void) {
|
||||
guard enabled else { return }
|
||||
|
||||
let callUpdate = makeCXUpdate(handle: handle,
|
||||
displayName: displayName,
|
||||
hasVideo: hasVideo)
|
||||
cxProvider.reportNewIncomingCall(with: UUID,
|
||||
update: callUpdate,
|
||||
completion: completion)
|
||||
provider.reportNewIncomingCall(with: UUID,
|
||||
update: callUpdate,
|
||||
completion: completion)
|
||||
}
|
||||
|
||||
@objc public static func reportCallUpdate(with UUID: UUID,
|
||||
handle: String?,
|
||||
displayName: String?,
|
||||
hasVideo: Bool) {
|
||||
handle: String?,
|
||||
displayName: String?,
|
||||
hasVideo: Bool) {
|
||||
guard enabled else { return }
|
||||
|
||||
let callUpdate = makeCXUpdate(handle: handle,
|
||||
displayName: displayName,
|
||||
hasVideo: hasVideo)
|
||||
cxProvider.reportCall(with: UUID, updated: callUpdate)
|
||||
provider.reportCall(with: UUID, updated: callUpdate)
|
||||
}
|
||||
|
||||
@objc public static func reportCall(with UUID: UUID,
|
||||
endedAt dateEnded: Date?,
|
||||
reason endedReason: CXCallEndedReason) {
|
||||
@objc public static func reportCall(
|
||||
with UUID: UUID,
|
||||
endedAt dateEnded: Date?,
|
||||
reason endedReason: CXCallEndedReason) {
|
||||
guard enabled else { return }
|
||||
|
||||
cxProvider.reportCall(with: UUID,
|
||||
endedAt: dateEnded,
|
||||
reason: endedReason)
|
||||
provider.reportCall(with: UUID,
|
||||
endedAt: dateEnded,
|
||||
reason: endedReason)
|
||||
}
|
||||
|
||||
@objc public static func reportOutgoingCall(with UUID: UUID,
|
||||
startedConnectingAt dateStartedConnecting: Date?) {
|
||||
@objc public static func reportOutgoingCall(
|
||||
with UUID: UUID,
|
||||
startedConnectingAt dateStartedConnecting: Date?) {
|
||||
guard enabled else { return }
|
||||
|
||||
cxProvider.reportOutgoingCall(with: UUID,
|
||||
startedConnectingAt: dateStartedConnecting)
|
||||
provider.reportOutgoingCall(with: UUID,
|
||||
startedConnectingAt: dateStartedConnecting)
|
||||
}
|
||||
|
||||
@objc public static func reportOutgoingCall(with UUID: UUID,
|
||||
connectedAt dateConnected: Date?) {
|
||||
@objc public static func reportOutgoingCall(
|
||||
with UUID: UUID,
|
||||
connectedAt dateConnected: Date?) {
|
||||
guard enabled else { return }
|
||||
|
||||
cxProvider.reportOutgoingCall(with: UUID, connectedAt: dateConnected)
|
||||
provider.reportOutgoingCall(with: UUID, connectedAt: dateConnected)
|
||||
}
|
||||
|
||||
@objc public static func request(_ transaction: CXTransaction,
|
||||
completion: @escaping (Error?) -> Swift.Void) {
|
||||
@objc public static func request(
|
||||
_ transaction: CXTransaction,
|
||||
completion: @escaping (Error?) -> Swift.Void) {
|
||||
guard enabled else { return }
|
||||
|
||||
cxCallController.request(transaction, completion: completion)
|
||||
callController.request(transaction, completion: completion)
|
||||
}
|
||||
|
||||
// MARK: - Callkit Proxy helpers
|
||||
|
@ -173,5 +177,4 @@ import Foundation
|
|||
|
||||
return update
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
import uuid from 'uuid';
|
||||
|
||||
import {
|
||||
createTrackMutedEvent,
|
||||
sendAnalytics
|
||||
} from '../../analytics';
|
||||
import { createTrackMutedEvent, sendAnalytics } from '../../analytics';
|
||||
import {
|
||||
APP_WILL_MOUNT,
|
||||
APP_WILL_UNMOUNT,
|
||||
|
@ -29,16 +26,13 @@ import {
|
|||
setAudioMuted
|
||||
} from '../../base/media';
|
||||
import { MiddlewareRegistry } from '../../base/redux';
|
||||
import {
|
||||
TRACK_CREATE_ERROR,
|
||||
isLocalTrackMuted
|
||||
} from '../../base/tracks';
|
||||
import { TRACK_CREATE_ERROR, isLocalTrackMuted } from '../../base/tracks';
|
||||
|
||||
import { _SET_CALLKIT_SUBSCRIPTIONS } from './actionTypes';
|
||||
import CallKit from './CallKit';
|
||||
|
||||
/**
|
||||
* Middleware that captures several system actions and hooks up CallKit.
|
||||
* Middleware that captures system actions and hooks up CallKit.
|
||||
*
|
||||
* @param {Store} store - The redux store.
|
||||
* @returns {Function}
|
||||
|
@ -84,17 +78,17 @@ CallKit && MiddlewareRegistry.register(store => next => action => {
|
|||
});
|
||||
|
||||
/**
|
||||
* Notifies the feature jwt that the action {@link APP_WILL_MOUNT} is being
|
||||
* Notifies the feature callkit that the action {@link APP_WILL_MOUNT} is being
|
||||
* dispatched within a specific redux {@code store}.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||
* specified {@code action} to the specified {@code store}.
|
||||
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
||||
* specified {@code action} in the specified {@code store}.
|
||||
* @param {Action} action - The redux action {@code APP_WILL_MOUNT} which is
|
||||
* being dispatched in the specified {@code store}.
|
||||
* @private
|
||||
* @returns {*}
|
||||
* @returns {*} The value returned by {@code next(action)}.
|
||||
*/
|
||||
function _appWillMount({ dispatch, getState }, next, action) {
|
||||
const result = next(action);
|
||||
|
@ -119,8 +113,8 @@ function _appWillMount({ dispatch, getState }, next, action) {
|
|||
context),
|
||||
|
||||
// According to CallKit's documentation, when the system resets we
|
||||
// should terminate all calls. Hence, providerDidReset is the same
|
||||
// to us as performEndCallAction.
|
||||
// should terminate all calls. Hence, providerDidReset is the same to us
|
||||
// as performEndCallAction.
|
||||
CallKit.addListener(
|
||||
'providerDidReset',
|
||||
_onPerformEndCallAction,
|
||||
|
@ -136,17 +130,17 @@ function _appWillMount({ dispatch, getState }, next, action) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Notifies the feature jwt that the action {@link CONFERENCE_FAILED} is being
|
||||
* dispatched within a specific redux {@code store}.
|
||||
* Notifies the feature callkit that the action {@link CONFERENCE_FAILED} is
|
||||
* being dispatched within a specific redux {@code store}.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||
* specified {@code action} to the specified {@code store}.
|
||||
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
||||
* specified {@code action} in the specified {@code store}.
|
||||
* @param {Action} action - The redux action {@code CONFERENCE_FAILED} which is
|
||||
* being dispatched in the specified {@code store}.
|
||||
* @private
|
||||
* @returns {*}
|
||||
* @returns {*} The value returned by {@code next(action)}.
|
||||
*/
|
||||
function _conferenceFailed(store, next, action) {
|
||||
const result = next(action);
|
||||
|
@ -166,17 +160,17 @@ function _conferenceFailed(store, next, action) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Notifies the feature jwt that the action {@link CONFERENCE_JOINED} is being
|
||||
* dispatched within a specific redux {@code store}.
|
||||
* Notifies the feature callkit that the action {@link CONFERENCE_JOINED} is
|
||||
* being dispatched within a specific redux {@code store}.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||
* specified {@code action} to the specified {@code store}.
|
||||
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
||||
* specified {@code action} in the specified {@code store}.
|
||||
* @param {Action} action - The redux action {@code CONFERENCE_JOINED} which is
|
||||
* being dispatched in the specified {@code store}.
|
||||
* @private
|
||||
* @returns {*}
|
||||
* @returns {*} The value returned by {@code next(action)}.
|
||||
*/
|
||||
function _conferenceJoined(store, next, action) {
|
||||
const result = next(action);
|
||||
|
@ -191,17 +185,17 @@ function _conferenceJoined(store, next, action) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Notifies the feature jwt that the action {@link CONFERENCE_LEFT} is being
|
||||
* Notifies the feature callkit that the action {@link CONFERENCE_LEFT} is being
|
||||
* dispatched within a specific redux {@code store}.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||
* specified {@code action} to the specified {@code store}.
|
||||
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
||||
* specified {@code action} in the specified {@code store}.
|
||||
* @param {Action} action - The redux action {@code CONFERENCE_LEFT} which is
|
||||
* being dispatched in the specified {@code store}.
|
||||
* @private
|
||||
* @returns {*}
|
||||
* @returns {*} The value returned by {@code next(action)}.
|
||||
*/
|
||||
function _conferenceLeft(store, next, action) {
|
||||
const result = next(action);
|
||||
|
@ -216,29 +210,29 @@ function _conferenceLeft(store, next, action) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Notifies the feature jwt that the action {@link CONFERENCE_WILL_JOIN} is
|
||||
* Notifies the feature callkit that the action {@link CONFERENCE_WILL_JOIN} is
|
||||
* being dispatched within a specific redux {@code store}.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||
* specified {@code action} to the specified {@code store}.
|
||||
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
||||
* specified {@code action} in the specified {@code store}.
|
||||
* @param {Action} action - The redux action {@code CONFERENCE_WILL_JOIN} which
|
||||
* is being dispatched in the specified {@code store}.
|
||||
* @private
|
||||
* @returns {*}
|
||||
* @returns {*} The value returned by {@code next(action)}.
|
||||
*/
|
||||
function _conferenceWillJoin({ getState }, next, action) {
|
||||
const result = next(action);
|
||||
|
||||
const { conference } = action;
|
||||
const state = getState();
|
||||
const { callUUID } = state['features/base/config'];
|
||||
const url = getInviteURL(state);
|
||||
const hasVideo = !isVideoMutedByAudioOnly(state);
|
||||
const { callUUID } = state['features/base/config'];
|
||||
|
||||
// When assigning the call UUID, do so in upper case, since iOS will
|
||||
// return it upper cased.
|
||||
// When assigning the call UUID, do so in upper case, since iOS will return
|
||||
// it upper cased.
|
||||
conference.callUUID = (callUUID || uuid.v4()).toUpperCase();
|
||||
|
||||
CallKit.startCall(conference.callUUID, url.toString(), hasVideo)
|
||||
|
@ -306,17 +300,17 @@ function _onPerformSetMutedCallAction({ callUUID, muted: newValue }) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Notifies the feature jwt that the action {@link SET_AUDIO_MUTED} is being
|
||||
* Notifies the feature callkit that the action {@link SET_AUDIO_MUTED} is being
|
||||
* dispatched within a specific redux {@code store}.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||
* specified {@code action} to the specified {@code store}.
|
||||
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
||||
* specified {@code action} in the specified {@code store}.
|
||||
* @param {Action} action - The redux action {@code SET_AUDIO_MUTED} which is
|
||||
* being dispatched in the specified {@code store}.
|
||||
* @private
|
||||
* @returns {*}
|
||||
* @returns {*} The value returned by {@code next(action)}.
|
||||
*/
|
||||
function _setAudioMuted({ getState }, next, action) {
|
||||
const result = next(action);
|
||||
|
@ -331,17 +325,18 @@ function _setAudioMuted({ getState }, next, action) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Notifies the feature jwt that the action {@link _SET_CALLKIT_SUBSCRIPTIONS}
|
||||
* is being dispatched within a specific redux {@code store}.
|
||||
* Notifies the feature callkit that the action
|
||||
* {@link _SET_CALLKIT_SUBSCRIPTIONS} is being dispatched within a specific
|
||||
* redux {@code store}.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||
* specified {@code action} to the specified {@code store}.
|
||||
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
||||
* specified {@code action} in the specified {@code store}.
|
||||
* @param {Action} action - The redux action {@code _SET_CALLKIT_SUBSCRIPTIONS}
|
||||
* which is being dispatched in the specified {@code store}.
|
||||
* @private
|
||||
* @returns {*}
|
||||
* @returns {*} The value returned by {@code next(action)}.
|
||||
*/
|
||||
function _setCallKitSubscriptions({ getState }, next, action) {
|
||||
const { subscriptions } = getState()['features/callkit'];
|
||||
|
@ -356,17 +351,17 @@ function _setCallKitSubscriptions({ getState }, next, action) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Notifies the feature jwt that the action {@link SET_VIDEO_MUTED} is being
|
||||
* Notifies the feature callkit that the action {@link SET_VIDEO_MUTED} is being
|
||||
* dispatched within a specific redux {@code store}.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||
* specified {@code action} to the specified {@code store}.
|
||||
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
||||
* specified {@code action} in the specified {@code store}.
|
||||
* @param {Action} action - The redux action {@code SET_VIDEO_MUTED} which is
|
||||
* being dispatched in the specified {@code store}.
|
||||
* @private
|
||||
* @returns {*}
|
||||
* @returns {*} The value returned by {@code next(action)}.
|
||||
*/
|
||||
function _setVideoMuted({ getState }, next, action) {
|
||||
const result = next(action);
|
||||
|
@ -385,17 +380,17 @@ function _setVideoMuted({ getState }, next, action) {
|
|||
/**
|
||||
* Handles a track creation failure. This is relevant to us in the following
|
||||
* (corner) case: if the user never gave their permission to use the microphone
|
||||
* and try to unmute from the CallKit interface, this will fail, and we need
|
||||
* to sync back the CallKit button state.
|
||||
* and try to unmute from the CallKit interface, this will fail, and we need to
|
||||
* sync back the CallKit button state.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
||||
* specified {@code action} to the specified {@code store}.
|
||||
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
||||
* specified {@code action} in the specified {@code store}.
|
||||
* @param {Action} action - The redux action {@code TRACK_CREARE_ERROR} which is
|
||||
* being dispatched in the specified {@code store}.
|
||||
* @private
|
||||
* @returns {*}
|
||||
* @returns {*} The value returned by {@code next(action)}.
|
||||
*/
|
||||
function _trackCreateError({ getState }, next, action) {
|
||||
const result = next(action);
|
||||
|
|
Loading…
Reference in New Issue