Skip to content

Commit

Permalink
Merge pull request #86 from sendbird/release/1.4.1
Browse files Browse the repository at this point in the history
Release 1.4.1
  • Loading branch information
mininny committed Dec 11, 2020
2 parents e7ca663 + 84c3117 commit 047b03a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
8 changes: 4 additions & 4 deletions QuickStart.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4.0;
MARKETING_VERSION = 1.4.1;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart;
PRODUCT_NAME = "Sendbird Calls";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -922,7 +922,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4.0;
MARKETING_VERSION = 1.4.1;
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.4.0;
MARKETING_VERSION = 1.4.1;
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.4.0;
MARKETING_VERSION = 1.4.1;
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart.QuickStartIntent;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
12 changes: 9 additions & 3 deletions QuickStart/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// 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)

// Configure your app id here to designate a specific app id for the application.
// let appId = YOUR_APP_ID
// SendBirdCall.configure(appId: appId)
// UserDefaults.standard.designatedAppId = appId

self.autoSignIn { error in
if error == nil { return }
Expand Down Expand Up @@ -81,8 +85,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

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

// Authenticate
let authParams = AuthenticateParams(userId: credential.userId, accessToken: credential.accessToken)
Expand Down
3 changes: 2 additions & 1 deletion QuickStart/Extensions/UIKit/UIStoryboard+QuickStart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ extension UIStoryboard {

extension UIStoryboard {
static func signController() -> UIViewController {
let controller = (SendBirdCall.appId != nil ? QuickStart.simpleSignIn : QuickStart.signIn).controller
let hasConfiguredAppId = (UserDefaults.standard.credential?.appId != nil || UserDefaults.standard.designatedAppId != nil)
let controller = (hasConfiguredAppId ? QuickStart.simpleSignIn : QuickStart.signIn).controller
if #available(iOS 13.0, *) {
controller.isModalInPresentation = true
}
Expand Down
8 changes: 7 additions & 1 deletion QuickStart/Extensions/UserDefaults+QuickStart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension UserDefaults {
case credential
case voipPushToken
case callHistories
case designatedAppId

var value: String { "com.sendbird.calls.quickstart.\(self.rawValue.lowercased())" }
}
Expand All @@ -35,12 +36,17 @@ extension UserDefaults {
get { UserDefaults.standard.get(objectType: [CallHistory].self, forKey: Key.callHistories.value) ?? [] }
set { UserDefaults.standard.set(object: newValue, forKey: Key.callHistories.value) }
}

var designatedAppId: String? {
get { UserDefaults.standard.value(forKey: Key.designatedAppId.value) as? String }
set { UserDefaults.standard.setValue(newValue, forKey: Key.designatedAppId.value) }
}
}

extension UserDefaults {
func clear() {
Key.allCases
.filter { $0 != .voipPushToken }
.filter { $0 != .voipPushToken && $0 != .designatedAppId }
.map { $0.value }
.forEach(UserDefaults.standard.removeObject)
}
Expand Down

0 comments on commit 047b03a

Please sign in to comment.