@@ -2,16 +2,16 @@ import Flutter
22import UIKit
33
44public class StreamVideoPushNotificationPlugin : NSObject , FlutterPlugin {
5- private let devicePushTokenVoIP = " DevicePushTokenVoIP "
5+ private static let devicePushTokenVoIPKey = " DevicePushTokenVoIP "
66
77 let persistentState : UserDefaults = UserDefaults . standard
88
9- @objc public private( set) static var sharedInstance : StreamVideoPushNotificationPlugin !
9+ @objc public private( set) static var sharedInstance : StreamVideoPushNotificationPlugin ?
1010
1111 private var callKitManager : StreamVideoCallkitManager
1212
13- public init ( callKitManager : StreamVideoCallkitManager ) {
14- self . callKitManager = callKitManager
13+ private override init ( ) {
14+ self . callKitManager = StreamVideoCallkitManager . shared
1515 super. init ( )
1616 }
1717
@@ -24,10 +24,10 @@ public class StreamVideoPushNotificationPlugin: NSObject, FlutterPlugin {
2424 let eventsHandler = EventCallbackHandler ( )
2525 eventChannel. setStreamHandler ( eventsHandler)
2626
27- let callKitManager = StreamVideoCallkitManager ( eventHandler: eventsHandler)
28- sharedInstance = StreamVideoPushNotificationPlugin ( callKitManager: callKitManager)
27+ StreamVideoCallkitManager . shared. setEventHandler ( eventsHandler)
2928
30- registrar. addMethodCallDelegate ( sharedInstance, channel: mainChannel)
29+ sharedInstance = StreamVideoPushNotificationPlugin ( )
30+ registrar. addMethodCallDelegate ( sharedInstance!, channel: mainChannel)
3131
3232 StreamVideoPKDelegateManager . shared. initChannel ( mainChannel: mainChannel)
3333 }
@@ -59,35 +59,34 @@ public class StreamVideoPushNotificationPlugin: NSObject, FlutterPlugin {
5959 }
6060
6161 @objc public static func setDevicePushTokenVoIP( deviceToken: String ) {
62- sharedInstance. setDevicePushTokenVoIP ( deviceToken: deviceToken)
63- //TODO: send event? //ACTION_DID_UPDATE_DEVICE_PUSH_TOKEN_VOIP
62+ sharedInstance? . setDevicePushTokenVoIP ( deviceToken: deviceToken)
6463 }
6564
6665 @objc public static func startOutgoingCall(
6766 data: CallData ,
6867 fromPushKit: Bool
6968 ) {
70- sharedInstance . callKitManager . startCall ( data, fromPushKit: fromPushKit)
69+ StreamVideoCallkitManager . shared . startCall ( data, fromPushKit: fromPushKit)
7170 }
7271
7372 @objc public static func showIncomingCall(
7473 data: CallData ,
7574 fromPushKit: Bool
7675 ) {
77- sharedInstance . callKitManager . showIncomingCall (
76+ StreamVideoCallkitManager . shared . showIncomingCall (
7877 data, fromPushKit: fromPushKit)
7978 }
8079
8180 @objc public static func activeCalls( ) -> [ [ String : Any ] ] ? {
82- sharedInstance . callKitManager . activeCalls ( )
81+ return StreamVideoCallkitManager . shared . activeCalls ( )
8382 }
8483
8584 @objc public func setDevicePushTokenVoIP( deviceToken: String ) {
86- persistentState. set ( deviceToken, forKey: devicePushTokenVoIP )
85+ persistentState. set ( deviceToken, forKey: Self . devicePushTokenVoIPKey )
8786 }
8887
8988 @objc public func getDevicePushTokenVoIP( ) -> String {
90- return persistentState. string ( forKey: devicePushTokenVoIP ) ?? " "
89+ return persistentState. string ( forKey: Self . devicePushTokenVoIPKey ) ?? " "
9190 }
9291}
9392
0 commit comments