Skip to content

Commit

Permalink
Release RongCloud CallKit SDK 2.8.31
Browse files Browse the repository at this point in the history
  • Loading branch information
RongRobot committed Apr 27, 2018
1 parent 9d45b9d commit 1bdc054
Show file tree
Hide file tree
Showing 57 changed files with 3,294 additions and 2,293 deletions.
8 changes: 8 additions & 0 deletions ios-rongcallkit/RongCallKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
9CE36FD6200F5FDC0068263B /* RCCXCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CE36FD4200F5FDC0068263B /* RCCXCall.h */; };
9CE36FD7200F5FDC0068263B /* RCCXCall.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CE36FD5200F5FDC0068263B /* RCCXCall.m */; };
A6253FFB1D86A9D000408F9D /* RCDAudioFrameObserver.mm in Sources */ = {isa = PBXBuildFile; fileRef = A6253FF91D86A9D000408F9D /* RCDAudioFrameObserver.mm */; };
A6253FFC1D86A9D000408F9D /* RCDAudioFrameObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = A6253FFA1D86A9D000408F9D /* RCDAudioFrameObserver.h */; };
A68AFAE91CCEFF5B00F16B3D /* RCCallDetailMessageCell.h in Headers */ = {isa = PBXBuildFile; fileRef = A68AFAE51CCEFF5B00F16B3D /* RCCallDetailMessageCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -53,6 +55,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
9CE36FD4200F5FDC0068263B /* RCCXCall.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCCXCall.h; sourceTree = "<group>"; };
9CE36FD5200F5FDC0068263B /* RCCXCall.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCCXCall.m; sourceTree = "<group>"; };
A6253FF91D86A9D000408F9D /* RCDAudioFrameObserver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCDAudioFrameObserver.mm; sourceTree = "<group>"; };
A6253FFA1D86A9D000408F9D /* RCDAudioFrameObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCDAudioFrameObserver.h; sourceTree = "<group>"; };
A68AFAE51CCEFF5B00F16B3D /* RCCallDetailMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCCallDetailMessageCell.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -155,6 +159,8 @@
A6BE1A511CCE561200FF6BF7 /* RongCallKit.h */,
A6BE1B171CCEFAAC00FF6BF7 /* RCCall.h */,
A6BE1B181CCEFAAC00FF6BF7 /* RCCall.mm */,
9CE36FD4200F5FDC0068263B /* RCCXCall.h */,
9CE36FD5200F5FDC0068263B /* RCCXCall.m */,
A6BE1B3C1CCEFAB700FF6BF7 /* Support Files */,
);
path = RongCallKit;
Expand Down Expand Up @@ -286,6 +292,7 @@
A6BE1B2E1CCEFAAC00FF6BF7 /* RCCallVideoMultiCallViewController.h in Headers */,
A6BE1B381CCEFAAC00FF6BF7 /* RCCallFloatingBoard.h in Headers */,
A6BE1B201CCEFAAC00FF6BF7 /* RCCallMultiCallUserCell.h in Headers */,
9CE36FD6200F5FDC0068263B /* RCCXCall.h in Headers */,
F8235CDD1CE5B2A100C95B26 /* RCloudImageLoader.h in Headers */,
A68AFAE91CCEFF5B00F16B3D /* RCCallDetailMessageCell.h in Headers */,
A68AFAEB1CCEFF5B00F16B3D /* RCCallTipMessageCell.h in Headers */,
Expand Down Expand Up @@ -395,6 +402,7 @@
A6BE1B2F1CCEFAAC00FF6BF7 /* RCCallVideoMultiCallViewController.m in Sources */,
A6BE1B271CCEFAAC00FF6BF7 /* RCCallAudioMultiCallViewController.m in Sources */,
A6BE1B391CCEFAAC00FF6BF7 /* RCCallFloatingBoard.m in Sources */,
9CE36FD7200F5FDC0068263B /* RCCXCall.m in Sources */,
A6BE1B2D1CCEFAAC00FF6BF7 /* RCCallSingleCallViewController.m in Sources */,
A68AFAEA1CCEFF5B00F16B3D /* RCCallDetailMessageCell.m in Sources */,
F8D2904D1D2790E3002BFA65 /* RCCallKitExtensionModule.m in Sources */,
Expand Down
241 changes: 183 additions & 58 deletions ios-rongcallkit/RongCallKit/Controller/RCCallBaseViewController.m

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,16 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
if (![self.existUserIdList containsObject:userId]) {
if ([self.selectUserIds containsObject:userId]) {
[self.selectUserIds removeObject:userId];
} else {
} else if (userId) {
[self.selectUserIds addObject:userId];
}
[self updateRightButton];
}

[self.tableView reloadRowsAtIndexPaths:@[ indexPath ] withRowAnimation:UITableViewRowAnimationAutomatic];
[UIView performWithoutAnimation:^{
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];

}];
}

- (void)updateRightButton {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
self.remotePortraitView.hidden = YES;

self.remoteNameLabel.frame =
CGRectMake(RCCallHorizontalMargin, RCCallVerticalMargin,
CGRectMake(RCCallHorizontalMargin, RCCallVerticalMargin + RCCallStatusBarHeight,
self.view.frame.size.width - RCCallHorizontalMargin * 2, RCCallLabelHeight);
self.remoteNameLabel.hidden = NO;
self.remoteNameLabel.textAlignment = NSTextAlignmentCenter;
Expand Down Expand Up @@ -231,7 +231,7 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
} else {
self.subVideoView.frame =
CGRectMake(self.view.frame.size.width - RCCallHeaderLength - RCCallHorizontalMargin / 2,
RCCallVerticalMargin, RCCallHeaderLength, RCCallHeaderLength * 1.5);
RCCallVerticalMargin + RCCallStatusBarHeight, RCCallHeaderLength, RCCallHeaderLength * 1.5);
}
[self.callSession setVideoView:self.subVideoView
userId:[RCIMClient sharedRCIMClient].currentUserInfo.userId];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS

if (callStatus == RCCallActive) {
self.mainNameLabel.frame =
CGRectMake(RCCallHorizontalMargin, RCCallVerticalMargin,
CGRectMake(RCCallHorizontalMargin, RCCallVerticalMargin + RCCallStatusBarHeight,
self.view.frame.size.width - RCCallHorizontalMargin * 2, RCCallLabelHeight);
self.mainNameLabel.hidden = NO;
} else {
Expand All @@ -393,15 +393,15 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
(self.view.frame.size.height - RCCallLabelHeight) / 2);
if (callStatus == RCCallIncoming || callStatus == RCCallRinging) {
self.userCollectionTitleLabel.frame = CGRectMake(
RCCallHorizontalMargin, titleY, self.view.frame.size.width - RCCallHorizontalMargin * 2, RCCallLabelHeight);
RCCallHorizontalMargin, titleY - RCCallExtraSpace, self.view.frame.size.width - RCCallHorizontalMargin * 2, RCCallLabelHeight);
self.userCollectionTitleLabel.hidden = NO;
} else {
self.userCollectionTitleLabel.hidden = YES;
}

if (callStatus == RCCallIncoming || callStatus == RCCallRinging) {
self.userCollectionView.frame = CGRectMake(
RCCallHorizontalMargin * 2.5, titleY + RCCallLabelHeight + RCCallInsideMargin,
RCCallHorizontalMargin * 2.5, titleY + RCCallLabelHeight + RCCallInsideMargin - RCCallExtraSpace,
self.view.frame.size.width - RCCallHorizontalMargin * 5,
self.view.frame.size.height - RCCallVerticalMargin - RCCallButtonLength - RCCallInsideMargin * 4 -
RCCallLabelHeight - (titleY + RCCallLabelHeight + RCCallInsideMargin));
Expand All @@ -416,7 +416,7 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
self.userCollectionView.hidden = NO;
} else if (callStatus == RCCallDialing || (callStatus == RCCallActive && !self.isFullScreen)) {
self.userCollectionView.frame = CGRectMake(
0, self.view.frame.size.height - RCCallVerticalMargin - RCCallButtonLength * 3.5 - RCCallInsideMargin * 2,
0, self.view.frame.size.height - RCCallVerticalMargin - RCCallButtonLength * 3.5 - RCCallInsideMargin * 2 - RCCallExtraSpace,
self.view.frame.size.width, RCCallButtonLength * 2.5);

if (self.userCollectionViewLayout) {
Expand All @@ -429,7 +429,7 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
self.userCollectionView.hidden = NO;
} else if (callStatus == RCCallActive && self.isFullScreen) {
self.userCollectionView.frame =
CGRectMake(0, self.view.frame.size.height - RCCallInsideMargin - RCCallButtonLength * 2.5,
CGRectMake(0, self.view.frame.size.height - RCCallInsideMargin - RCCallButtonLength * 2.5 - RCCallExtraSpace,
self.view.frame.size.width, RCCallButtonLength * 2.5);
self.userCollectionView.hidden = NO;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ - (void)destroyModule {
- (void)didTapMessageCell:(RCMessageModel *)messageModel {
if ([messageModel.content isKindOfClass:[RCCallSummaryMessage class]]) {
RCCallSummaryMessage *callMessage = (RCCallSummaryMessage *)messageModel.content;
if (messageModel.conversationType == ConversationType_PRIVATE) {
// 其他端接听显示的消息不可点击
if (messageModel.conversationType == ConversationType_PRIVATE && callMessage.hangupReason != RCCallDisconnectReasonAcceptByOtherClient) {
[[RCCall sharedRCCall] startSingleCall:messageModel.targetId mediaType:callMessage.mediaType];
}
}
Expand Down
2 changes: 1 addition & 1 deletion ios-rongcallkit/RongCallKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.8.26</string>
<string>2.8.31</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
59 changes: 59 additions & 0 deletions ios-rongcallkit/RongCallKit/RCCXCall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// RCCXCall.h
// RongCallKit
//
// Created by LiFei on 2018/1/17.
// Copyright © 2018年 Rong Cloud. All rights reserved.
//

#import <Foundation/Foundation.h>

/*!
融云适配苹果 CallKit 核心类
*/
@interface RCCXCall : NSObject

/**
获取 RCCXCall 单例
@return RCCXCall 单例
*/
+ (instancetype)sharedInstance;

/*!
通知苹果 Callkit 开始呼出电话
@param userId 呼叫用户 id,如果是多人通话则传多个用户 id,以:::分隔
*/
- (void)startCall:(NSString *)userId;

/*!
通知苹果 Callkit 呼出电话已连接
*/
- (void)reportOutgoingCallConnected;

/**
通知苹果 Callkit 来电
@param inviterId 来电人用户 id
@param userIdList 被邀请者的 userId 列表。nil 表示单人通话
@param isVideo 是否视频通话。YES: video NO: audio
*/
- (void)reportIncomingCallWithInviter:(NSString *)inviterId
userIdList:(NSArray <NSString *> *)userIdList
isVideo:(BOOL)isVideo;

/*!
挂断苹果 Callkit 通话
*/
- (void)endCXCall;

/**
当系统来电接通时,如果没有激活苹果 Callkit 通话,则挂断 VOIP
@param UUID 系统来电 UUID
*/
- (void)hangupIfNeedWithUUID:(NSString *)UUID;
@end
188 changes: 188 additions & 0 deletions ios-rongcallkit/RongCallKit/RCCXCall.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
//
// RCCXCall.m
// RongCallKit
//
// Created by LiFei on 2018/1/17.
// Copyright © 2018年 Rong Cloud. All rights reserved.
//

#import "RCCXCall.h"
#import "RCCall.h"
#import "RCUserInfoCacheManager.h"
#import <CallKit/CallKit.h>
#import <AVFoundation/AVFoundation.h>
#import "RCCallKitUtility.h"

#define RCCXCallLocalizedName @"RongCloud"

@interface RCCXCall() <CXProviderDelegate>
@property(nonatomic, strong) CXProvider *provider;
@property(nonatomic, strong) NSUUID *currentUUID;
@property(nonatomic, strong) CXCallController *controller;
@end

@implementation RCCXCall

+ (instancetype)sharedInstance {
static RCCXCall *pCall;
static dispatch_once_t onceToken;
if (RC_IOS_SYSTEM_VERSION_LESS_THAN(@"10.0")) {
return nil;
}
dispatch_once(&onceToken, ^{
if (pCall == nil) {
pCall = [[RCCXCall alloc] init];
}
});
return pCall;
}

- (void)startCall:(NSString *)userId {
if (userId.length > 0) {
NSUUID *uuid = [NSUUID UUID];
self.currentUUID = uuid;
CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:[userId copy]];
CXStartCallAction *startAction = [[CXStartCallAction alloc] initWithCallUUID:uuid handle:handle];
NSArray *array = [userId componentsSeparatedByString:@":::"];
if (array.count == 1) {
startAction.contactIdentifier = [[RCUserInfoCacheManager sharedManager] getUserInfo:userId].name;
} else {
NSString *str = @"";
for (NSString *uId in array) {
NSString *name = [[RCUserInfoCacheManager sharedManager] getUserInfo:uId].name;
if (name.length > 0) {
str = [str stringByAppendingFormat:@"%@", name];
}
}
if (str.length > 0) {
str = [str substringToIndex:str.length - 1];
}
startAction.contactIdentifier = str;
}
CXTransaction *transaction = [[CXTransaction alloc] init];
[transaction addAction:startAction];
[self.controller requestTransaction:transaction completion:^(NSError * _Nullable error) {
}];
[self.provider reportOutgoingCallWithUUID:uuid startedConnectingAtDate:nil];
}
}

- (void)reportOutgoingCallConnected {
[self.provider reportOutgoingCallWithUUID:self.currentUUID connectedAtDate:nil];
}

- (void)reportIncomingCallWithInviter:(NSString *)inviterId
userIdList:(NSArray<NSString *> *)userIdList
isVideo:(BOOL)isVideo {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
NSUUID *uuid = [[NSUUID alloc] init];
self.currentUUID = uuid;
CXCallUpdate *update = [[CXCallUpdate alloc] init];
NSString *localizedCallerName = [[RCUserInfoCacheManager sharedManager] getUserInfo:inviterId].name;
NSString *handleValue = inviterId;
for (NSString *userId in userIdList) {
if ([userId isEqualToString:inviterId]) {
break;
}
NSString *name = [[RCUserInfoCacheManager sharedManager] getUserInfo:userId].name;
if (name.length > 0) {
localizedCallerName = [localizedCallerName stringByAppendingFormat:@"%@", name];
}
handleValue = [handleValue stringByAppendingFormat:@":::%@", userId];
}
update.localizedCallerName = localizedCallerName;
CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handleValue];
update.remoteHandle = handle;
if (isVideo) {
update.hasVideo = YES;
}
[self.provider reportNewIncomingCallWithUUID:uuid
update:update
completion:^(NSError * _Nullable error) {
if (error == nil) {
}
}];
}

- (void)endCXCall {
if (self.currentUUID) {
CXEndCallAction *endAction = [[CXEndCallAction alloc] initWithCallUUID:self.currentUUID];
CXTransaction *transaction = [[CXTransaction alloc] init];
[transaction addAction:endAction];
[self.controller requestTransaction:transaction completion:^(NSError * _Nullable error) {
self.currentUUID = nil;
}];
}
}

- (void)hangupIfNeedWithUUID:(NSString *)UUID {
if (UUID.length == 0) {
return;
}
if (![UUID isEqualToString:self.currentUUID.UUIDString]) {
[[RCCall sharedRCCall].currentCallSession hangup];
}
}

- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {
if ([self.currentUUID.UUIDString isEqualToString:action.callUUID.UUIDString]) {
[[RCCall sharedRCCall].currentCallSession accept:[RCCall sharedRCCall].currentCallSession.mediaType];
}
[action fulfill];
}

- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action {
if ([self.currentUUID.UUIDString isEqualToString:action.callUUID.UUIDString]) {
[[RCCall sharedRCCall].currentCallSession hangup];
self.currentUUID = nil;
}
[action fulfill];
}

- (void)provider:(CXProvider *)provider performStartCallAction:(CXStartCallAction *)action {
//startCall的时候设置action的contactIdentifier并不会更新通话记录中的名字,这段代码是为了更新通话记录
CXCallUpdate *update = [[CXCallUpdate alloc] init];
update.remoteHandle = action.handle;
update.localizedCallerName = action.contactIdentifier;
[self.provider reportCallWithUUID:action.callUUID updated:update];
[action fulfill];
}

- (void)providerDidReset:(CXProvider *)provider {
//info.plist里面没有打开后台VoIP模式的情况下,在startCall之后会走这个回调,导致呼出的电话被hangup
// if (self.currentUUID) {
// self.currentUUID = nil;
// if ([RCCall sharedRCCall].currentCallSession) {
// [[RCCall sharedRCCall].currentCallSession hangup];
// }
// }
}

- (CXProvider *)provider {
if (!_provider) {
NSString *name = [RCCall sharedRCCall].appLocalizedName;
if (name.length == 0) {
name = RCCXCallLocalizedName;
}
CXProviderConfiguration *config = [[CXProviderConfiguration alloc] initWithLocalizedName:name];
config.supportedHandleTypes = [NSSet setWithObject:@(CXHandleTypeGeneric)];
config.maximumCallGroups = 1;
config.maximumCallsPerCallGroup = 1;

UIImage *img = [RCCallKitUtility imageFromVoIPBundle:@"voip/callkit_app_icon.png"];
NSData *data = UIImagePNGRepresentation(img);
config.iconTemplateImageData = data;
_provider = [[CXProvider alloc] initWithConfiguration:config];
[_provider setDelegate:self queue:nil];
}
return _provider;
}

- (CXCallController *)controller {
if (!_controller) {
_controller = [[CXCallController alloc] init];
}
return _controller;
}

@end
Loading

0 comments on commit 1bdc054

Please sign in to comment.