Skip to content

Commit

Permalink
Merge pull request #52 from sendbird/release/1.1.1
Browse files Browse the repository at this point in the history
Version 1.1.1 (Merge to master)
  • Loading branch information
Jaesung authored Jun 30, 2020
2 parents 999ca08 + 00a769c commit 8ea77cb
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 74 deletions.
10 changes: 6 additions & 4 deletions QuickStart.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = QuickStart/QuickStart.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 18;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = RM4A5PXTUX;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -799,7 +799,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart;
PRODUCT_NAME = "SendBird Calls";
SWIFT_VERSION = 5.0;
Expand All @@ -816,7 +816,7 @@
CODE_SIGN_ENTITLEMENTS = QuickStart/QuickStart.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 18;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = RM4A5PXTUX;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -828,7 +828,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart;
PRODUCT_NAME = "SendBird Calls";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -849,6 +849,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart.QuickStartIntent;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -870,6 +871,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart.QuickStartIntent;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
4 changes: 3 additions & 1 deletion QuickStart/CallHistory/CallHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ struct CallHistory: Codable {
let hasVideo: Bool
let remoteUserProfileURL: String?
let remoteUserID: String
let remoteNickname: String
let duration: String
let endResult: String
let startedAt: String

static var dateFormatter: DateFormatter {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "YYYY/MM/d HH:mm"
dateFormatter.dateFormat = "YYYY/MM/dd HH:mm"
return dateFormatter
}

Expand All @@ -34,6 +35,7 @@ struct CallHistory: Codable {
let remoteUser = callLog.myRole == .caller ? callLog.callee : callLog.caller
self.remoteUserProfileURL = remoteUser?.profileURL
self.remoteUserID = remoteUser?.userId ?? "Unknown"
self.remoteNickname = remoteUser?.nickname ?? ""

self.startedAt = CallHistory.dateFormatter.string(from: Date(timeIntervalSince1970: Double(callLog.startedAt) / 1000))
self.duration = callLog.duration.timerText()
Expand Down
8 changes: 4 additions & 4 deletions QuickStart/CallHistory/CallHistoryTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class CallHistoryTableViewCell: UITableViewCell {

@IBOutlet weak var remoteUserProfileImageView: UIImageView!

@IBOutlet weak var remoteNicknameLabel: UILabel!
@IBOutlet weak var remoteUserIDLabel: UILabel!
@IBOutlet weak var startedAtLabel: UILabel!
@IBOutlet weak var callDurationLabel: UILabel!
@IBOutlet weak var endResultLabel: UILabel!

@IBOutlet weak var voiceCallButton: UIButton!
Expand All @@ -37,11 +37,11 @@ class CallHistoryTableViewCell: UITableViewCell {
self.callTypeImageView.image = UIImage.callTypeImage(outgoing: self.callHistory.outgoing, hasVideo: self.callHistory.hasVideo)
self.remoteUserProfileImageView.updateImage(urlString: self.callHistory.remoteUserProfileURL)

self.remoteUserIDLabel.text = self.callHistory.remoteUserID
self.remoteNicknameLabel.text = self.callHistory.remoteNickname
self.remoteUserIDLabel.text = "User ID: " + self.callHistory.remoteUserID

self.startedAtLabel.text = self.callHistory.startedAt
self.callDurationLabel.text = self.callHistory.duration
self.endResultLabel.text = self.callHistory.endResult
self.endResultLabel.text = self.callHistory.endResult + " · " + self.callHistory.duration
}

@IBAction func didTapVoiceCall() {
Expand Down
2 changes: 1 addition & 1 deletion QuickStart/CallHistory/CallHistoryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class CallHistoryViewController: UIViewController, UITableViewDataSource, UITabl
extension CallHistoryViewController {
// When select table view cell, make a call based on its `CallHistory` information.
func didTapCallHistoryCell(_ cell: CallHistoryTableViewCell) {
guard let remoteUserID = cell.remoteUserIDLabel.text else { return }
guard let remoteUserID = cell.remoteNicknameLabel.text else { return }
let isVideoCall = cell.callHistory.hasVideo
let dialParams = DialParams(calleeId: remoteUserID,
isVideoCall: isVideoCall,
Expand Down
9 changes: 7 additions & 2 deletions QuickStart/Dial/DialViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ class DialViewController: UIViewController, UITextFieldDelegate {
self.profileImageView.updateImage(urlString: profileURL)
}
}
@IBOutlet weak var userIdLabel: UILabel! {
@IBOutlet weak var nicknameLabel: UILabel! {
didSet {
self.userIdLabel.text = UserDefaults.standard.user.id
self.nicknameLabel.text = UserDefaults.standard.user.name.unwrap(with: "-")
}
}
@IBOutlet weak var userIDLabel: UILabel! {
didSet {
self.userIDLabel.text = "User ID: " + UserDefaults.standard.user.id
}
}

Expand Down
20 changes: 13 additions & 7 deletions QuickStart/Dial/VideoCallViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ class VideoCallViewController: UIViewController, DirectCallDataSource {
@IBOutlet weak var callStatusLabel: UILabel!
@IBOutlet weak var mutedStateLabel: UILabel! {
didSet {
self.mutedStateLabel.text = "\(self.call.remoteUser?.userId ?? "Remote user") is on mute"
guard let remoteUser = self.call.remoteUser else { return }
let name = remoteUser.nickname?.isEmptyOrWhitespace == true ? remoteUser.userId : remoteUser.nickname!
self.mutedStateLabel.text = "\(name) is on mute"
}
}
@IBOutlet weak var remoteUserIdLabel: UILabel! {
@IBOutlet weak var remoteNicknameLabel: UILabel! {
didSet {
self.remoteUserIdLabel.text = self.call.remoteUser?.userId
let nickname = self.call.remoteUser?.nickname
self.remoteNicknameLabel.text = nickname?.isEmptyOrWhitespace == true ? self.call.remoteUser?.userId : nickname
}
}

Expand Down Expand Up @@ -77,7 +80,7 @@ class VideoCallViewController: UIViewController, DirectCallDataSource {
}

// Constraints of remote user ID
@IBOutlet weak var topSpaceRemoteUserId: NSLayoutConstraint!
@IBOutlet weak var topSpaceRemoteNickname: NSLayoutConstraint!

var call: DirectCall!
var isDialing: Bool?
Expand Down Expand Up @@ -112,9 +115,9 @@ class VideoCallViewController: UIViewController, DirectCallDataSource {
func setupEndedCallUI() {
// Tell user that the call has been ended.
self.callStatusLabel.text = "Call Ended"
self.topSpaceRemoteUserId.constant = 244
self.topSpaceRemoteNickname.constant = 244
self.callStatusLabel.isHidden = false
self.remoteUserIdLabel.isHidden = false
self.remoteNicknameLabel.isHidden = false
self.remoteProfileImageView.isHidden = false

// Release resource
Expand Down Expand Up @@ -286,7 +289,7 @@ extension VideoCallViewController {
extension VideoCallViewController: DirectCallDelegate {
// MARK: Required Methods
func didConnect(_ call: DirectCall) {
self.remoteUserIdLabel.isHidden = true
self.remoteNicknameLabel.isHidden = true
self.callStatusLabel.isHidden = true
self.updateRemoteAudio(isEnabled: call.isRemoteAudioEnabled)

Expand Down Expand Up @@ -329,5 +332,8 @@ extension VideoCallViewController: DirectCallDelegate {
self.audioRouteButton.setBackgroundImage(.audio(output: output.portType),
for: .normal)
print("[QuickStart] Audio Route has been changed to \(output.portName)")

// Disable to display `AVAudioPickerView` (also `MPVolumeView`) when it is speaker mode.
self.audioRouteButton.isEnabled = output.portType != .builtInSpeaker
}
}
8 changes: 6 additions & 2 deletions QuickStart/Dial/VoiceCallViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class VoiceCallViewController: UIViewController, DirectCallDataSource {
}
@IBOutlet weak var nameLabel: UILabel! {
didSet {
self.nameLabel.text = self.call.remoteUser?.userId
let nickname = self.call.remoteUser?.nickname
self.nameLabel.text = nickname?.isEmptyOrWhitespace == true ? self.call.remoteUser?.userId : nickname
}
}

Expand All @@ -38,7 +39,10 @@ class VoiceCallViewController: UIViewController, DirectCallDataSource {
@IBOutlet weak var mutedStateImageView: UIImageView!
@IBOutlet weak var mutedStateLabel: UILabel! {
didSet {
self.mutedStateLabel.text = "\(self.call.remoteUser?.userId ?? "Remote user") is on mute"
guard let remoteUser = self.call.remoteUser else { return }
let name = remoteUser.nickname?.isEmptyOrWhitespace == true ? remoteUser.userId : remoteUser.nickname!

self.mutedStateLabel.text = "\(name) is on mute"
}
}

Expand Down
8 changes: 4 additions & 4 deletions QuickStart/Extensions/Int64+QuickStart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ extension Int64 {
// update UI
var timeText = [String]()

if hour > 0 { timeText.append(String(hour)) }
timeText.append(String(format: "%02d", minute))
timeText.append(String(format: "%02d", second))
if hour > 0 { timeText.append(String(hour) + "h") }
if minute > 0 { timeText.append(String(format: "%02d", minute) + "m") }
timeText.append(String(format: "%02d", second) + "s")

return timeText.joined(separator: ":")
return timeText.joined(separator: " ")
}
}
17 changes: 17 additions & 0 deletions QuickStart/Extensions/String+QuickStart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,20 @@ extension String {
}
}
}


extension Optional where Wrapped == String {
/// Unwraps optional value with replacement.
///
/// - Parameters:
/// - replacement: When the unwrapped value is invalid(`nil` or empty `String`), this method will return replacement.
/// - checkWhiteSpace: The value for checking white space.
///
/// - Note: Set `checkWhiteSpace` to `false` when you don't want to check white space of nickname.
func unwrap(with replacement: String, checkWhiteSpace: Bool = true) -> String {
guard let unwrappedValue = self else { return replacement }
// Check empty string or whitespace if needed
if checkWhiteSpace, unwrappedValue.isEmptyOrWhitespace { return replacement }
return unwrappedValue
}
}
20 changes: 15 additions & 5 deletions QuickStart/Settings/SettingsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ class SettingsTableViewController: UITableViewController {
}
@IBOutlet weak var usernameLabel: UILabel! {
didSet {
self.usernameLabel.text = UserDefaults.standard.user.name
self.usernameLabel.text = UserDefaults.standard.user.name.unwrap(with: "-")
}
}
@IBOutlet weak var userIdLabel: UILabel! {
didSet {
self.userIdLabel.text = UserDefaults.standard.user.id
self.userIdLabel.text = "User ID " + UserDefaults.standard.user.id
}
}

@IBOutlet weak var versionLabel: UILabel! {
didSet {
let sampleVersion = Bundle.main.version
self.versionLabel.text = "QuickStart \(sampleVersion) Calls SDK \(SendBirdCall.sdkVersion)"
}
}

Expand Down Expand Up @@ -72,10 +79,13 @@ extension SettingsTableViewController {
guard let token = UserDefaults.standard.voipPushToken else { return }

// MARK: SendBirdCall Deauthenticate
SendBirdCall.deauthenticate(voipPushToken: token) { error in
SendBirdCall.unregisterVoIPPush(token: token) { error in
// Handle error
if let error = error { print("[QuickStart]" + error.localizedDescription) }

UserDefaults.standard.clear()
guard error == nil else { return }

SendBirdCall.deauthenticate { _ in }
}
}
}

Loading

0 comments on commit 8ea77cb

Please sign in to comment.