Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
noahsmartin committed Oct 11, 2024
1 parent ad5ec1b commit f650ede
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 8 additions & 1 deletion Example/DemoApp/UpdateUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


import Foundation
import UIKit
import ETDistribution

struct UpdateUtil {
Expand All @@ -17,6 +18,12 @@ struct UpdateUtil {
case .success(let releaseInfo):
if let releaseInfo {
print("Update found: \(releaseInfo)")
guard let url = ETDistribution.shared.buildUrlForInstall(releaseInfo.downloadUrl) else {
return
}
UIApplication.shared.open(url) { _ in
exit(0)
}
} else {
print("Already up to date")
}
Expand All @@ -25,4 +32,4 @@ struct UpdateUtil {
}
}
}
}
}
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ dependencies: [
### Checking for Updates
The ETDistribution library provides a simple API to check for updates:
```swift
import UIKit
import ETDistribution

ETDistribution.shared.checkForUpdate(apiKey: "YOUR_API_KEY") { result in
switch result {
case .success(let releaseInfo):
if let releaseInfo {
print("Update found: \(releaseInfo)")
guard let url = ETDistribution.shared.buildUrlForInstall(releaseInfo.downloadUrl) else {
return
}
UIApplication.shared.open(url) { _ in
exit(0)
}
} else {
print("Already up to date")
}
Expand All @@ -66,11 +73,7 @@ For Objective-C:
}];
```
If you already have the `plist` url for the update, you can get the `itms-services` url by calling `buildUrlForInstall`:
```swift
if let installUrl = ETDistribution.shared.buildUrlForInstall("https://example.com/app.plist") {
UIApplication.shared.open(installUrl, options: [:], completionHandler: nil)
}
If you do not provide a completion handler, a default UI will be shown asking if the update should be installed.
```

## Configuration
Expand Down Expand Up @@ -102,4 +105,4 @@ The library is designed to skip update checks on the simulator. To test update f

### How do I skip an update?

There is no public API to programatically skip updates right now.
When handling the response you can check the release version field to decide if it should be installed or not.

0 comments on commit f650ede

Please sign in to comment.