Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 36ca1fcc80 | |||
| eb92d2173b | |||
| 4622c17257 | |||
| d1247acc99 | |||
| ba3044c709 | |||
| 4bff506491 | |||
| 17279f1da2 | |||
| da67615804 | |||
| 6a94c4f4e5 | |||
| 2afe920c86 | |||
| 7f8c2a6fb1 | |||
| 1463428c8c | |||
| 8021367f54 | |||
| af139d649c | |||
| 8ba1ac7fb3 | |||
| 133bfd4088 | |||
| 0f0c7bbbd2 | |||
| b5a9cd6fd1 | |||
| bb8916f598 | |||
| de7f6654e2 | |||
| 6c5b0e3318 | |||
| 37cb67d979 | |||
| 0194a691c9 |
+6
-3
@@ -1,11 +1,14 @@
|
||||
### Created and maintained by
|
||||
[Arthur Ariel Sabintsev](http://www.sabintsev.com/) and [Aaron Brager](http://twitter.com/GetAaron)
|
||||
|
||||
### Swift Project Contributors
|
||||
Open up a Pull Request to get your name on here.
|
||||
### 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)
|
||||
- [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)
|
||||
|
||||
### 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:
|
||||
|
||||
|
||||
@@ -12,15 +12,16 @@ If a new version is available, an alert can be presented to the user informing t
|
||||
- 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
|
||||
#### 0.2.2
|
||||
- Fixed [Issue #6](https://github.com/ArtSabintsev/Siren/issues/6): Setting `checkType` to `.Daily` or `.Weekly` now works properly.
|
||||
- Other minor internal changes.
|
||||
### Changelog (v0.3.4)
|
||||
- Fixes scoping issue with .framework that's generated via CocoaPods installation
|
||||
- Conversation: [Issue #13](https://github.com/ArtSabintsev/Siren/issues/13)
|
||||
- Pull Request: [PR #15](https://github.com/ArtSabintsev/Siren/pull/15)
|
||||
- Massive thanks to [Michael Graff](http://github.com/skandragon)!
|
||||
|
||||
### Features
|
||||
- [x] CocoaPods Support
|
||||
- [x] Support for `UIAlertController` (iOS 8+) and `UIAlertView` (iOS 7)
|
||||
- [x] Localized for 18 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)
|
||||
|
||||
@@ -31,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
|
||||
|
||||
@@ -53,7 +55,7 @@ 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#>
|
||||
@@ -170,7 +172,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, Portuguese, Russian, Slovenian, Swedish, Spanish, and Turkish.
|
||||
Harpy supports 20 languages: Basque, Chinese (Simplified), Chinese (Traditional), Danish, Dutch, English, French, German, Hebrew, Italian, Japanese, Korean, 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).
|
||||
|
||||
@@ -179,8 +181,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.
|
||||
|
||||
@@ -43,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
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.
|
||||
// siren.forceLanguageLocalization = .Spanish // Optional: Sets all messages to appear in Spanish. Siren supports many other languages, not just English and Spanish.
|
||||
|
||||
// Required
|
||||
siren.checkVersion(.Immediately)
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Siren"
|
||||
s.version = "0.2.2"
|
||||
s.version = "0.3.4"
|
||||
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.2.2" }
|
||||
s.source = { :git => "https://github.com/ArtSabintsev/Siren.git", :tag => "0.3.4" }
|
||||
s.source_files = 'Siren/Siren.swift'
|
||||
s.resources = 'Siren/Siren.bundle'
|
||||
s.requires_arc = true
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+34
-66
@@ -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,26 +56,6 @@ 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
|
||||
@@ -92,7 +72,9 @@ public enum SirenLanguageType: String
|
||||
case Italian = "it"
|
||||
case Japanese = "ja"
|
||||
case Korean = "ko"
|
||||
case Portuguese = "pt"
|
||||
case Polish = "pl"
|
||||
case PortugueseBrazil = "pt"
|
||||
case PortuguesePortugal = "pt-PT"
|
||||
case Russian = "ru"
|
||||
case Slovenian = "sl"
|
||||
case Spanish = "es"
|
||||
@@ -135,14 +117,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.
|
||||
*/
|
||||
var debugEnabled = false
|
||||
public lazy var debugEnabled = false
|
||||
|
||||
// Alert Vars
|
||||
/**
|
||||
@@ -150,40 +132,40 @@ 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
|
||||
|
||||
When this property is nil, the value set for the general alertType property is used.
|
||||
Defaults to SirenAlertType.Option.
|
||||
|
||||
See the SirenAlertType enum for full details.
|
||||
*/
|
||||
var majorUpdateAlertType: SirenAlertType?
|
||||
public var majorUpdateAlertType = SirenAlertType.Option
|
||||
|
||||
/**
|
||||
Determines the type of alert that should be shown for minor version updates: a.B.c
|
||||
|
||||
When this property is nil, the value set for the general alertType property is used.
|
||||
Defaults to SirenAlertType.Option.
|
||||
|
||||
See the SirenAlertType enum for full details.
|
||||
*/
|
||||
var minorUpdateAlertType: SirenAlertType?
|
||||
public var minorUpdateAlertType = SirenAlertType.Option
|
||||
|
||||
/**
|
||||
Determines the type of alert that should be shown for minor patch updates: a.b.C
|
||||
|
||||
When this property is nil, the value set for the general alertType property is used.
|
||||
Defaults to SirenAlertType.Option.
|
||||
|
||||
See the SirenAlertType enum for full details.
|
||||
*/
|
||||
var patchUpdateAlertType: SirenAlertType?
|
||||
public var patchUpdateAlertType = SirenAlertType.Option
|
||||
|
||||
// Required Vars
|
||||
/**
|
||||
The App Store / iTunes Connect ID for your app.
|
||||
*/
|
||||
var appID: String?
|
||||
public var appID: String?
|
||||
|
||||
/**
|
||||
The view controller that will present the instance of UIAlertController.
|
||||
@@ -192,7 +174,7 @@ public class Siren: NSObject
|
||||
|
||||
This property must be set before calling checkVersion().
|
||||
*/
|
||||
var presentingViewController: UIViewController?
|
||||
public var presentingViewController: UIViewController?
|
||||
|
||||
// Optional Vars
|
||||
/**
|
||||
@@ -200,7 +182,7 @@ public class Siren: NSObject
|
||||
|
||||
By default, it's set to the name of the app that's stored in your plist.
|
||||
*/
|
||||
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.
|
||||
@@ -209,19 +191,19 @@ 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?
|
||||
@@ -248,7 +230,7 @@ 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.")
|
||||
@@ -351,7 +333,8 @@ public class Siren: NSObject
|
||||
}
|
||||
|
||||
// MARK: Alert
|
||||
private extension Siren {
|
||||
private extension Siren
|
||||
{
|
||||
func showAlertIfCurrentAppStoreVersionNotSkipped() {
|
||||
|
||||
self.alertType = self.setAlertType()
|
||||
@@ -455,7 +438,8 @@ private extension Siren {
|
||||
}
|
||||
|
||||
// MARK: Helpers
|
||||
private extension Siren {
|
||||
private extension Siren
|
||||
{
|
||||
|
||||
func iTunesURLFromString() -> NSURL {
|
||||
|
||||
@@ -499,34 +483,18 @@ private extension Siren {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: Potentially turn this into a custom setter/getter with property observers
|
||||
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Properties.html#//apple_ref/doc/uid/TP40014097-CH14-ID262
|
||||
*/
|
||||
func setAlertType() -> SirenAlertType {
|
||||
|
||||
if majorUpdateAlertType == nil {
|
||||
majorUpdateAlertType = alertType
|
||||
}
|
||||
|
||||
if minorUpdateAlertType == nil {
|
||||
minorUpdateAlertType = alertType
|
||||
}
|
||||
|
||||
if patchUpdateAlertType == nil {
|
||||
patchUpdateAlertType = alertType
|
||||
}
|
||||
|
||||
let oldVersion = split(currentInstalledVersion!, {$0 == "."}, maxSplit: Int.max, allowEmptySlices: false).map {$0.toInt() ?? 0}
|
||||
let newVersion = split(currentAppStoreVersion!, {$0 == "."}, maxSplit: Int.max, allowEmptySlices: false).map {$0.toInt() ?? 0}
|
||||
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
|
||||
alertType = majorUpdateAlertType!
|
||||
alertType = majorUpdateAlertType
|
||||
} else if newVersion[1] > oldVersion[1] { // a.B.c
|
||||
alertType = minorUpdateAlertType!
|
||||
alertType = minorUpdateAlertType
|
||||
} else if newVersion[2] > oldVersion[2] { // a.b.C
|
||||
alertType = patchUpdateAlertType!
|
||||
alertType = patchUpdateAlertType
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,15 +508,15 @@ private extension Siren {
|
||||
|
||||
// Actions
|
||||
func launchAppStore() {
|
||||
let iTunesString = "https://itunes.apple.com/app/id\(appID)";
|
||||
let iTunesString = "https://itunes.apple.com/app/id\(appID!)";
|
||||
let iTunesURL = NSURL(string: iTunesString);
|
||||
UIApplication.sharedApplication().openURL(iTunesURL!);
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: String Localization
|
||||
private extension Siren {
|
||||
|
||||
private extension Siren
|
||||
{
|
||||
func localizedNewVersionMessage() -> String {
|
||||
|
||||
let newVersionMessageToLocalize = "A new version of %@ is available. Please update to version %@ now."
|
||||
@@ -572,8 +540,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