Code Monkey home page Code Monkey logo

siren's Introduction

Siren

Notify users when a new version of your app is available, and prompt them with the App Store link.


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.

Changelog

0.1.1

  • Changed CocoaPods deployment target to iOS 8 due to this post.

Features

  • CocoaPods Support
  • Support for UIAlertController (iOS 8+) and UIAlertView (iOS 7)
  • Localized for 18 languages (See Localization Section)
  • Three types of alerts (see Screenshots & Alert Types)
  • Optional delegate methods (see Optional Delegate section)

Installation Instructions

CocoaPods Installation

pod 'Siren'
  • Requires CocoaPods 0.36 prerelease or later

  • Only for apps with a minimum deployment target of iOS 8.0 or later

    CocoaPods does not support pods written in Swift on iOS 7. For more information, please see this issue.

If your app needs to support iOS 7, use Manual Installation.

Manual Installation

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

Setup Instructions

Here's some commented sample code. Adapt this to meet your app's needs.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{
	/* Siren code should go below window?.makeKeyAndVisible() */
	
	// Siren is a singleton
	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#>
	
	/*
	    Replace .Immediately with .Daily or .Weekly to specify a maximum daily or weekly frequency for version
	    checks.
	*/
    siren.checkVersion(.Immediately)
}

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!

Screenshots & Alert Types

Siren can force an update, let the user optionally update, and allow the user to skip an update.

To control this behavior, assign a SirenAlertType to alertType (or one of the specific alert type properties).

siren.alertType = .Force

Forces the user to update.

Forced Update

siren.alertType = .Option

The default behavior.

Optional Update

siren.alertType = .Skip

Allows the user to opt out of future reminders for this version.

Skip Update

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.

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) {
        println("\(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 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:

	/* Siren defaults to SirenAlertType.Option for all updates */
	siren.sharedInstance().patchUpdateAlertType = <#SirenAlertType_Enum_Value#>
	siren.sharedInstance().minorUpdateAlertType = <#SirenAlertType_Enum_Value#>
	siren.sharedInstance().majorUpdateAlertType = <#SirenAlertType_Enum_Value#>

Optional Delegate and Delegate Methods

Five delegate methods allow you to handle or track the user's behavior:

@objc 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
    optional func sirenUserDidCancel()  // User did click on button that cancels update dialog
    optional func sirenDidDetectNewVersionWithoutAlert(message: String) // Siren performed version check and did not display alert
}

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.

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

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

Watchers

 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.