diff --git a/ChatSDKCore/Classes/Convenience/BModuleHelper.m b/ChatSDKCore/Classes/Convenience/BModuleHelper.m index 95abd5f6..3fa7fff6 100755 --- a/ChatSDKCore/Classes/Convenience/BModuleHelper.m +++ b/ChatSDKCore/Classes/Convenience/BModuleHelper.m @@ -50,6 +50,7 @@ -(void) activateModulesForXMPP { -(void) activateCommonModules: (NSString *) server { [self activateModuleForName:@"BBlockingModule"]; + [self activateModuleForName:@"BSinchModule"]; [self activateModuleForName:@"BLastOnlineModule"]; [self activateModuleForName:@"BAudioMessageModule"]; [self activateModuleForName:@"BVideoMessageModule"]; diff --git a/ChatSDKCore/Classes/Core.h b/ChatSDKCore/Classes/Core.h index 826bbae0..3003a523 100755 --- a/ChatSDKCore/Classes/Core.h +++ b/ChatSDKCore/Classes/Core.h @@ -73,6 +73,9 @@ #import #import #import +#import +#import +#import #import #import #import diff --git a/ChatSDKCore/Classes/Handlers/Abstract/BAbstractNetworkAdapter.h b/ChatSDKCore/Classes/Handlers/Abstract/BAbstractNetworkAdapter.h index 16023476..e7215e3e 100755 --- a/ChatSDKCore/Classes/Handlers/Abstract/BAbstractNetworkAdapter.h +++ b/ChatSDKCore/Classes/Handlers/Abstract/BAbstractNetworkAdapter.h @@ -25,6 +25,7 @@ @property (nonatomic, readwrite) id search; @property (nonatomic, readwrite) id publicThread; @property (nonatomic, readwrite) id blocking; +@property (nonatomic, readwrite) id calling; @property (nonatomic, readwrite) id lastOnline; @property (nonatomic, readwrite) id nearbyUsers; @property (nonatomic, readwrite) id readReceipt; diff --git a/ChatSDKCore/Classes/Interfaces/PCall.h b/ChatSDKCore/Classes/Interfaces/PCall.h new file mode 100644 index 00000000..93e5f893 --- /dev/null +++ b/ChatSDKCore/Classes/Interfaces/PCall.h @@ -0,0 +1,27 @@ +// +// PCall.h +// ChatSDK +// +// Created by Pepe Becker on 9/3/19. +// + +#ifndef PCall_h +#define PCall_h + +@protocol PCall + +- (void)answer; +- (void)hangup; +- (void)pauseVideo; +- (void)resumeVideo; + +- (void)setDelegate:(id)delegate; +- (id)delegate; + +- (NSString *)callId; +- (NSString *)remoteUserId; +- (BOOL)isOutgoing; + +@end + +#endif /* PCall_h */ diff --git a/ChatSDKCore/Classes/Interfaces/PCallDelegate.h b/ChatSDKCore/Classes/Interfaces/PCallDelegate.h new file mode 100644 index 00000000..61d4809b --- /dev/null +++ b/ChatSDKCore/Classes/Interfaces/PCallDelegate.h @@ -0,0 +1,22 @@ +// +// PCallDelegate.h +// ChatSDK +// +// Created by Pepe Becker on 9/5/19. +// + +#ifndef PCallDelegate_h +#define PCallDelegate_h + +@protocol PCall; + +@protocol PCallDelegate +@optional +- (void)callDidEnd:(id)call; +- (void)callDidProgress:(id)call; +- (void)callDidEstablish:(id)call; +- (void)callDidPauseVideo:(id)call; +- (void)callDidResumeVideo:(id)call; +@end + +#endif /* PCallDelegate_h */ diff --git a/ChatSDKCore/Classes/Interfaces/PCallHandler.h b/ChatSDKCore/Classes/Interfaces/PCallHandler.h new file mode 100644 index 00000000..53dd1978 --- /dev/null +++ b/ChatSDKCore/Classes/Interfaces/PCallHandler.h @@ -0,0 +1,43 @@ +// +// PCallHandler.h +// ChatSDKModules +// +// Created by Pepe Becker on 9/3/19. +// + +#ifndef PCallHandler_h +#define PCallHandler_h + +@class RXPromise; +@protocol PCall; + +@protocol PCallHandler + +- (RXPromise *)startWithUserId:(NSString *)userId; +- (RXPromise *)callUserWithId:(NSString *)userId; +- (id)activeCall; +- (id)incomingCall; +- (void)answerIncomingCall; +- (void)hangupIncomingCall; +- (void)hangupActiveCall; + +- (UIView *)localView; +- (UIView *)remoteView; + +- (void)enableSpeaker; +- (void)disableSpeaker; + +- (int)captureDevicePosition; +- (void)setCaptureDevicePosition:(int)i; +- (void)toggleCaptureDevicePosition; + +- (UINavigationController *)callNavigationController; +- (UINavigationController *)incomingCallNavigationController; +- (UIViewController *)callViewController; +- (UIViewController *)incomingCallViewController; +- (void)setCallViewControllerClass:(Class)controllerClass; +- (void)setIncomingCallViewControllerClass:(Class)controllerClass; + +@end + +#endif /* PCallHandler_h */ diff --git a/ChatSDKCore/Classes/Interfaces/PNetworkAdapter.h b/ChatSDKCore/Classes/Interfaces/PNetworkAdapter.h index 985b639b..61662208 100755 --- a/ChatSDKCore/Classes/Interfaces/PNetworkAdapter.h +++ b/ChatSDKCore/Classes/Interfaces/PNetworkAdapter.h @@ -23,6 +23,7 @@ @protocol PPublicThreadHandler; @protocol PLastOnlineHandler; @protocol PBlockingHandler; +@protocol PCallHandler; @protocol PNearbyUsersHandler; @protocol PReadReceiptHandler; @protocol PStickerMessageHandler; @@ -94,6 +95,7 @@ -(id) publicThread; -(id) lastOnline; -(id) blocking; +-(id) calling; -(id) nearbyUsers; -(id) readReceipt; -(id) stickerMessage; @@ -121,6 +123,7 @@ -(void) setPublicThread: (id) publicThread; -(void) setLastOnline: (id) lastOnline; -(void) setBlocking: (id) blocking; +-(void) setCalling: (id) calling; -(void) setNearbyUsers: (id) nearbyUsers; -(void) setReadReceipt: (id) readReceipt; -(void) setStickerMessage: (id) stickerMessage; diff --git a/ChatSDKCore/Classes/Session/BChatSDK.h b/ChatSDKCore/Classes/Session/BChatSDK.h index 096fe1d7..260f5856 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.h +++ b/ChatSDKCore/Classes/Session/BChatSDK.h @@ -79,6 +79,7 @@ +(id) search; +(id) publicThread; +(id) blocking; ++(id) calling; +(id) lastOnline; +(id) nearbyUsers; +(id) readReceipt; diff --git a/ChatSDKCore/Classes/Session/BChatSDK.m b/ChatSDKCore/Classes/Session/BChatSDK.m index ffe64809..20be6d02 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.m +++ b/ChatSDKCore/Classes/Session/BChatSDK.m @@ -272,6 +272,10 @@ -(BBackgroundPushNotificationQueue *) pushQueue { return self.a.blocking; } ++(id) calling { + return self.a.calling; +} + +(id) lastOnline { return self.a.lastOnline; } diff --git a/ChatSDKUI/Assets/call_white_24pt.png b/ChatSDKUI/Assets/call_white_24pt.png new file mode 100755 index 00000000..34c17c87 Binary files /dev/null and b/ChatSDKUI/Assets/call_white_24pt.png differ diff --git a/ChatSDKUI/Assets/call_white_24pt@2x.png b/ChatSDKUI/Assets/call_white_24pt@2x.png new file mode 100755 index 00000000..e26d2cef Binary files /dev/null and b/ChatSDKUI/Assets/call_white_24pt@2x.png differ diff --git a/ChatSDKUI/Assets/call_white_24pt@3x.png b/ChatSDKUI/Assets/call_white_24pt@3x.png new file mode 100755 index 00000000..d9d2b877 Binary files /dev/null and b/ChatSDKUI/Assets/call_white_24pt@3x.png differ diff --git a/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m b/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m index e485c4eb..381a680a 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m +++ b/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m @@ -40,6 +40,11 @@ -(void) viewDidLoad { [self updateSubtitle]; [super setAudioEnabled: BChatSDK.audioMessage != Nil]; + + if (BChatSDK.calling) { + UIBarButtonItem * callItem = [[UIBarButtonItem alloc] initWithTitle:@"Call" style:UIBarButtonItemStylePlain target:self action:@selector(call)]; + self.navigationItem.rightBarButtonItem = callItem; + } // Add the initial batch of messages NSArray * messages = [BChatSDK.db loadMessagesForThread:_thread newest:BChatSDK.config.messagesToLoadPerBatch]; @@ -47,6 +52,13 @@ -(void) viewDidLoad { [self setMessages:messages scrollToBottom:NO animate:NO force: YES]; } +-(void) call { + if (!BChatSDK.calling) return; + [BChatSDK.calling callUserWithId:_thread.otherUser.entityID]; + UIViewController * controller = [BChatSDK.calling callNavigationController]; + [self presentViewController:controller animated:YES completion:nil]; +} + -(void) updateSubtitle { if (BChatSDK.config.userChatInfoEnabled) { diff --git a/Xcode/Podfile b/Xcode/Podfile index a52515d1..974a0da2 100644 --- a/Xcode/Podfile +++ b/Xcode/Podfile @@ -19,6 +19,7 @@ target 'ChatSDK Demo' do # pod 'FBSDKLoginKit' + # pod 'ChatSDKModules/SinchModule', :path => '../ChatSDKModules' # pod 'ChatSDKModules/StickerMessage', :path => '../ChatSDKModules' # pod 'ChatSDKModules/KeyboardOverlayOptions', :path => '../ChatSDKModules' # pod 'ChatSDKModules/ContactBook', :path => '../ChatSDKModules'