Skip to content

Commit

Permalink
Add aggressive prompt for update (use when the user must update the a…
Browse files Browse the repository at this point in the history
…pp to continue working)
  • Loading branch information
sidan5 committed Aug 7, 2015
1 parent e43f2bc commit 263a4f8
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 24 deletions.
2 changes: 2 additions & 0 deletions Examples/iPhone Demo/Classes/iLinkAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ + (void)initialize

[iLink sharedInstance].applicationVersion = @"1.0";

//[iLink sharedInstance].aggressiveUpdatePrompt = YES; // Would initiate update prompt always //

//[iLink sharedInstance].globalPromptForUpdate = NO;
// enable preview mode // if YES would show prompt always //
//[iLink sharedInstance].previewMode = YES;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../iLink/iLink.m"
timestampString = "417710332.294647"
timestampString = "460663167.40663"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "412"
endingLineNumber = "412"
startingLineNumber = "422"
endingLineNumber = "422"
landmarkName = "-shouldPromptForUpdate"
landmarkType = "5">
</BreakpointContent>
Expand All @@ -74,30 +74,46 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../iLink/iLink.m"
timestampString = "417710332.294647"
timestampString = "460663167.40663"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "413"
endingLineNumber = "413"
startingLineNumber = "423"
endingLineNumber = "423"
landmarkName = "-shouldPromptForUpdate"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../iLink/iLink.m"
timestampString = "417711253.645528"
timestampString = "460663167.40663"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "922"
endingLineNumber = "922"
startingLineNumber = "939"
endingLineNumber = "939"
landmarkName = "-applicationLaunched"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../iLink/iLink.m"
timestampString = "460663167.40663"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "872"
endingLineNumber = "872"
landmarkName = "-promptForUpdate"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Binary file modified iLink/iLink.bundle/en.lproj/Localizable.strings
Binary file not shown.
1 change: 1 addition & 0 deletions iLink/iLink.bundle/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"iLinkMessageTitle" = "Mettre à jour %@";
"iLinkAppMessage" = "Une nouvelle version de %@ est disponible. \n\nVoulez-vous la télécharger maintenant ?";
"iLinkAppMessageAggressive" = "An update for %@ is available. \n\nPlease update before continue using the app.";
"iLinkCancelButton" = "Non, merci";
"iLinkRemindButton" = "Me le rappeler ultérieurement";
"iLinkUpdateButton" = "Mettre à jour maintenant";
Binary file modified iLink/iLink.bundle/he.lproj/Localizable.strings
Binary file not shown.
17 changes: 10 additions & 7 deletions iLink/iLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,18 @@
#endif


extern NSUInteger const iLinkAppStoreGameGenreID;
extern NSString *const iLinkErrorDomain;
extern NSUInteger const iLinkAppStoreGameGenreID;
extern NSString *const iLinkErrorDomain;


//localisation string keys
static NSString *const iLinkMessageTitleKey = @"iLinkMessageTitle";
static NSString *const iLinkAppMessageKey = @"iLinkAppMessage";
static NSString *const iLinkCancelButtonKey = @"iLinkCancelButton";
static NSString *const iLinkRemindButtonKey = @"iLinkRemindButton";
static NSString *const iLinkUpdateButtonKey = @"iLinkUpdateButton";
static NSString *const iLinkMessageTitleKey = @"iLinkMessageTitle";

static NSString *const iLinkAppMessageKey = @"iLinkAppMessage";
static NSString *const iLinkAppMessageAggressiveKey = @"iLinkAppMessageAggressive";
static NSString *const iLinkCancelButtonKey = @"iLinkCancelButton";
static NSString *const iLinkRemindButtonKey = @"iLinkRemindButton";
static NSString *const iLinkUpdateButtonKey = @"iLinkUpdateButton";



Expand Down Expand Up @@ -155,6 +157,7 @@ typedef NS_ENUM(NSUInteger, iLinkErrorCode)
@property (nonatomic, assign) BOOL verboseLogging;
@property (nonatomic, assign) BOOL previewMode;
@property (nonatomic, assign) BOOL globalPromptForUpdate;
@property (nonatomic, assign) BOOL aggressiveUpdatePrompt;
@property (nonatomic, assign) NSString *linkParams;

//advanced properties for implementing custom behaviour
Expand Down
31 changes: 24 additions & 7 deletions iLink/iLink.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ - (iLink *)init
self.verboseLogging = NO;
self.previewMode = NO;
self.globalPromptForUpdate = YES;
self.aggressiveUpdatePrompt = NO;
self.linkParams = iLinkParamsCode;

#if DEBUG
Expand All @@ -245,6 +246,7 @@ - (iLink *)init

//app launched
[self performSelectorOnMainThread:@selector(applicationLaunched) withObject:nil waitUntilDone:NO];

}
return self;
}
Expand Down Expand Up @@ -273,9 +275,17 @@ - (NSString *)messageTitle
- (NSString *)message
{
NSString *message = _message;

NSString *tmpMsg;
if ([self aggressiveUpdatePrompt]) {
tmpMsg = iLinkAppMessageAggressiveKey;
}else{
tmpMsg = iLinkAppMessageKey;
}

if (!message)
{
message = [self localizedStringForKey:iLinkAppMessageKey withDefault:@"An update for %@ is available. \n\nWould you like to update it now?"]; }
message = [self localizedStringForKey:tmpMsg withDefault:@"An update for %@ is available. \n\nWould you like to update it now?"]; }
return [message stringByReplacingOccurrencesOfString:@"%@" withString:self.applicationName];
}

Expand Down Expand Up @@ -418,6 +428,14 @@ - (BOOL)shouldPromptForUpdate
return YES;
}

else if (self.globalPromptForUpdate && self.aggressiveUpdatePrompt){
if (self.verboseLogging)
{
NSLog(@"iLink did prompt for update because we are using aggressive mode and ask for prompt");
}
return YES;
}

else if (!self.globalPromptForUpdate)
{
if (self.verboseLogging)
Expand Down Expand Up @@ -852,16 +870,15 @@ - (void)promptForUpdate
{
if (!self.visibleAlert)
{

#if TARGET_OS_IPHONE

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:self.messageTitle
message:self.message
delegate:(id<UIAlertViewDelegate>)self
cancelButtonTitle:[self.cancelButtonLabel length] ? self.cancelButtonLabel: nil
cancelButtonTitle:
!self.aggressiveUpdatePrompt && [self.cancelButtonLabel length] ? self.cancelButtonLabel: nil
otherButtonTitles:self.updateButtonLabel//self.rateButtonLabel
, nil];
if ([self.remindButtonLabel length])
if (!self.aggressiveUpdatePrompt && [self.remindButtonLabel length])
{
[alert addButtonWithTitle:self.remindButtonLabel];
}
Expand All @@ -879,11 +896,11 @@ - (void)promptForUpdate

self.visibleAlert = [NSAlert alertWithMessageText:self.messageTitle
defaultButton:self.updateButtonLabel//self.rateButtonLabel
alternateButton:self.cancelButtonLabel
alternateButton:!self.aggressiveUpdatePrompt && [self.cancelButtonLabel length] ? self.cancelButtonLabel: nil
otherButton:nil
informativeTextWithFormat:@"%@", self.message];

if ([self.remindButtonLabel length])
if (!self.aggressiveUpdatePrompt && [self.remindButtonLabel length])
{
[self.visibleAlert addButtonWithTitle:self.remindButtonLabel];
}
Expand Down

0 comments on commit 263a4f8

Please sign in to comment.