Git Product home page Git Product logo

siren's Introduction

Siren ๐Ÿšจ

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

Swift Support CocoaPods SwiftPM Compatible Accio supported


Important Information

I stopped being a proactive iOS engineer in 2021. For the time being, I will keep this library maintained for the community, but I will not be proactively adding features.


Table of Contents


Meta

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, a language localized 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 through alternative means, such as a custom user interface.

Siren is built to work with the Semantic Versioning system.

  • Canonical Semantic Versioning uses a three number versioning system (e.g., 1.0.0)
  • Siren also supports two-number versioning (e.g., 1.0) and four-number versioning (e.g., 1.0.0.0)

Features

Current Features


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 Rules.AlertType enum.

Ports

  • Objective-C (iOS)
    • Harpy
    • Siren was ported from Harpy, as Siren and Harpy are maintained by the same developer.
    • As of December 2018, Harpy has been deprecated in favor of Siren.
  • Java (Android)
  • React Native (iOS)

Installation and Integration

Installation Instructions

Swift Version Branch Name Will Continue to Receive Updates?
5.5+ master Yes
5.1-5.4 swift5.4 No
5.0 swift5.0 No
4.2 swift4.2 No
4.1 swift4.1 No
3.2 swift3.2 No
3.1 swift3.1 No
2.3 swift2.3 No

CocoaPods

pod 'Siren' # Swift 5.5+
pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'swift5.4' # Swift 5.1-5.4
pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'swift5.0' # Swift 5.0
pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'swift4.2' # Swift 4.2
pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'swift4.1' # Swift 4.1
pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'swift3.2' # Swift 3.2
pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'swift3.1' # Swift 3.1
pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'swift2.3' # Swift 2.3

Swift Package Manager

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

Implementation Examples

Implementing Siren is as easy as adding two lines of code to your app in either AppDelegate.swift or SceneDelegate.swift:

AppDelegate.swift Example

import Siren // Line 1
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        window?.makeKeyAndVisible()

	Siren.shared.wail() // Line 2

        return true
    }
}

SceneDelegate.swift Example

import Siren // Line 1
import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        window?.makeKeyAndVisible()

	Siren.shared.wail() // Line 2

        return true
    }
}

Siren also has plenty of customization options. All examples can be found in the Example Project's AppDelegate file. Uncomment the example you'd like to test.


Device-Specific Checks

Localization

Siren is localized for the following languages:

Arabic, Armenian, Basque, Chinese (Simplified and Traditional), Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, German, Greek, Hebrew, Hungarian, Indonesian, Italian, Japanese, Korean, Latvian, Lithuanian, Malay, Norwegian (Bokmรฅl), Persian (Afghanistan, Iran, Persian), Polish, Portuguese (Brazil and Portugal), Romanian, Russian, Serbian (Cyrillic and Latin), Slovenian, Spanish, Swedish, Thai, Turkish, Ukrainian, Urdu, Vietnamese

If your user's device is set to one of the supported locales, an update message will appear in that language. If a locale is not supported, than the message will appear in English.

You may want the update dialog to always appear in a certain language, ignoring the user's device-specific setting. You can enable it like so:

// In this example, we force the `Russian` language.
Siren.shared.presentationManager = PresentationManager(forceLanguageLocalization: .russian)

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 with the one that is required by the app update. For example, if a user has iOS 11 installed on their device, but the app update requires iOS 12, an alert will not be shown. This takes care of the false positive case regarding app updating.


Testing

Testing Siren Locally

Temporarily change the version string in Xcode (within the .xcodeproj file) 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 Facebook's Bundle ID: com.facebook.Facebook.

Words of Caution

Occasionally, the iTunes JSON will update faster than the App Store CDN, meaning the JSON may state that the new version of the app has been released, while no new binary is made available for download via the App Store. It is for this reason that Siren will, by default, wait 1 day (24 hours) after the JSON has been updated to prompt the user to update. To change the default setting, please modify the value of showAlertAfterCurrentVersionHasBeenReleasedForDays.


App Submission

App Store Review

The App Store reviewer will not see the alert. The version in the App Store will always be older than the version being reviewed.

Phased Releases

In 2017, Apple announced the ability to rollout app updates gradually (a.k.a. Phased Releases). Siren will continue to work as it has in the past, presenting an update modal to all users. If you opt-in to a phased rollout for a specific version, you have a few choices:

  • You can leave Siren configured as normal. Phased rollout will continue to auto-update apps. Since all users can still manually update your app directly from the App Store, Siren will ignore the phased rollout and will prompt users to update.
  • You can set showAlertAfterCurrentVersionHasBeenReleasedForDays to 7, and Siren will not prompt any users until the latest version is 7 days old, after the phased rollout is complete.
  • You can remotely disable Siren until the rollout is done using your own API / backend logic.

Attribution

Special Thanks

A massive shout-out and thank you goes to the following folks:

  • Aaron Brager for motivating me and assisting me in building the initial proof-of-concept of Siren (based on Harpy) back in 2015. Without him, Siren may never have been built.
  • All of Harpy's Contributors for helping building the feature set from 2012-2015 that was used as the basis for the first version of Siren.
  • All of Siren's Contributors for helping make Siren as powerful and bug-free as it currently is today.

Creator

Arthur Ariel Sabintsev

siren's People

Contributors

artsabintsev avatar blerdfoniqi avatar bre7 avatar chrisixflash avatar dependabot[bot] avatar fahlout avatar fl0ge avatar frydiggity avatar getaaron avatar hkellaway avatar irlabs avatar keyboardseokmin avatar kwstasna avatar liebeskind avatar mmdock avatar mojtabahs avatar nixnoughtnothing avatar nsemakov avatar ryanthon avatar sandrodahl avatar sentulasia avatar spigarellisj avatar sschizas avatar steviki avatar thii avatar txaiwieser avatar vahanmargaryan avatar viewsourcecode avatar xedla avatar zongmumask avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

siren's Issues

sirenDidShowUpdateDialog Function Not Called

I have implemented the 'SirenDelegate' within my ViewController, and the dialog appears properly, however the 'sirenDidShowUpdateDialog' is not getting called. I have the following in my code:

func sirenDidShowUpdateDialog() {
    print("did show dialog")
}

func sirenUserDidLaunchAppStore() {
    print("did launch app store")
}

func sirenUserDidCancel() {
    print("did cancel")
}

The 'sirenUserDidLaunchAppStore' and 'sirenUserDidCancel' 'print' statements are called properly, but the 'sirenDidShowUpdateDialog' 'print' statement is not called when the dialog appears.

Swift 3

Hello and thanks for this framework,

Is there a Swift 3 branch on its way?

I can't use it with Xcode 8 and Swift 3 beta and Cocoapods... Or couldn't find how to.

Thanks!

Crash when no internet

Siren crashes the app when no internet/service.

HockeyApp Log:

MyApp.Siren.((performVersionCheck in _5FA0E00E9C2A892EB4899D0EF44B562B) (MyApp.Siren) -> () -> ()).(closure #1) (Siren.swift:273)

partial apply forwarder for reabstraction thunk helper from @callee_owned (@in (Swift.ImplicitlyUnwrappedOptional<ObjectiveC.NSData>, Swift.ImplicitlyUnwrappedOptional<ObjectiveC.NSURLResponse>, Swift.ImplicitlyUnwrappedOptional<ObjectiveC.NSError>)) -> (@out ()) to @callee_owned (@owned Swift.ImplicitlyUnwrappedOptional<ObjectiveC.NSData>, @owned Swift.ImplicitlyUnwrappedOptional<ObjectiveC.NSURLResponse>, @owned Swift.ImplicitlyUnwrappedOptional<ObjectiveC.NSError>) -> (@unowned ()) with unmangled suffix "25" (Siren.swift:0)

Error when trying to retrieve App Store data

I'm getting this error when I run the app.
[Siren] JSON results: ["resultCount": 0, "results": <__NSArray0 0x15de15b60>()]
[Siren] Error retrieving App Store data as an error was returned.

I don't know where to specify my App Id now when that property is private. My app is active on the app store so this don't happen because of it doesn't exist there.

What am I missing?

iOS 8 skipAlertAction bug

NSUserDefaults.standardUserDefaults().setObject(currentAppStoreVersion!, forKey:sirenDefaultSkippedVersion) NSUserDefaults.standardUserDefaults().synchronize()

Did not perform this code

UIAlertController

Hello,

First of all -- great project.

I noticed that the UIAlertController only appears if the window's rootViewController is visible when you open the app. It's not a bug with UIAlertController, but it has to do with UIAlertController being a UIViewController instead of a UIView (like UIAlertView).

Have you figured out how to show the update alert when the app resumes on a view controller that's not the rootViewController?

I've tried using a second UIWindow and then presenting the UIAlertController on that, but I ran into some odd issues.

Thanks in advance!
Dylan

Version check comparison error.

This issue simply shouldn't be happening.

There needs to be another way to compare version numbers, 16.0 is certainly the same as 16 and shouldn't be treated as requiring a new version! :O I was shocked when I saw this..
Did some debugging and found the problem area...
Today our app was accepted only for siren to cause our users to go into a never ending loop of installs..

screen shot 2016-06-16 at 02 50 53

Public API to close alert and version check?

Hi,

Would it be possible to have a public API to be able to close the alert with a method?

Also, we rolled our own forced update alert with our API. I would love to be able to use the same method you use to check if the current app version is older than X version. Would it makes sense to open it up as well?

if app is not in app store yet, it crashes

Change processVersionCheckResults() to this to fix the issue (first check if app is available)

private func processVersionCheckResults(results: [String : AnyObject]) {

        if results["results"]?.count > 0 {
            self.currentAppStoreVersion = results["results"]?[0]["version"] as? String
            if let currentAppStoreVersion = self.currentAppStoreVersion {
                if self.isAppStoreVersionNewer() {
                    self.showAlertIfCurrentAppStoreVersionNotSkipped()
                }
            } else {
                if self.debugEnabled {
                    println("[Siren] Error retrieving App Store version number")
                }
            }
        }
        else {
            if self.debugEnabled {
                println("[Siren] App not found")
            }
        }


    }

Checking works only once

There is erorr in checking of date in the daysSinceLastVersionCheckDate method. Please accept my pull request.

CFNetwork SSLHandshake failed (-9801) errors

Hi,

when I try to use Siren in my app, I get SSL errors on startup:

CFNetwork SSLHandshake failed (-9801)
CFNetwork SSLHandshake failed (-9801)
CFNetwork SSLHandshake failed (-9801)
CFNetwork SSLHandshake failed (-9801)
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9801)

Do I have to add a URL to my App Transport Security exceptions for Siren to work?

Set 'presentingViewController' before calling checkVersion Error

I am using Siren 0.3.5 via CocoaPods 0.37.2 and am getting the error

"Please make sure that you have set 'presentingViewController' before calling checkVersion."

Have tried running from AppDelegate and from a UIViewController. I've tried setting the following in the UIViewController code:

siren.sharedInstance().presentingViewController = self

but getting nil when unwrapping Optional in

func sirenBundlePath() -> String {
    return NSBundle.mainBundle().pathForResource("Siren", ofType: "bundle") as String!
}

Can't test unless app is live in the app store.

I want to test on Siren however I do not currently have a version live in the app store so I can't "Temporarily change the version string in Xcode to an older version than the one that's currently available in the App Store" as is specified in the ReadMe.

Here are the results from turning on debug:

[Siren] iTunes Lookup URL: https://itunes.apple.com/lookup?id=XXXXXXXXX (I'm obscuring my app id)
[Siren] JSON results: [resultCount: 0, results: (
)]
[Siren] Error retrieving App Store verson number as results returns an empty array

Currently I'm just finding a random app on the app store and using their app id for testing.

Manual Installation Error

There is no proper folder to be manually added into my own project. Need to open the Sample App and pull the Siren.framework into my own project.

Warnings when launching app store from UIAlertAction completion handler.

Running sample app in iOS 9.3 produces the following warnings in the console:

2016-05-04 14:53:59.978 Sample App[13254:43700378] _BSMachError: (os/kern) invalid capability (20)
2016-05-04 14:53:59.979 Sample App[13254:43700738] _BSMachError: (os/kern) invalid name (15)

Stackoverflow suggests using dispatch_async to fix this:

let action = UIAlertAction(title: title, style: .Default) { (alert: UIAlertAction) in
            self.hideWindow()
            dispatch_async(dispatch_get_main_queue(), {
                self.launchAppStore()
            })
            self.delegate?.sirenUserDidLaunchAppStore()
            return
        }

other server

hello
i can update app version whiteout appstor Apple

Multiple checkVersion in app?

Is it fine to have siren.checkVersion(.Immediately) in didFinishLaunchingWithOptions and Siren.sharedInstance.checkVersion(.Daily) in applicationDidBecomeActive? I saw in the obj-c project you advice to just use one, but I think it's useful to do a immediate check when the app launch for the first time as well as daily.

Carthage support?

It would be great to have Carthage support. If I create a PR, would you accept it?

(Not that I'm a Carthage creation expert, but it would give me extra incentive to try if I know it will be accepted and updated ongoing, thanks!)

Support for iOS8

Just discover that Siren 1.0.0 doesn't support iOS8.0 anymore, is there a technical reason for that?

I know Apple suggests to support only the last two major version, but it would be great to have at least one release supporting Swift 3 and iOS8 for all the developers that can't drop that version yet ๐Ÿ‘ผ

Setting the alertType to .Force doesn't seem to work

let siren = Siren.sharedInstance
siren.appID = "[APP_ID]"
siren.alertType = .Force
siren.checkVersion(.Immediately)

This brings up an alert with "Next time" and "Update" as options, which is the default alert type.
Am I doing something wrong?

Attempting to load a UIAlertController when VC is deallocating

I am trying to perform a check immediately when the app open, so I call check immediately from didFinishLaunchingWithOptions. I keep getting the following error:
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior

I also tried calling it from the View Controller in didAppear and get the same error.

Error when testing - EXC_BAD_INSTRUCTION

I'm getting an error (EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode 0x0)) on the return on this:

func sirenBundlePath() -> String {
return NSBundle.mainBundle().pathForResource("Siren", ofType: "bundle") as String!
}

Thread 1 says:
0 function signature specialization <Arg[1] = Owned to Guaranteed> of ext.MYAPP.ObjectiveC.NSBundle.(sirenForcedBundlePath in _......."

Any ideas? It seems to only crash when I try to make the app fail (by pointing towards the iTunes Connect appID, since my app isn't in the store yet to test against.

Thanks!

sirenDidFailVersionCheck

I had an error but i don't know what exaclty it is
Can anyone help me to find out
Here is the log from console tab

sirenDidFailVersionCheck Error Domain=Siren Error Domain Code=1001 "No new update available." UserInfo={NSLocalizedDescription=No new update available.}
[Siren] No new update available.

Many Thanks

hideWindow() causes a crash

When the alert pops up and user presses home button and go back app again. Tap "Next Time" or "Update" will cause a bug.

I found the hideWindow() cause this issue. you need to check the updateWindow if nil before hide it.
Please fix this, thanks.

Version check

I think the currentInstalledVersion should check for CFBundleVersion instead of CFBundleShortVersionString

Mac App Store support

It would be great to have only one library to handle all the platforms ๐ŸŽ‰
Not sure how hard it would be to port to Siren to macOS, probably just be the interface part which has to be platform related.

Altering AppID and Test with 0.8

How can I set the appID for testing ? My app is not in app store yet and I need to set the AppID but as instruction says, the AppID is now fetched from the API.

Any solution for how to test with other AppID's

Swift 3 and SwiftPM support

Hi,
If your component is SwiftPM compatible it's will be great you add
add SwiftPM Compatible on top of your README.md and add section for the installation with SwiftPM.

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.