Commit 2040e188 authored by Jose Blaya's avatar Jose Blaya

Update library for Account module 1.1.0

parent 66e56ded
......@@ -147,9 +147,10 @@ public protocol AccountProvider: class {
/**
Returns the available messages from the API.
- Parameter version: App version.
- Parameter callback: Returns the message`InAppMessage` on success.
*/
func inAppMessages(_ callback: LibraryCallback<InAppMessage>?)
func inAppMessages(forAppVersion version: String, _ callback: LibraryCallback<InAppMessage>?)
#if os(iOS)
/**
......
......@@ -78,7 +78,7 @@ extension InAppMessage {
self.settingAction = actions
self.settingLink = nil
self.settingView = nil
} else if !link.action.uri.isEmpty {
} else if let uri = link.action.uri, !uri.isEmpty {
self.type = .link
self.settingLink = link.action.uri
self.settingAction = nil
......
......@@ -74,5 +74,5 @@ protocol WebServices: class {
// MARK: Messages
func messages(_ callback: LibraryCallback<InAppMessage>?)
func messages(forAppVersion version: String, _ callback: LibraryCallback<InAppMessage>?)
}
......@@ -330,8 +330,8 @@ class DefaultAccountProvider: AccountProvider, ConfigurationAccess, DatabaseAcce
}
}
func inAppMessages(_ callback: LibraryCallback<InAppMessage>?) {
webServices.messages { (message, error) in
func inAppMessages(forAppVersion version: String, _ callback: LibraryCallback<InAppMessage>?) {
webServices.messages(forAppVersion: version) { (message, error) in
callback?(message, error)
}
}
......
......@@ -434,11 +434,11 @@ class PIAWebServices: WebServices, ConfigurationAccess {
}
// MARK: Messages
func messages(_ callback: LibraryCallback<InAppMessage>?) {
func messages(forAppVersion version: String, _ callback: LibraryCallback<InAppMessage>?) {
if let token = Client.providers.accountProvider.token {
self.accountAPI.message(token: token, callback: { (message, error) in
self.accountAPI.message(token: token, appVersion: version, callback: { (message, error) in
if let error = error {
callback?(nil, ClientError.malformedResponseData)
......
......@@ -310,8 +310,8 @@ public class MockAccountProvider: AccountProvider, WebServicesConsumer {
callback?(nil)
}
public func inAppMessages(_ callback: LibraryCallback<InAppMessage>?) {
delegate.inAppMessages { (message, error) in
public func inAppMessages(forAppVersion version: String, _ callback: LibraryCallback<InAppMessage>?) {
delegate.inAppMessages(forAppVersion: version) { (message, error) in
callback?(message, error)
}
}
......
......@@ -137,7 +137,7 @@ class MockWebServices: WebServices {
callback?(["mock-test"], nil)
}
func messages(_ callback: LibraryCallback<InAppMessage>?) {
func messages(forAppVersion version: String, _ callback: LibraryCallback<InAppMessage>?) {
let testLink = InAppMessage(withMessage: ["en" : "This is a message"], id: "1", link: ["en" : "message"], type: .link, level: .api, actions: nil, view: nil, uri: "https://www.privateinternetaccess.com")
callback?(testLink, nil)
......
......@@ -119,9 +119,6 @@ extension Macros {
/**
Returns a localized full version string.
- Parameter format: A localized format string with two `String` parameters:
- The first one is replaced with the x.y.z version
- The second one is replaced with the build number
- Returns: A localized full version string built upon the input `format`
*/
public static func localizedVersionFullString() -> String? {
......@@ -132,6 +129,17 @@ extension Macros {
let buildNumber = info[kCFBundleVersionKey as String] as! String
return L10n.Ui.Global.Version.format(versionNumber, buildNumber)
}
/**
Returns a localized version number string. Example "3.9.0"
*/
public static func localizedVersionNumber() -> String {
guard let info = Bundle.main.infoDictionary else {
return ""
}
let versionNumber = info["CFBundleShortVersionString"] as! String
return versionNumber
}
/**
Shortcut to create a `PopupDialog`.
......
......@@ -434,7 +434,7 @@ class EphemeralAccountProvider: AccountProvider, ProvidersAccess, InAppAccess {
callback?(nil)
}
func inAppMessages(_ callback: LibraryCallback<InAppMessage>?) {
func inAppMessages(forAppVersion version: String, _ callback: LibraryCallback<InAppMessage>?) {
callback?(nil, nil)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment