4

I am distributing the iPad application using apple's Distributing Enterprise Apps for iOS Devices.

In my app, it is very important to update the older version to prevent access of expired information. Hence, I have implemented app update mechanism as follow.

When user starts the app, each time I compare the installed build version code with one on the server by requesting the web service I have created and hosted on my own server. If there is update found, I ask user to upgrade the app via UIAlertView and when user taps on Update button, I fire the URL which points to .plist on my server as suggested here.

NSString *appUpgradeUrl = [NSString stringWithString:@"http://domain.com/manifest.plist"]; NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"itms-services://?action=download-manifest&url=%@", appUpgradeUrl]]; [[UIApplication sharedApplication] openURL:url];

Now an UIAlertView pops up on the screen and asks user for the confirmation with two buttons at the bottom, Cancel and Install. When user taps on Install, it simply gets replaced with newer version and when user taps on Cancel, it simply disappears and does nothing.

Now here is my question: I want to force user to update the app as I said, it is very important to update to newer to prevent access of expired information. Unfortunately, I am not able to do so. I want to get notified of Cancel button's click event so that I can force user to update the app by asking again for the app update via UIAlertView. Can I do so?

Let me know if there is any better idea than this to force for updating the app.

Community
  • 1
  • 1
Bharat Dodeja
  • 1,137
  • 16
  • 22
  • If they must update why provide a choice? i.e. open a dialogue that says the app must update and don't allow any user activity until it's complete. – Bejmax Feb 27 '13 at 13:56
  • @Bejmax You are right. For that I will need to create another `UIViewController` and redirect user to it where will be a message to update the app with an Update button. I am looking for an option where I can manage the behavior of system generated `UIAlertView`'s buttons. Anyway thanks for the quick response. – Bharat Dodeja Feb 27 '13 at 14:18

3 Answers3

2

As mentioned in other answers, you cannot be the delegate of a system Alert. However, since your app now knows that it is out of date, it can change its own UI, for example, to display only the manifest url as a button, and not allow the user to do anything until the app matches some version.

Richard
  • 3,316
  • 30
  • 41
1

Assign your controller as the delegate when you create the UIAlertView.

The alertView:clickedButtonAtIndex: is called when the user clicks a button on an alert view. You can decide what to do based on the index of the button clicked and setup the UIAlertView with whatever buttons you need. (See the UIAlertViewDelegate Protocol Reference.)

Bejmax
  • 945
  • 7
  • 16
  • I think you did not get my question properly. In my case, `UIAlertView` is show by the system to ask user whether they want to install app or not. So I am not able to get delegate of its button click. – Bharat Dodeja Mar 05 '13 at 10:02
  • Ditto same issue here. Any luck with identifying how to handle that "Cancel" click. – skaneria Jun 27 '13 at 16:39
-1

As we cannot access the delegate for system generated alerts. Solution I have used is, I am redirecting user to the update screen. unless user updates the app, he cannot use the functionality of it.

Bharat Dodeja
  • 1,137
  • 16
  • 22