Compare commits

...

2 Commits

Author SHA1 Message Date
Arthur Ariel Sabintsev 879cf8c21c Closes #6. Fixes issue with Daily/Weeky checkType setting 2015-01-24 11:38:18 -05:00
Arthur Ariel Sabintsev d862717f5d Minor change to logs 2015-01-21 10:55:19 -05:00
5 changed files with 22 additions and 20 deletions
+3 -3
View File
@@ -13,9 +13,9 @@ If a new version is available, an alert can be presented to the user informing t
- Siren is actively maintained by [**Arthur Sabintsev**](http://github.com/ArtSabintsev) and [**Aaron Brager**](http://twitter.com/getaaron).
### Changelog
#### 0.2.0
- Refactored for safety and readability
- Added more log statements if `debugEnabled == true`
#### 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.
### Features
- [x] CocoaPods Support
+1 -1
View File
@@ -43,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
siren.alertType = .Option
// Optional
// siren.forceLanguageLocalization = .Spanish // Optional: Sets all messages to appear in 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)
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6724" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6711"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Siren"
s.version = "0.2.0"
s.version = "0.2.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.2.0" }
s.source = { :git => "https://github.com/ArtSabintsev/Siren.git", :tag => "0.2.2" }
s.source_files = 'Siren/Siren.swift'
s.resources = 'Siren/Siren.bundle'
s.requires_arc = true
+13 -12
View File
@@ -117,7 +117,7 @@ public class Siren: NSObject
let sirenDefaultSkippedVersion = "Siren User Decided To Skip Version Update"
// Current installed version of your app
let currentVersion = NSBundle.mainBundle().currentVersion()
let currentInstalledVersion = NSBundle.mainBundle().currentInstalledVersion()
// NSBundle path for localization
let bundlePath = NSBundle.mainBundle().pathForResource("Siren", ofType: "Bundle")
@@ -251,11 +251,10 @@ public class Siren: NSObject
func checkVersion(checkType: SirenVersionCheckType) {
if (appID == nil) {
println("[Siren]: Please make sure that you have set 'appID' before calling checkVersion.")
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.")
println("[Siren] Please make sure that you have set 'presentingViewController' before calling checkVersion.")
} else {
if checkType == .Immediately {
performVersionCheck()
} else {
@@ -475,7 +474,7 @@ private extension Siren {
func daysSinceLastVersionCheckDate() -> Int {
let calendar = NSCalendar.currentCalendar()
let components = calendar.components(.CalendarUnitDay, fromDate: lastVersionCheckPerformedOnDate!, toDate: NSDate(), options: nil)
let components = calendar.components(.CalendarUnitDay, fromDate: NSDate(), toDate: lastVersionCheckPerformedOnDate!, options: nil)
return components.day
}
@@ -483,8 +482,8 @@ private extension Siren {
var newVersionExists = false
if let currentVersion = self.currentVersion {
if (currentVersion.compare(currentAppStoreVersion!, options: .NumericSearch) == NSComparisonResult.OrderedAscending) {
if let currentInstalledVersion = self.currentInstalledVersion {
if (currentInstalledVersion.compare(currentAppStoreVersion!, options: .NumericSearch) == NSComparisonResult.OrderedAscending) {
newVersionExists = true
}
}
@@ -493,9 +492,11 @@ private extension Siren {
}
func storeVersionCheckDate() {
self.lastVersionCheckPerformedOnDate = NSUserDefaults.standardUserDefaults().objectForKey(self.sirenDefaultStoredVersionCheckDate) as? NSDate
NSUserDefaults.standardUserDefaults().setObject(self.lastVersionCheckPerformedOnDate, forKey: self.sirenDefaultStoredVersionCheckDate)
NSUserDefaults.standardUserDefaults().synchronize()
lastVersionCheckPerformedOnDate = NSDate()
if let lastVersionCheckPerformedOnDate = self.lastVersionCheckPerformedOnDate {
NSUserDefaults.standardUserDefaults().setObject(self.lastVersionCheckPerformedOnDate!, forKey: self.sirenDefaultStoredVersionCheckDate)
NSUserDefaults.standardUserDefaults().synchronize()
}
}
/*
@@ -516,7 +517,7 @@ private extension Siren {
patchUpdateAlertType = alertType
}
let oldVersion = split(currentVersion!, {$0 == "."}, maxSplit: Int.max, allowEmptySlices: false).map {$0.toInt() ?? 0}
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}
if oldVersion.count == 3 && newVersion.count == 3 {
@@ -573,7 +574,7 @@ private extension Siren {
// MARK: NSBundle Extension
private extension NSBundle {
func currentVersion() -> String? {
func currentInstalledVersion() -> String? {
return NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as? String
}