Giter Site home page Giter Site logo

thii / siren Goto Github PK

View Code? Open in Web Editor NEW

This project forked from artsabintsev/siren

0.0 3.0 0.0 365 KB

Notify users when a new version of your app is available and prompt them to upgrade.

Home Page: http://www.sabintsev.com

License: MIT License

Swift 96.82% Objective-C 0.83% Ruby 2.35%

siren's Introduction

Siren

Notify users when a new version of your app is available and prompt them to upgrade.

Travis-CI Cocoapods Carthage Compatible SwiftPM Compatible

About

Siren checks a user's currently installed version of your iOS app against the version that is currently available in the App Store.

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 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 actively maintained by Arthur Sabintsev and Aaron Brager

Ports

  • Siren is a Swift language port of Harpy, an Objective-C library that achieves the same functionality.
  • Siren and Harpy are maintained by the same developers.
  • This library was the inspiration for Egghead Games' Siren library, which achieves the same functionality with the Google Play store on the Android platform.

Features

  • CocoaPods Support
  • Carthage Support
  • Swift Package Manager Support
  • Localized for 20+ languages (See Localization)
  • Pre-Update Device Compatibility Check (See Device Compatibility)
  • Three types of alerts (see Screenshots)
  • Optional delegate methods (see Optional Delegate)
  • Unit Tests!

Screenshots

  • The left picture forces the user to update the app.
  • The center picture gives the user the option to update the app.
  • The right picture gives the user the option to skip the current update.
  • These options are controlled by the SirenAlertType enum.

<img src="https://github.com/ArtSabintsev/Harpy/blob/master/samplePictures/picForcedUpdate.png?raw=true" height=480"> <img src="https://github.com/ArtSabintsev/Harpy/blob/master/samplePictures/picOptionalUpdate.png?raw=true" height=480"> <img src="https://github.com/ArtSabintsev/Harpy/blob/master/samplePictures/picSkippedUpdate.png?raw=true" height=480">

Installation Instructions

CocoaPods

pod 'Siren'

For Swift 2.3 support:

pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'swift2.3'

For Swift 3 support:

pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'swift3'

Carthage

github "ArtSabintsev/Siren"

For Swift 2.3 support:

github "ArtSabintsev/Siren" "swift2.3"

For Swift 3 support:

github "ArtSabintsev/Siren" "swift3"

Swift Package Manager

.Package(url: "https://github.com/ArtSabintsev/Siren.git", majorVersion: 0)

Manual

  1. Download Siren.
  2. Copy the Siren folder into your project.

Setup

Here's some commented sample code. Adapt this to meet your app's needs. For a full list of optional settings/preferences, please refer to https://github.com/ArtSabintsev/Siren/blob/master/Sample%20App/Sample%20App/AppDelegate.swift in the Sample Project.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
	/* Siren code should go below window?.makeKeyAndVisible() */

	// Siren is a singleton
	let siren = Siren.sharedInstance

	// Optional: Defaults to .Option
	siren.alertType = <#SirenAlertType_Enum_Value#>

	/*
	    Replace .Immediately with .Daily or .Weekly to specify a maximum daily or weekly frequency for version
	    checks.
	*/
    siren.checkVersion(.Immediately)

    return true
}

func applicationDidBecomeActive(application: UIApplication) {
	/*
	    Perform daily (.Daily) or weekly (.Weekly) checks for new version of your app.
	    Useful if user returns to your app from the background after extended period of time.
    	 Place in applicationDidBecomeActive(_:).	*/

    Siren.sharedInstance.checkVersion(.Daily)
}

func applicationWillEnterForeground(application: UIApplication) {
   /*
	    Useful if user returns to your app from the background after being sent to the
	    App Store, but doesn't update their app before coming back to your app.

       ONLY USE WITH SirenAlertType.Force
   */

    Siren.sharedInstance.checkVersion(.Immediately)
}

And you're all set!

Prompting for Updates without Alerts

Some developers may want to display a less obtrusive custom interface, like a banner or small icon. To accomplish this, you can disable alert presentation by doing the following:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
	...
	siren.delegate = self
	siren.alertType = .None
	...
}

extension AppDelegate: SirenDelegate {
	// Returns a localized message to this delegate method upon performing a successful version check
    func sirenDidDetectNewVersionWithoutAlert(message: String) {
        print("\(message)")
    }
}

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 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:

	/* 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#>

Optional Delegate and Delegate Methods

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.

public protocol SirenDelegate: class {
    func sirenDidShowUpdateDialog(alertType: SirenAlertType)   // User presented with update dialog
    func sirenUserDidLaunchAppStore()                          // User did click on button that launched App Store.app
    func sirenUserDidSkipVersion()                             // User did click on button that skips version update
    func sirenUserDidCancel()                                  // User did click on button that cancels update dialog
    func sirenDidFailVersionCheck(error: NSError)              // Siren failed to perform version check (may return system-level error)
    func sirenDidDetectNewVersionWithoutAlert(message: String) // Siren performed version check and did not display alert
}

Localization

Siren is localized for Arabic, Armenian, Basque, Chinese (Simplified), Chinese (Traditional), Danish, Dutch, English, Estonian, French, German, Hebrew, Hungarian, Italian, Japanese, Korean, Latvian, Lithuanian, Malay, Polish, Portuguese (Brazil), Portuguese (Portugal), Russian, Slovenian, Swedish, Spanish, Thai, Turkish, Vietnamese.

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).

You can enable it like this:

Siren.sharedInstance.forceLanguageLocalization = SirenLanguageType.<#SirenLanguageType_Enum_Value#>

Device Compatibility

If an app update is available, Siren checks to make sure that the version of iOS on the user's device is compatible the one that is required by the app update. For example, if a user has iOS 9 installed on their device, but the app update requires iOS 10, an alert will not be shown. This takes care of the false positive case regarding app updating.

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, change your bundleID to one that is already in the store. In the sample app packaged with this library, we use the iTunes Connect Mobile app's bundleID: com.apple.itunesconnect.mobile.

For your convenience, you may turn on 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.

Created and maintained by

Arthur Ariel Sabintsev & Aaron Brager

siren's People

Contributors

artsabintsev avatar getaaron avatar irlabs avatar jedrekk avatar jinjic avatar joelparkerhenderson avatar liebeskind avatar nagaho avatar pavankataria avatar sentulasia avatar thii avatar vahanmargaryan avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.