Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Check if update alert should be shown with update manager delegate #339

Merged
merged 1 commit into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Classes/BITUpdateManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,12 @@ - (void)showUpdateView {
- (void)showCheckForUpdateAlert {
if (self.appEnvironment != BITEnvironmentOther) return;
if ([self isUpdateManagerDisabled]) return;


if ([self.delegate respondsToSelector:@selector(shouldDisplayUpdateAlertForUpdateManager:forShortVersion:forVersion:)] &&
![self.delegate shouldDisplayUpdateAlertForUpdateManager:self forShortVersion:[self.newestAppVersion shortVersion] forVersion:[self.newestAppVersion version]]) {
return;
}

if (!_updateAlertShowing) {
NSString *title = BITHockeyLocalizedString(@"UpdateAvailable");
NSString *message = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertMandatoryTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]];
Expand Down
23 changes: 23 additions & 0 deletions Classes/BITUpdateManagerDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@

@optional

///-----------------------------------------------------------------------------
/// @name Update
///-----------------------------------------------------------------------------

/**
Return if update alert should be shown

If you want to display your own user interface when there is an update available,
implement this method, present your user interface and return _NO_. In this case
it is your responsibility to call `BITUpdateManager showUpdateView`

Note: This delegate will be invoked on startup and every time the app becomes
active again!

When returning _YES_ the default blocking UI will be shown.

When running the app from the App Store, this delegate is ignored.

@param updateManager The `BITUpdateManager` instance invoking this delegate
@param shortVersion The latest available version
@param version The latest available version
*/
- (BOOL)shouldDisplayUpdateAlertForUpdateManager:(BITUpdateManager *)updateManager forShortVersion:(NSString *)shortVersion forVersion:(NSString *)version;

///-----------------------------------------------------------------------------
/// @name Expiry
Expand Down