Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4cbac5258e | |||
| 09e8d99999 | |||
| 573ed1ec4d | |||
| 9d46770715 | |||
| 259573e9f0 | |||
| e71411ea09 | |||
| 8c659fad60 | |||
| 8883c65d82 | |||
| 4df5fec911 | |||
| 8fc676be89 | |||
| 033beba9ea | |||
| d0f1afe4a7 | |||
| bf8130bf1e | |||
| 36ca1fcc80 | |||
| eb92d2173b | |||
| 4622c17257 | |||
| d1247acc99 | |||
| ba3044c709 | |||
| 4bff506491 | |||
| 17279f1da2 | |||
| da67615804 |
Regular → Executable
+6
-3
@@ -4,11 +4,14 @@
|
||||
### Siren Project Contributors
|
||||
- [Dmitry Bespalov](https://github.com/diamondsky) for [Pull Request #7](https://github.com/ArtSabintsev/Siren/pull/7)
|
||||
- [Daniel Bauke](https://github.com/bonkey) for [Pull Request #8](https://github.com/ArtSabintsev/Siren/pull/8)
|
||||
- [Jędrek Kostecki](https://github.com/jedrekk) for [Pull Request #10](https://github.com/ArtSabintsev/Siren/pull/10)
|
||||
|
||||
- [ipedro](https://github.com/ipedro) for [Pull Request #76 (Harpy)](https://github.com/ArtSabintsev/Harpy/pull/76)
|
||||
- [Michael Graff](http://github.com/skandragon) for [Pull Request #15](https://github.com/ArtSabintsev/Siren/pull/15)
|
||||
- [Jaroslav_](https://github.com/jaroslavas) for [Pull Request #83 (Harpy)](https://github.com/ArtSabintsev/Harpy/pull/83)
|
||||
- [Dylan Bettermann](https://github.com/dbettermann) for [Pull Request #18](https://github.com/ArtSabintsev/Siren/pull/18)
|
||||
- [Daniel](https://github.com/Daniel) for [Pull Request #21](https://github.com/ArtSabintsev/Siren/pull/21)
|
||||
|
||||
### Harpy Project Contributors
|
||||
This repo is a Swift language port of [Harpy](http://github.com/ArtSabintsev/Harpy). We couldn't have built this port without acknowledging the following developers who were instrumental in getting Harpy to its current state, v3.2.1 at the time this document was written.
|
||||
This repo is a Swift language port of [Harpy](http://github.com/ArtSabintsev/Harpy). We couldn't have built this port without acknowledging the following developers who were instrumental in getting Harpy to v3.2.1, the version of Harpy that Siren was based on.
|
||||
|
||||
A huge **Thank You** to the following developers:
|
||||
|
||||
|
||||
@@ -9,16 +9,19 @@
|
||||
If a new version is available, an alert can be presented to the user informing them of the newer version, and giving them the option to update the application. Alternatively, Siren can notify your app programmatically, enabling you to inform the user through alternative means, such as a custom interface.
|
||||
|
||||
- Siren is built to work with the [**Semantic Versioning**](http://semver.org/) system.
|
||||
- Semantic Versioning is a three number versioning system (e.g., 1.0.0)
|
||||
- Siren also supports two-number versioning (e.g., 1.0)
|
||||
- Siren also supports four-number versioning (e.g., 1.0.0.0)
|
||||
- Siren is a Swift language port of [**Harpy**](http://github.com/ArtSabintsev/Harpy), an Objective-C library that achieves the same functionality.
|
||||
- Siren is actively maintained by [**Arthur Sabintsev**](http://github.com/ArtSabintsev) and [**Aaron Brager**](http://twitter.com/getaaron).
|
||||
|
||||
### Changelog (v0.3.2)
|
||||
- Added Polish localization (thanks to [Jędrek Kostecki](https://github.com/jedrekk))
|
||||
### Changelog (v0.4.2)
|
||||
- Added Arabic localization
|
||||
|
||||
### Features
|
||||
- [x] CocoaPods Support
|
||||
- [x] Support for `UIAlertController` (iOS 8+) and `UIAlertView` (iOS 7)
|
||||
- [x] Localized for 19 languages (See **Localization** Section)
|
||||
- [x] Localized for 20 languages (See **Localization** Section)
|
||||
- [x] Three types of alerts (see **Screenshots & Alert Types**)
|
||||
- [x] Optional delegate methods (see **Optional Delegate** section)
|
||||
|
||||
@@ -29,6 +32,7 @@ If a new version is available, an alert can be presented to the user informing t
|
||||
pod 'Siren'
|
||||
```
|
||||
|
||||
- Add `import Siren` to any `.Swift` file that references Siren via a CocoaPods installation.
|
||||
- Requires [CocoaPods 0.36 prerelease](http://blog.cocoapods.org/Pod-Authors-Guide-to-CocoaPods-Frameworks/) or later
|
||||
- Only for apps with a minimum deployment target of iOS 8.0 or later
|
||||
|
||||
@@ -51,14 +55,11 @@ func application(application: UIApplication, didFinishLaunchingWithOptions launc
|
||||
/* Siren code should go below window?.makeKeyAndVisible() */
|
||||
|
||||
// Siren is a singleton
|
||||
let siren = Siren.SharedInstance
|
||||
let siren = Siren.sharedInstance
|
||||
|
||||
// Required: Your app's iTunes App Store ID
|
||||
siren.appID = <#Your_App_ID#>
|
||||
|
||||
// Required on iOS 8: The controller to present the alert from (usually the UIWindow's rootViewController)
|
||||
siren.presentingViewController = window?.rootViewController
|
||||
|
||||
// Optional: Defaults to .Option
|
||||
siren.alertType = <#SirenAlertType_Enum_Value#>
|
||||
|
||||
@@ -118,7 +119,7 @@ To control this behavior, assign a `SirenAlertType` to `alertType` (or one of th
|
||||
> ----
|
||||
> #### `siren.alertType = .None`
|
||||
>
|
||||
> This option doesn't show an alert view. It's useful for skipping Patch, Minor, or Major updates, or for presenting your own UI.
|
||||
> This option doesn't show an alert view. It's useful for skipping Revision, Patch, Minor, or Major updates, or for presenting your own UI.
|
||||
|
||||
### Prompting for Updates without Alerts
|
||||
|
||||
@@ -144,11 +145,12 @@ extension AppDelegate: SirenDelegate
|
||||
|
||||
Siren will call the `sirenDidDetectNewVersionWithoutAlert(message: String)` delegate method, passing a localized, suggested update string suitable for display. Implement this method to display your own messaging, optionally using `message`.
|
||||
|
||||
### Differentiated Alerts for Patch, Minor, and Major Updates
|
||||
If you would like to set a different type of alert for patch, minor, and/or major updates, simply add one or all of the following *optional* lines to your setup *before* calling the `checkVersion()` method:
|
||||
### Differentiated Alerts for Revision, Patch, Minor, and Major Updates
|
||||
If you would like to set a different type of alert for revision, patch, minor, and/or major updates, simply add one or all of the following *optional* lines to your setup *before* calling the `checkVersion()` method:
|
||||
|
||||
```swift
|
||||
/* Siren defaults to SirenAlertType.Option for all updates */
|
||||
siren.sharedInstance().revisionUpdateAlertType = <#SirenAlertType_Enum_Value#>
|
||||
siren.sharedInstance().patchUpdateAlertType = <#SirenAlertType_Enum_Value#>
|
||||
siren.sharedInstance().minorUpdateAlertType = <#SirenAlertType_Enum_Value#>
|
||||
siren.sharedInstance().majorUpdateAlertType = <#SirenAlertType_Enum_Value#>
|
||||
@@ -168,7 +170,7 @@ Five delegate methods allow you to handle or track the user's behavior:
|
||||
```
|
||||
|
||||
### Force Localization
|
||||
Siren supports 18 languages: Basque, Chinese (Simplified), Chinese (Traditional), Danish, Dutch, English, French, German, Hebrew, Italian, Japanese, Korean, Polish, Portuguese, Russian, Slovenian, Swedish, Spanish, and Turkish.
|
||||
Harpy is localized for Basque, Chinese (Simplified), Chinese (Traditional), Danish, Dutch, English, French, German, Hebrew, Italian, Japanese, Korean, Lithuanian, Polish, Portuguese (Brazil), Portuguese (Portugal), Russian, Slovenian, Swedish, Spanish, and Turkish.
|
||||
|
||||
You may want the update dialog to *always* appear in a certain language, ignoring iOS's language setting (e.g. apps released in a specific country).
|
||||
|
||||
@@ -177,8 +179,12 @@ You can enable it like this:
|
||||
```swift
|
||||
Siren.sharedInstance.forceLanguageLocalization = SirenLanguageType.<#SirenLanguageType_Enum_Value#>
|
||||
```
|
||||
### How to test Siren
|
||||
Temporarily change the version string in Xcode to an older version than the one that's currently available in the App Store. Afterwards, build and run your app, and you should see the alert.
|
||||
### Testing Siren
|
||||
Temporarily change the version string in Xcode (within the `.xcodeproj`) to an older version than the one that's currently available in the App Store. Afterwards, build and run your app, and you should see the alert.
|
||||
|
||||
If you currently don't have an app in the store, use the **AppID** for the iTunes Connect App (376771144), or any other app, and temporarily change the version string in `.xcodeproj` to an older version than the one that's currently available in the App Store.
|
||||
|
||||
For your convenience, you may turn on `printn()` debugging statements by setting `self.debugEnabled = true` before calling the `checkVersion()` method.
|
||||
|
||||
### App Store Submissions
|
||||
The App Store reviewer will **not** see the alert. The version in the App Store will always be older than the version being reviewed.
|
||||
|
||||
Regular → Executable
+2
-2
@@ -260,7 +260,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Sample App/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_NAME = "Sample App";
|
||||
};
|
||||
@@ -271,7 +271,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Sample App/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_NAME = "Sample App";
|
||||
};
|
||||
|
||||
Generated
Regular → Executable
Regular → Executable
+11
-9
@@ -24,26 +24,28 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
func setupSiren() {
|
||||
|
||||
|
||||
let siren = Siren.sharedInstance
|
||||
|
||||
// Required
|
||||
siren.appID = "376771144" // For this example, we're using the iTunes Connect App (https://itunes.apple.com/us/app/itunes-connect/id376771144?mt=8)
|
||||
|
||||
// Required
|
||||
siren.presentingViewController = window?.rootViewController
|
||||
|
||||
// Optional
|
||||
siren.delegate = self
|
||||
|
||||
// Optional
|
||||
siren.debugEnabled = true;
|
||||
|
||||
// Optional
|
||||
siren.alertType = .Option
|
||||
// Optional - Defaults to .Option
|
||||
// siren.alertType = .Option
|
||||
|
||||
// Optional
|
||||
// siren.forceLanguageLocalization = .Spanish // Optional: Sets all messages to appear in Spanish. Siren supports many other languages, not just English and Spanish.
|
||||
// Optional - Can set differentiated Alerts for Major, Minor, Patch, and Revision Updates
|
||||
siren.majorUpdateAlertType = .Option
|
||||
siren.minorUpdateAlertType = .Option
|
||||
siren.patchUpdateAlertType = .Option
|
||||
siren.revisionUpdateAlertType = .Option
|
||||
|
||||
// Optional - Sets all messages to appear in Spanish. Siren supports many other languages, not just English and Spanish.
|
||||
// siren.forceLanguageLocalization = .Spanish
|
||||
|
||||
// Required
|
||||
siren.checkVersion(.Immediately)
|
||||
@@ -69,7 +71,7 @@ extension AppDelegate: SirenDelegate
|
||||
}
|
||||
|
||||
/**
|
||||
This method is only hit when alertType is initialized to .None
|
||||
This delegate method is only hit when alertType is initialized to .None
|
||||
*/
|
||||
func sirenDidDetectNewVersionWithoutAlert(message: String) {
|
||||
println("\(message)")
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+2
@@ -33,6 +33,8 @@
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
Regular → Executable
+1
-2
@@ -19,7 +19,6 @@ class ViewController: UIViewController {
|
||||
super.didReceiveMemoryWarning()
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Regular → Executable
+2
-2
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Siren"
|
||||
s.version = "0.3.2"
|
||||
s.version = "0.4.2"
|
||||
s.summary = "Notify users when a new version of your iOS app is available, and prompt them with the App Store link.."
|
||||
|
||||
s.description = <<-DESC
|
||||
@@ -15,7 +15,7 @@ Siren is actively maintained by Arthur Sabintsev and Aaron Brager.
|
||||
s.license = "MIT"
|
||||
s.authors = { "Arthur Sabintsev" => "arthur@sabintsev.com", "Aaron Brager" => "getaaron@gmail.com" }
|
||||
s.platform = :ios, "8.0"
|
||||
s.source = { :git => "https://github.com/ArtSabintsev/Siren.git", :tag => "0.3.2" }
|
||||
s.source = { :git => "https://github.com/ArtSabintsev/Siren.git", :tag => s.version.to_s }
|
||||
s.source_files = 'Siren/Siren.swift'
|
||||
s.resources = 'Siren/Siren.bundle'
|
||||
s.requires_arc = true
|
||||
|
||||
BIN
Binary file not shown.
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+14
@@ -0,0 +1,14 @@
|
||||
/* Update alert message: A new version of {APP NAME} is available. Please update to version {NEW VERSION} now.*/
|
||||
"A new version of %@ is available. Please update to version %@ now." = "Atsirado nauja %@ versija. Prašome atsinaujinti iki %@ versijos.";
|
||||
|
||||
/* Update alert title */
|
||||
"Update Available" = "Atnaujinimas";
|
||||
|
||||
/* Update alert dismiss button title */
|
||||
"Next time" = "Kitą kartą";
|
||||
|
||||
/* Update alert skip button title */
|
||||
"Skip this version" = "Praleisti šią versiją";
|
||||
|
||||
/* Update alert skip button title */
|
||||
"Update" = "Atnaujinti";
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
BIN
Binary file not shown.
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+65
-57
@@ -9,7 +9,7 @@
|
||||
import UIKit
|
||||
|
||||
// MARK: SirenDelegate Protocol
|
||||
@objc protocol SirenDelegate {
|
||||
@objc public protocol SirenDelegate {
|
||||
optional func sirenDidShowUpdateDialog() // User presented with update dialog
|
||||
optional func sirenUserDidLaunchAppStore() // User did click on button that launched App Store.app
|
||||
optional func sirenUserDidSkipVersion() // User did click on button that skips version update
|
||||
@@ -56,30 +56,11 @@ public enum SirenVersionCheckType : Int
|
||||
|
||||
By default, the operating system's default lanuage setting is used. However, you can force a specific language
|
||||
by setting the forceLanguageLocalization property before calling checkVersion()
|
||||
|
||||
Supported languages:
|
||||
- Basque
|
||||
- ChineseSimplified
|
||||
- ChineseTraditional
|
||||
- Danish
|
||||
- Dutch
|
||||
- English
|
||||
- French
|
||||
- Hebrew
|
||||
- German
|
||||
- Italian
|
||||
- Japanese
|
||||
- Korean
|
||||
- Portuguese
|
||||
- Russian
|
||||
- Slovenian
|
||||
- Spanish
|
||||
- Swedish
|
||||
- Turkish
|
||||
|
||||
*/
|
||||
public enum SirenLanguageType: String
|
||||
{
|
||||
case Arabic = "ar"
|
||||
case Basque = "eu"
|
||||
case ChineseSimplified = "zh-Hans"
|
||||
case ChineseTraditional = "zh-Hant"
|
||||
@@ -92,8 +73,10 @@ public enum SirenLanguageType: String
|
||||
case Italian = "it"
|
||||
case Japanese = "ja"
|
||||
case Korean = "ko"
|
||||
case Lithuanian = "lt"
|
||||
case Polish = "pl"
|
||||
case Portuguese = "pt"
|
||||
case PortugueseBrazil = "pt"
|
||||
case PortuguesePortugal = "pt-PT"
|
||||
case Russian = "ru"
|
||||
case Slovenian = "sl"
|
||||
case Spanish = "es"
|
||||
@@ -136,14 +119,14 @@ public class Siren: NSObject
|
||||
- sirenDidDetectNewVersionWithoutAlert(message: String)
|
||||
|
||||
*/
|
||||
weak var delegate: SirenDelegate?
|
||||
public weak var delegate: SirenDelegate?
|
||||
|
||||
/**
|
||||
The debug flag, which is disabled by default.
|
||||
|
||||
When enabled, a stream of println() statements are logged to your console when a version check is performed.
|
||||
*/
|
||||
lazy var debugEnabled = false
|
||||
public lazy var debugEnabled = false
|
||||
|
||||
// Alert Vars
|
||||
/**
|
||||
@@ -151,7 +134,7 @@ public class Siren: NSObject
|
||||
|
||||
See the SirenAlertType enum for full details.
|
||||
*/
|
||||
var alertType = SirenAlertType.Option
|
||||
public var alertType = SirenAlertType.Option
|
||||
|
||||
/**
|
||||
Determines the type of alert that should be shown for major version updates: A.b.c
|
||||
@@ -160,7 +143,7 @@ public class Siren: NSObject
|
||||
|
||||
See the SirenAlertType enum for full details.
|
||||
*/
|
||||
var majorUpdateAlertType = SirenAlertType.Option
|
||||
public var majorUpdateAlertType = SirenAlertType.Option
|
||||
|
||||
/**
|
||||
Determines the type of alert that should be shown for minor version updates: a.B.c
|
||||
@@ -169,7 +152,7 @@ public class Siren: NSObject
|
||||
|
||||
See the SirenAlertType enum for full details.
|
||||
*/
|
||||
var minorUpdateAlertType = SirenAlertType.Option
|
||||
public var minorUpdateAlertType = SirenAlertType.Option
|
||||
|
||||
/**
|
||||
Determines the type of alert that should be shown for minor patch updates: a.b.C
|
||||
@@ -178,22 +161,22 @@ public class Siren: NSObject
|
||||
|
||||
See the SirenAlertType enum for full details.
|
||||
*/
|
||||
var patchUpdateAlertType = SirenAlertType.Option
|
||||
public var patchUpdateAlertType = SirenAlertType.Option
|
||||
|
||||
/**
|
||||
Determines the type of alert that should be shown for revision updates: a.b.c.D
|
||||
|
||||
Defaults to SirenAlertType.Option.
|
||||
|
||||
See the SirenAlertType enum for full details.
|
||||
*/
|
||||
public var revisionUpdateAlertType = SirenAlertType.Option
|
||||
|
||||
// Required Vars
|
||||
/**
|
||||
The App Store / iTunes Connect ID for your app.
|
||||
*/
|
||||
var appID: String?
|
||||
|
||||
/**
|
||||
The view controller that will present the instance of UIAlertController.
|
||||
|
||||
It is recommended that you set this value to window?.rootViewController.
|
||||
|
||||
This property must be set before calling checkVersion().
|
||||
*/
|
||||
var presentingViewController: UIViewController?
|
||||
public var appID: String?
|
||||
|
||||
// Optional Vars
|
||||
/**
|
||||
@@ -201,7 +184,7 @@ public class Siren: NSObject
|
||||
|
||||
By default, it's set to the name of the app that's stored in your plist.
|
||||
*/
|
||||
lazy var appName: String = (NSBundle.mainBundle().infoDictionary?[kCFBundleNameKey] as? String) ?? ""
|
||||
public lazy var appName: String = (NSBundle.mainBundle().infoDictionary?[kCFBundleNameKey] as? String) ?? ""
|
||||
|
||||
/**
|
||||
The region or country of an App Store in which your app is available.
|
||||
@@ -210,23 +193,24 @@ public class Siren: NSObject
|
||||
If your app is not available in the US App Store, you should set it to the identifier
|
||||
of at least one App Store within which it is available.
|
||||
*/
|
||||
var countryCode: String?
|
||||
public var countryCode: String?
|
||||
|
||||
/**
|
||||
Overrides the default localization of a user's device when presenting the update message and button titles in the alert.
|
||||
|
||||
See the SirenLanguageType enum for more details.
|
||||
*/
|
||||
var forceLanguageLocalization: SirenLanguageType?
|
||||
public var forceLanguageLocalization: SirenLanguageType?
|
||||
|
||||
/**
|
||||
Overrides the tint color for UIAlertController.
|
||||
*/
|
||||
var alertControllerTintColor: UIColor?
|
||||
public var alertControllerTintColor: UIColor?
|
||||
|
||||
// Private
|
||||
private var lastVersionCheckPerformedOnDate: NSDate?
|
||||
private var currentAppStoreVersion: String?
|
||||
private var updaterWindow: UIWindow!
|
||||
|
||||
// MARK: Initialization
|
||||
public class var sharedInstance: Siren {
|
||||
@@ -249,12 +233,10 @@ public class Siren: NSObject
|
||||
|
||||
:param: checkType The frequency in days in which you want a check to be performed. Please refer to the SirenVersionCheckType enum for more details.
|
||||
*/
|
||||
func checkVersion(checkType: SirenVersionCheckType) {
|
||||
public func checkVersion(checkType: SirenVersionCheckType) {
|
||||
|
||||
if (appID == nil) {
|
||||
println("[Siren] Please make sure that you have set 'appID' before calling checkVersion.")
|
||||
} else if (useAlertController && presentingViewController == nil) { // iOS 8 only
|
||||
println("[Siren] Please make sure that you have set 'presentingViewController' before calling checkVersion.")
|
||||
} else {
|
||||
if checkType == .Immediately {
|
||||
performVersionCheck()
|
||||
@@ -352,7 +334,8 @@ public class Siren: NSObject
|
||||
}
|
||||
|
||||
// MARK: Alert
|
||||
private extension Siren {
|
||||
private extension Siren
|
||||
{
|
||||
func showAlertIfCurrentAppStoreVersionNotSkipped() {
|
||||
|
||||
self.alertType = self.setAlertType()
|
||||
@@ -394,7 +377,7 @@ private extension Siren {
|
||||
}
|
||||
|
||||
if alertType != .None {
|
||||
presentingViewController?.presentViewController(alertController, animated: true, completion: nil)
|
||||
alertController.show()
|
||||
}
|
||||
|
||||
} else { // iOS 7
|
||||
@@ -426,6 +409,7 @@ private extension Siren {
|
||||
func updateAlertAction() -> UIAlertAction {
|
||||
let title = localizedUpdateButtonTitle()
|
||||
let action = UIAlertAction(title: title, style: .Default) { (alert: UIAlertAction!) -> Void in
|
||||
self.hideWindow()
|
||||
self.launchAppStore()
|
||||
self.delegate?.sirenUserDidLaunchAppStore?()
|
||||
return
|
||||
@@ -437,6 +421,7 @@ private extension Siren {
|
||||
func nextTimeAlertAction() -> UIAlertAction {
|
||||
let title = localizedNextTimeButtonTitle()
|
||||
let action = UIAlertAction(title: title, style: .Default) { (alert: UIAlertAction!) -> Void in
|
||||
self.hideWindow()
|
||||
self.delegate?.sirenUserDidCancel?()
|
||||
return
|
||||
}
|
||||
@@ -447,6 +432,7 @@ private extension Siren {
|
||||
func skipAlertAction() -> UIAlertAction {
|
||||
let title = localizedSkipButtonTitle()
|
||||
let action = UIAlertAction(title: title, style: .Default) { (alert: UIAlertAction!) -> Void in
|
||||
self.hideWindow()
|
||||
self.delegate?.sirenUserDidSkipVersion?()
|
||||
return
|
||||
}
|
||||
@@ -456,8 +442,8 @@ private extension Siren {
|
||||
}
|
||||
|
||||
// MARK: Helpers
|
||||
private extension Siren {
|
||||
|
||||
private extension Siren
|
||||
{
|
||||
func iTunesURLFromString() -> NSURL {
|
||||
|
||||
var storeURLString = "https://itunes.apple.com/lookup?id=\(appID!)"
|
||||
@@ -505,19 +491,26 @@ private extension Siren {
|
||||
let oldVersion = split(currentInstalledVersion!) {$0 == "."}.map {$0.toInt() ?? 0}
|
||||
let newVersion = split(currentAppStoreVersion!) {$0 == "."}.map {$0.toInt() ?? 0}
|
||||
|
||||
if oldVersion.count == 3 && newVersion.count == 3 {
|
||||
if newVersion[0] > oldVersion[0] { // A.b.c
|
||||
if 2...4 ~= oldVersion.count && oldVersion.count == newVersion.count {
|
||||
if newVersion[0] > oldVersion[0] { // A.b[.c][.d]
|
||||
alertType = majorUpdateAlertType
|
||||
} else if newVersion[1] > oldVersion[1] { // a.B.c
|
||||
} else if newVersion[1] > oldVersion[1] { // a.B[.c][.d]
|
||||
alertType = minorUpdateAlertType
|
||||
} else if newVersion[2] > oldVersion[2] { // a.b.C
|
||||
} else if newVersion.count > 2 && newVersion[2] > oldVersion[2] { // a.b.C[.d]
|
||||
alertType = patchUpdateAlertType
|
||||
} else if newVersion.count > 3 && newVersion[3] > oldVersion[3] { // a.b.c.D
|
||||
alertType = revisionUpdateAlertType
|
||||
}
|
||||
}
|
||||
|
||||
return alertType
|
||||
}
|
||||
|
||||
func hideWindow() {
|
||||
updaterWindow.hidden = true
|
||||
updaterWindow = nil
|
||||
}
|
||||
|
||||
// iOS 8 Compatibility Check
|
||||
var useAlertController: Bool { // iOS 8 check
|
||||
return objc_getClass("UIAlertController") != nil
|
||||
@@ -531,9 +524,24 @@ private extension Siren {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: String Localization
|
||||
private extension Siren {
|
||||
// MARK: UIAlertController
|
||||
private extension UIAlertController
|
||||
{
|
||||
func show() {
|
||||
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
|
||||
window.rootViewController = UIViewController()
|
||||
window.windowLevel = UIWindowLevelAlert + 1
|
||||
|
||||
Siren.sharedInstance.updaterWindow = window
|
||||
|
||||
window.makeKeyAndVisible()
|
||||
window.rootViewController!.presentViewController(self, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: String Localization
|
||||
private extension Siren
|
||||
{
|
||||
func localizedNewVersionMessage() -> String {
|
||||
|
||||
let newVersionMessageToLocalize = "A new version of %@ is available. Please update to version %@ now."
|
||||
@@ -557,8 +565,8 @@ private extension Siren {
|
||||
}
|
||||
|
||||
// MARK: NSBundle Extension
|
||||
private extension NSBundle {
|
||||
|
||||
private extension NSBundle
|
||||
{
|
||||
func currentInstalledVersion() -> String? {
|
||||
return NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as? String
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user