Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.2.2 #832

Merged
merged 12 commits into from
Nov 6, 2023
4 changes: 2 additions & 2 deletions GliaWidgets.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GliaWidgets'
s.version = '2.2.1'
s.version = '2.2.2'
s.summary = 'The Glia iOS Widgets library'
s.description = 'The Glia Widgets library allows to integrate easily a UI/UX for Glia\'s Digital Customer Service platform'
s.homepage = 'https://github.com/salemove/ios-sdk-widgets'
Expand All @@ -19,5 +19,5 @@ Pod::Spec.new do |s|
}
s.exclude_files = ['GliaWidgets/Window/**']

s.dependency 'GliaCoreSDK', '1.1.5'
s.dependency 'GliaCoreSDK', '1.1.6'
end
44 changes: 44 additions & 0 deletions GliaWidgets.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion GliaWidgets/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>2.2.1</string>
<string>2.2.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
304 changes: 152 additions & 152 deletions GliaWidgets/Localization.swift

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions GliaWidgets/Public/Configuration/Configuration+Mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ extension Configuration {
authMethod: AuthorizationMethod = .siteApiKey(id: "site-api-key-id", secret: "site-api-key-secret"),
environment: Environment = .beta,
site: String = "site-id",
companyName: String = ""
companyName: String = "",
manualLocaleOverride: String? = nil
) -> Self {
Configuration(
authorizationMethod: authMethod,
environment: environment,
site: site,
companyName: companyName
companyName: companyName,
manualLocaleOverride: manualLocaleOverride
)
}
}
Expand Down
10 changes: 8 additions & 2 deletions GliaWidgets/Public/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,27 @@ public struct Configuration {
public let isWhiteLabelApp: Bool
/// Company name. Appears during connection with operator.
public let companyName: String
/// The name of the manual locale override. If not set, or if set as `nil`,
/// then the default locale from site settings will be used.
public var manualLocaleOverride: String?
/// Initializes the configuration.
///
/// - Parameters:
/// - authorizationMethod: The site authorization method.
/// - environment: The environment to use.
/// - site: The site to use.
/// - visitorContext: Additional context about the visitor that operator may need.
///
/// - manualLocaleOverride: The name of the manual locale override.
/// If not set, or if set as `nil`, then the default locale from site settings will be used.
public init(
authorizationMethod: AuthorizationMethod,
environment: Environment,
site: String,
visitorContext: VisitorContext? = nil,
pushNotifications: PushNotifications = .disabled,
isWhiteLabelApp: Bool = false,
companyName: String = ""
companyName: String = "",
manualLocaleOverride: String? = nil
) {
self.authorizationMethod = authorizationMethod
self.environment = environment
Expand All @@ -41,6 +46,7 @@ public struct Configuration {
self.pushNotifications = pushNotifications
self.isWhiteLabelApp = isWhiteLabelApp
self.companyName = companyName
self.manualLocaleOverride = manualLocaleOverride
}
}

Expand Down
39 changes: 19 additions & 20 deletions GliaWidgets/Public/Glia/Glia+StartEngagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension Glia {
/// - `GliaError.engagementExists
/// - `GliaError.sdkIsNotConfigured`
///
/// - Important: Note, that `configure(with:queueID:visitorContext:)` must be called initially prior to this method,
/// - Important: Note, that `configure(with:uiConfig:assetsBuilder:completion:)` must be called initially prior to this method,
/// because `GliaError.sdkIsNotConfigured` will occur otherwise.
///
public func startEngagement(
Expand All @@ -28,31 +28,30 @@ extension Glia {
features: Features = .all,
sceneProvider: SceneProvider? = nil
) throws {
// `interactor?.queueIds.isEmpty == false` statement is needed for integrators who uses old interface
// and pass queue identifier through `configuration` function.
guard !queueIds.isEmpty || interactor?.queueIds.isEmpty == false else { throw GliaError.startingEngagementWithNoQueueIdsIsNotAllowed }
let trimmedQueueIds = queueIds
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
.filter { !$0.isEmpty }
guard !trimmedQueueIds.isEmpty else { throw GliaError.startingEngagementWithNoQueueIdsIsNotAllowed }
guard engagement == .none else { throw GliaError.engagementExists }
guard let interactor = self.interactor else { throw GliaError.sdkIsNotConfigured }
guard let configuration = self.configuration else { throw GliaError.sdkIsNotConfigured }
if let engagement = environment.coreSdk.getCurrentEngagement(),
engagement.source == .callVisualizer {
throw GliaError.callVisualizerEngagementExists
}

// This check is needed for integrators who uses old interface
// and pass queue identifier through `configuration` function,
// but would not pass queue ids in this method, so SDK would not override
// existed queue id.
if !queueIds.isEmpty {
interactor.queueIds = queueIds
}
// Creates interactor instance
let createdInteractor = setupInteractor(
configuration: configuration,
queueIds: trimmedQueueIds
)

theme.chat.connect.queue.firstText = companyName(
using: interactor,
using: configuration,
themeCompanyName: theme.chat.connect.queue.firstText
)

theme.call.connect.queue.firstText = companyName(
using: interactor,
using: configuration,
themeCompanyName: theme.call.connect.queue.firstText
)

Expand All @@ -71,7 +70,7 @@ extension Glia {
)

startRootCoordinator(
with: interactor,
with: createdInteractor,
viewFactory: viewFactory,
sceneProvider: sceneProvider,
engagementKind: engagementKind,
Expand All @@ -80,7 +79,7 @@ extension Glia {
}

func companyName(
using interactor: Interactor,
using configuration: Configuration,
themeCompanyName: String?
) -> String {
let companyNameStringKey = "general.company_name"
Expand All @@ -98,8 +97,8 @@ extension Glia {
}
// Integrator has not set a company name in the custom locale,
// but has set it on the configuration.
else if !interactor.configuration.companyName.isEmpty {
return interactor.configuration.companyName
else if !configuration.companyName.isEmpty {
return configuration.companyName
}
// Integrator has not set a company name anywhere, use the default.
else {
Expand Down Expand Up @@ -141,7 +140,6 @@ extension Glia {
submitSurveyAnswer: environment.coreSdk.submitSurveyAnswer,
uiApplication: environment.uiApplication,
uiScreen: environment.uiScreen,
uiDevice: environment.uiDevice,
notificationCenter: environment.notificationCenter,
fetchChatHistory: environment.coreSdk.fetchChatHistory,
listQueues: environment.coreSdk.listQueues,
Expand All @@ -165,7 +163,8 @@ extension Glia {
stopSocketObservation: environment.coreSdk.stopSocketObservation,
pushNotifications: environment.coreSdk.pushNotifications,
createSendMessagePayload: environment.coreSdk.createSendMessagePayload,
orientationManager: environment.orientationManager
orientationManager: environment.orientationManager,
proximityManager: environment.proximityManager
)
)
rootCoordinator?.delegate = { [weak self] event in
Expand Down
91 changes: 56 additions & 35 deletions GliaWidgets/Public/Glia/Glia.Deprecated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import GliaCoreSDK

extension Glia {
/// Deprecated.
@available(*, unavailable, message: "Use configure(with:queueId:uiConfig:assetsBuilder:completion:) instead.")
@available(*, unavailable, message: "Use configure(with:uiConfig:assetsBuilder:completion:) instead.")
public func configure(
with configuration: Configuration,
queueId: String,
Expand Down Expand Up @@ -91,42 +91,20 @@ extension Glia {
}

/// Deprecated, use ``Glia.configure(with:uiConfig:assetsBuilder:completion)`` instead.
@available(*, deprecated, message: "Deprecated, use ``Glia.configure(with:uiConfig:assetsBuilder:completion`` instead.")
@available(*, deprecated, message: "Deprecated, use ``Glia.configure(with:uiConfig:assetsBuilder:completion:)`` instead.")
public func configure(
with configuration: Configuration,
queueId: String,
uiConfig: RemoteConfiguration? = nil,
assetsBuilder: RemoteConfiguration.AssetsBuilder = .standard,
completion: (() -> Void)? = nil
) throws {
guard environment.coreSdk.getCurrentEngagement() == nil else {
throw GliaError.configuringDuringEngagementIsNotAllowed
}
self.uiConfig = uiConfig
self.assetsBuilder = assetsBuilder

let createdInteractor = Interactor(
configuration: configuration,
queueIds: [queueId],
environment: .init(coreSdk: environment.coreSdk, gcd: environment.gcd)
try configure(
with: configuration,
uiConfig: uiConfig,
assetsBuilder: assetsBuilder,
completion: completion
)

interactor = createdInteractor

if let callback = completion {
createdInteractor.withConfiguration { [weak createdInteractor, weak self] in
guard let createdInteractor, let self else { return }

self.stringProviding = .init(getRemoteString: self.environment.coreSdk.localeProvider.getRemoteString)

createdInteractor.state = self.environment.coreSdk
.getCurrentEngagement()?.engagedOperator
.map(InteractorState.engaged) ?? createdInteractor.state
callback()
}
}

startObservingInteractorEvents()
}

/// Deprecated, use ``Glia.startEngagement(engagementKind:in:theme:features:sceneProvider:)`` instead.
Expand All @@ -149,11 +127,11 @@ extension Glia {
)
}

/// Deprecated, use ``Deprecated, use ``Glia.configure(with:uiConfig:assetsBuilder:completion`` and ``Glia.startEngagement(engagementKind:in:theme:features:sceneProvider:)`` instead.`` instead.
/// Deprecated, use ``Glia.configure(with:uiConfig:assetsBuilder:completion:)`` and ``Glia.startEngagement(engagementKind:in:theme:features:sceneProvider:)`` instead.
@available(*,
deprecated,
message: """
Deprecated, use ``Glia.configure(with:uiConfig:assetsBuilder:completion`` and \
Deprecated, use ``Glia.configure(with:uiConfig:assetsBuilder:completion:)`` and \
``Glia.startEngagement(engagementKind:in:theme:features:sceneProvider:)`` instead.
"""
)
Expand All @@ -168,22 +146,65 @@ extension Glia {
let completion = { [weak self] in
try self?.startEngagement(
engagementKind: engagementKind,
in: [queueID],
theme: theme,
features: features,
sceneProvider: sceneProvider
)
}
do {
try configure(
with: configuration,
queueId: queueID
) {
try configure(with: configuration) {
try? completion()
}
} catch GliaError.configuringDuringEngagementIsNotAllowed {
try completion()
}
}

/// Deprecated, use ``Glia.startEngagementWithConfig(engagement:in:uiConfig:assetsBuilder:features:sceneProvider:)`` instead.
@available(*,
deprecated,
message: """
Deprecated, use ``Glia.startEngagementWithConfig(engagement:in:uiConfig:assetsBuilder:features:sceneProvider:)`` instead.
"""
)
public func startEngagementWithConfig(
engagement: EngagementKind,
uiConfig: RemoteConfiguration,
assetsBuilder: RemoteConfiguration.AssetsBuilder = .standard,
features: Features = .all,
sceneProvider: SceneProvider? = nil
) throws {
try startEngagementWithConfig(
engagement: engagement,
in: [],
uiConfig: uiConfig,
assetsBuilder: assetsBuilder,
features: features,
sceneProvider: sceneProvider
)
}

/// Deprecated, use the `configure` method that provides a `Result` in its completion instead.
@available(*, deprecated, message: "Use the `configure` method that provides a `Result` in its completion instead.")
public func configure(
with configuration: Configuration,
uiConfig: RemoteConfiguration? = nil,
assetsBuilder: RemoteConfiguration.AssetsBuilder = .standard,
completion: (() -> Void)? = nil
) throws {
try configure(
with: configuration,
uiConfig: uiConfig,
assetsBuilder: assetsBuilder
) { result in
defer {
completion?()
}
guard case let .failure(error) = result else { return }
debugPrint("💥 Core SDK configuration is not valid. Unexpected error='\(error)'.")
}
}
}

extension Glia.Authentication {
Expand Down
7 changes: 5 additions & 2 deletions GliaWidgets/Public/Glia/Glia.RemoteConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extension Glia {
///
/// - Parameters:
/// - engagementKind: Engagement media type.
/// - in: Queue identifiers
/// - uiConfig: Remote UI configuration.
/// - assetsBuilder: Provides assets for remote configuration.
/// - features: Set of features to be enabled in the SDK.
Expand All @@ -17,11 +18,12 @@ extension Glia {
/// - `GliaError.engagementExists
/// - `GliaError.sdkIsNotConfigured`
///
/// - Important: Note, that `configure(with:queueID:visitorContext:)` must be called initially prior to this method,
/// - Important: Note, that `configure(with:uiConfig:assetsBuilder:completion:)` must be called initially prior to this method,
/// because `GliaError.sdkIsNotConfigured` will occur otherwise.
///
public func startEngagementWithConfig(
engagement: EngagementKind,
in queueIds: [String],
uiConfig: RemoteConfiguration,
assetsBuilder: RemoteConfiguration.AssetsBuilder = .standard,
features: Features = .all,
Expand All @@ -38,14 +40,15 @@ extension Glia {
uiConfig: uiConfig,
assetsBuilder: assetsBuilder
)
if let config = interactor?.configuration {
if let config = configuration {
theme.showsPoweredBy = !config.isWhiteLabelApp
theme.chat.connect.queue.firstText = config.companyName
theme.call.connect.queue.firstText = config.companyName
}

try startEngagement(
engagementKind: engagement,
in: queueIds,
theme: theme,
features: features,
sceneProvider: sceneProvider
Expand Down
Loading