Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 19f303535c | |||
| cdfae11e70 |
@@ -1,6 +1,8 @@
|
||||
language: objective-c
|
||||
osx_image: xcode9.3
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
env:
|
||||
- LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8
|
||||
before_install:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
### Notify users when a new version of your app is available and prompt them to upgrade.
|
||||
|
||||

|
||||

|
||||
|
||||
 
|
||||
|
||||
@@ -214,24 +214,39 @@ If you would like to set a different type of alert for revision, patch, minor, a
|
||||
Six delegate methods allow you to handle or track the user's behavior. Each method has a default, empty implementation, effectively making each of these methods optional.
|
||||
|
||||
``` swift
|
||||
public protocol SirenDelegate: class {
|
||||
// User presented with update dialog
|
||||
func sirenDidShowUpdateDialog(alertType: Siren.AlertType)
|
||||
public protocol SirenDelegate: NSObjectProtocol {
|
||||
/// Siren performed version check and did not display alert.
|
||||
func sirenDidDetectNewVersionWithoutAlert(message: String, updateType: UpdateType)
|
||||
|
||||
// User did click on button that launched App Store.app
|
||||
func sirenUserDidLaunchAppStore()
|
||||
/// Siren failed to perform version check.
|
||||
///
|
||||
/// - Note:
|
||||
/// Depending on the reason for failure,
|
||||
/// a system-level error may be returned.
|
||||
func sirenDidFailVersionCheck(error: Error)
|
||||
|
||||
// User did click on button that skips version update
|
||||
func sirenUserDidSkipVersion()
|
||||
/// User presented with update dialog.
|
||||
func sirenDidShowUpdateDialog(alertType: Siren.AlertType)
|
||||
|
||||
// User did click on button that cancels update dialog
|
||||
func sirenUserDidCancel()
|
||||
|
||||
// Siren failed to perform version check (may return system-level error)
|
||||
func sirenDidFailVersionCheck(error: Error)
|
||||
/// Siren performed a version check and latest version is installed.
|
||||
func sirenLatestVersionInstalled()
|
||||
|
||||
// Siren performed version check and did not display alert
|
||||
func sirenDidDetectNewVersionWithoutAlert(message: String, updateType: UpdateType)
|
||||
/// Provides the decoded JSON information from a successful version check call.
|
||||
///
|
||||
/// - SeeAlso:
|
||||
/// SirenLookupModel.swift
|
||||
///
|
||||
/// - Parameter lookupModel: The `Decodable` model representing the JSON results from the iTunes Lookup API.
|
||||
func sirenNetworkCallDidReturnWithNewVersionInformation(lookupModel: SirenLookupModel)
|
||||
|
||||
/// User did click on button that cancels update dialog.
|
||||
func sirenUserDidCancel()
|
||||
|
||||
/// User did click on button that launched "App Store.app".
|
||||
func sirenUserDidLaunchAppStore()
|
||||
|
||||
/// User did click on button that skips version update.
|
||||
func sirenUserDidSkipVersion()
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
# Version
|
||||
s.version = "3.3.2"
|
||||
s.version = "3.4.0"
|
||||
s.swift_version = '4.1'
|
||||
|
||||
# Meta
|
||||
|
||||
@@ -102,6 +102,10 @@ extension AppDelegate: SirenDelegate
|
||||
print(#function, "Latest version of app is installed")
|
||||
}
|
||||
|
||||
func sirenNetworkCallDidReturnWithNewVersionInformation(lookupModel: SirenLookupModel) {
|
||||
print(#function, "\(lookupModel)")
|
||||
}
|
||||
|
||||
// This delegate method is only hit when alertType is initialized to .none
|
||||
func sirenDidDetectNewVersionWithoutAlert(message: String, updateType: UpdateType) {
|
||||
print(#function, "\(message).\nRelease type: \(updateType.rawValue.capitalized)")
|
||||
|
||||
@@ -194,6 +194,8 @@ private extension Siren {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.printMessage("Decoded JSON results: \(decodedData)")
|
||||
|
||||
self?.delegate?.sirenNetworkCallDidReturnWithNewVersionInformation(lookupModel: decodedData)
|
||||
|
||||
// Process Results (e.g., extract current version that is available on the AppStore)
|
||||
self?.processVersionCheck(with: decodedData)
|
||||
}
|
||||
|
||||
+37
-28
@@ -31,17 +31,8 @@ public enum UpdateType: String {
|
||||
|
||||
/// Delegate that handles all codepaths for Siren upon version check completion.
|
||||
public protocol SirenDelegate: NSObjectProtocol {
|
||||
/// User presented with update dialog.
|
||||
func sirenDidShowUpdateDialog(alertType: Siren.AlertType)
|
||||
|
||||
/// User did click on button that launched "App Store.app".
|
||||
func sirenUserDidLaunchAppStore()
|
||||
|
||||
/// User did click on button that skips version update.
|
||||
func sirenUserDidSkipVersion()
|
||||
|
||||
/// User did click on button that cancels update dialog.
|
||||
func sirenUserDidCancel()
|
||||
/// Siren performed version check and did not display alert.
|
||||
func sirenDidDetectNewVersionWithoutAlert(message: String, updateType: UpdateType)
|
||||
|
||||
/// Siren failed to perform version check.
|
||||
///
|
||||
@@ -50,30 +41,32 @@ public protocol SirenDelegate: NSObjectProtocol {
|
||||
/// a system-level error may be returned.
|
||||
func sirenDidFailVersionCheck(error: Error)
|
||||
|
||||
/// Siren performed version check and did not display alert.
|
||||
func sirenDidDetectNewVersionWithoutAlert(message: String, updateType: UpdateType)
|
||||
/// User presented with update dialog.
|
||||
func sirenDidShowUpdateDialog(alertType: Siren.AlertType)
|
||||
|
||||
/// Siren performed version check and latest version is installed.
|
||||
/// Siren performed a version check and latest version is installed.
|
||||
func sirenLatestVersionInstalled()
|
||||
|
||||
/// Provides the decoded JSON information from a successful version check call.
|
||||
///
|
||||
/// - Parameter lookupModel: The `Decodable` model representing the JSON results from the iTunes Lookup API.
|
||||
func sirenNetworkCallDidReturnWithNewVersionInformation(lookupModel: SirenLookupModel)
|
||||
|
||||
/// User did click on button that cancels update dialog.
|
||||
func sirenUserDidCancel()
|
||||
|
||||
/// User did click on button that launched "App Store.app".
|
||||
func sirenUserDidLaunchAppStore()
|
||||
|
||||
/// User did click on button that skips version update.
|
||||
func sirenUserDidSkipVersion()
|
||||
}
|
||||
|
||||
// MARK: - SirenDelegate Protocol Extension
|
||||
|
||||
public extension SirenDelegate {
|
||||
|
||||
func sirenDidShowUpdateDialog(alertType: Siren.AlertType) {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
func sirenUserDidLaunchAppStore() {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
func sirenUserDidSkipVersion() {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
func sirenUserDidCancel() {
|
||||
func sirenDidDetectNewVersionWithoutAlert(message: String, updateType: UpdateType) {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
@@ -81,7 +74,7 @@ public extension SirenDelegate {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
func sirenDidDetectNewVersionWithoutAlert(message: String, updateType: UpdateType) {
|
||||
func sirenDidShowUpdateDialog(alertType: Siren.AlertType) {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
@@ -89,6 +82,22 @@ public extension SirenDelegate {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
func sirenUserDidCancel() {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
func sirenUserDidLaunchAppStore() {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
func sirenNetworkCallDidReturnWithNewVersionInformation(lookupModel: SirenLookupModel) {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
func sirenUserDidSkipVersion() {
|
||||
printMessage()
|
||||
}
|
||||
|
||||
private func printMessage(_ function: String = #function) {
|
||||
SirenLog("The default implementation of \(function) is being called. You can ignore this message if you do not care to implement this method in your `SirenDelegate` conforming structure.")
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ import Foundation
|
||||
|
||||
// MARK: - Model representing a selection of results from the iTunes Lookup API
|
||||
|
||||
struct SirenLookupModel: Decodable {
|
||||
public struct SirenLookupModel: Decodable {
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case results
|
||||
}
|
||||
|
||||
let results: [Results]
|
||||
public let results: [Results]
|
||||
|
||||
struct Results: Decodable {
|
||||
public struct Results: Decodable {
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case appID = "trackId"
|
||||
case currentVersionReleaseDate
|
||||
@@ -26,10 +26,10 @@ struct SirenLookupModel: Decodable {
|
||||
case version
|
||||
}
|
||||
|
||||
let appID: Int
|
||||
let currentVersionReleaseDate: String
|
||||
let minimumOSVersion: String
|
||||
let releaseNotes: String?
|
||||
let version: String
|
||||
public let appID: Int
|
||||
public let currentVersionReleaseDate: String
|
||||
public let minimumOSVersion: String
|
||||
public let releaseNotes: String?
|
||||
public let version: String
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user