Skip to content

Commit

Permalink
Merge pull request #81 from sendbird/release/1.4.0
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
Jaesung committed Nov 10, 2020
2 parents 9ed7f06 + 39cf099 commit 85cbb51
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 26 deletions.
12 changes: 6 additions & 6 deletions QuickStart.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = QuickStart/QuickStart.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = RM4A5PXTUX;
EXCLUDED_ARCHS = "";
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -892,7 +892,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart;
PRODUCT_NAME = "Sendbird Calls";
SWIFT_VERSION = 5.0;
Expand All @@ -909,7 +909,7 @@
CODE_SIGN_ENTITLEMENTS = QuickStart/QuickStart.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = RM4A5PXTUX;
EXCLUDED_ARCHS = "";
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -922,7 +922,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart;
PRODUCT_NAME = "Sendbird Calls";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -944,7 +944,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart.QuickStartIntent;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -967,7 +967,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart.QuickStartIntent;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
12 changes: 10 additions & 2 deletions QuickStart/AppDelegate+SendBirdCallsDelegates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ extension AppDelegate: SendBirdCallDelegate, DirectCallDelegate {
update.hasVideo = call.isVideoCall
update.localizedCallerName = call.caller?.userId ?? "Unknown"

// Report the incoming call to the system
CXCallManager.shared.reportIncomingCall(with: uuid, update: update)
if SendBirdCall.getOngoingCallCount() > 1 {
// Allow only one ongoing call.
CXCallManager.shared.reportIncomingCall(with: uuid, update: update) { _ in
CXCallManager.shared.endCall(for: uuid, endedAt: Date(), reason: .declined)
}
call.end()
} else {
// Report the incoming call to the system
CXCallManager.shared.reportIncomingCall(with: uuid, update: update)
}
}

// MARK: DirectCallDelegate
Expand Down
5 changes: 3 additions & 2 deletions QuickStart/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// MARK: SendBirdCall.configure(appId:)
// See [here](https://github.com/sendbird/quickstart-calls-ios#creating-a-sendbird-application) for the application ID.
// If you want to sign in with QR code, don't configure your app ID in code.
// SendBirdCall.configure(appId: YOUR_APP_ID)

self.autoSignIn { error in
Expand Down Expand Up @@ -80,8 +81,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

func authenticate(with credential: Credential, completionHandler: @escaping (Error?) -> Void) {
// Configure app ID before authenticate
SendBirdCall.configure(appId: credential.appId)
// Configure app ID before authenticate when there is no configured app ID
if SendBirdCall.appId == nil { SendBirdCall.configure(appId: credential.appId) }

// Authenticate
let authParams = AuthenticateParams(userId: credential.userId, accessToken: credential.accessToken)
Expand Down
35 changes: 25 additions & 10 deletions QuickStart/CXExtensions/CXCallManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,33 @@ extension CXCallManager: CXProviderDelegate {
return
}

// For decline
if call.endResult == DirectCallEndResult.none || call.endResult == .unknown {
SendBirdCall.authenticateIfNeed { [weak call] (error) in
guard let call = call, error == nil else {
action.fail()
return
var backgroundTaskID: UIBackgroundTaskIdentifier = .invalid

// For decline in background
DispatchQueue.global().async {
backgroundTaskID = UIApplication.shared.beginBackgroundTask {
UIApplication.shared.endBackgroundTask(backgroundTaskID)
backgroundTaskID = .invalid
}

if call.endResult == DirectCallEndResult.none || call.endResult == .unknown {
SendBirdCall.authenticateIfNeed { [weak call] (error) in
guard let call = call, error == nil else {
action.fail()
return
}

call.end {
action.fulfill()

// End background task
UIApplication.shared.endBackgroundTask(backgroundTaskID)
backgroundTaskID = .invalid
}
}

call.end { action.fulfill() }
} else {
action.fulfill()
}
} else {
action.fulfill()
}
}

Expand Down
1 change: 1 addition & 0 deletions QuickStart/CXExtensions/CXProvider+QuickStart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extension CXProviderConfiguration {
// and update correct type of call log in Recents
providerConfiguration.supportsVideo = true
providerConfiguration.maximumCallsPerCallGroup = 1
providerConfiguration.maximumCallGroups = 1
providerConfiguration.supportedHandleTypes = [.generic]

// Set up ringing sound
Expand Down
2 changes: 1 addition & 1 deletion QuickStart/CallHistory/CallHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct CallHistory: Codable {

self.startedAt = CallHistory.dateFormatter.string(from: Date(timeIntervalSince1970: Double(callLog.startedAt) / 1000))
self.duration = callLog.duration.durationText()
self.endResult = callLog.endResult.rawValue
self.endResult = CallStatus.ended(result: callLog.endResult.rawValue).message
}
}

Expand Down
11 changes: 8 additions & 3 deletions QuickStart/Dial/CallStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ enum CallStatus {

var message: String {
switch self {
case .connecting: return "call connecting..."
case .muted(let user): return "\(user) is muted"
case .ended(let result): return result.replacingOccurrences(of: "_", with: " ")
case .connecting:
return "call connecting..."
case .muted(let user):
return "\(user) is muted"
case .ended(let result):
return result
.replacingOccurrences(of: "_", with: " ")
.capitalizingFirstLetter()
}
}
}
4 changes: 4 additions & 0 deletions QuickStart/Extensions/String+QuickStart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ extension String {
return self.trimmed
}
}

public func capitalizingFirstLetter() -> String {
return prefix(1).capitalized + dropFirst()
}
}

extension Optional where Wrapped == String {
Expand Down
6 changes: 4 additions & 2 deletions QuickStart/Extensions/UserDefaults+QuickStart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ extension UserDefaults {

extension UserDefaults {
func clear() {
let keys = Key.allCases.filter { $0 != .voipPushToken }
keys.map { $0.value }.forEach(UserDefaults.standard.removeObject)
Key.allCases
.filter { $0 != .voipPushToken }
.map { $0.value }
.forEach(UserDefaults.standard.removeObject)
}
}

Expand Down

0 comments on commit 85cbb51

Please sign in to comment.