iPhone: Quitting aplication using [[UIApplication sharedApplication] terminateWithSuccess]; - iphone

I have built a small app that gets informations from a database on a website.
the first thing the app does is to fetch an rss feed and then display it.
Apple guidelines tell to let the user decide if he/she wants to connect to the Internet, so I have placed an alert at the beginning showing "The app will connect to the Internet. Continue?" with two buttons: "Yes", and "No, quit"
if the user chooses "No, Quit", then I call:
[[UIApplication sharedApplication] terminateWithSuccess];
It Works. But I have read that Apple disencourage that, (Not an official API???) and that the only way to terminate an app should be the use of the Home button.
I tried an alernative: if the user press "No, Quit" I simply show a label that says "Quit the app using the Home Button"...
So, what should I do? leave the alert and quit the app or just show the "please quit" label???

You may never actively terminate your app, otherwise Apple will reject the app (I know by experience ;-). Only thing you can do is show a dialog, e.g. a UIAlertView without any buttons, asking the user to quit via home button.
But I never heard about the guidelines you've cited regarding an Internet connection. Please give a link. I've worked on a lot of apps that connect to the Internet without asking and Apple never complained.

Just leave off the "No" button.
Either the user will hit "Yes" and connect, or the user will terminate (or background) your app by switching to another app, since they have no other choice.
App termination by simply forcing the user to do something reasonable.

Related

Programmatically exiting iPhone app following rejected disclaimer

I'm currently working on an iPhone app that requires the user to accept a terms of use/disclaimer. If the user does not accept the disclaimer, I would like the app to close.
It is my understanding that exit(0); is frowned upon (as discussed at Proper way to exit iPhone application?) and the Human Interface Guidelines state that the only time an application should close is via user intervention.
What is the best practice for stopping the functionality of my app if the user presses a 'Reject' button for the disclaimer?
Should exit(0); be called, or is there a more graceful way to close the app? I'm not necessarily worried about removing the app from memory -- I'm just wanting the app to kick the user back to the home screen.
Does the user pressing a 'Reject' button constitute user intervention, consistent with the Human Interface Guidelines?
The correct way to handle this would be to write your terms into the EULA that goes along with your application. The gatekeeper then becomes the App Store, and this problem goes away. You can then assume that anyone running your app has agreed to the terms.
Apple provides a standard EULA, but your laywers can supply you with a custom one. Apple just has a few requirements that that custom EULA's terms must meet.
In my opinion, the best thing to do after user taps "reject" is to give him a sorry message without any button to proceed. In other words, the user will have nothing to do without pressing the home button. It's better than exit(0) as that looks like a crash.
In my case I had a message at the beginning of my app stating that some amount of data should be downloaded before continuing, with two buttons to "Continue" or "Exit" the app. The "Exit" button didn't really exit but just bring to front the Safari browser to show our home page.
And this app got rejected by the App Store reviewers just because of that Exit button. The funny thing is they rejected the app when submitting my second update to the original version! (the two previous versions had been approved just fine and had that very same "Exit" button).
Anyway, it seems it's important not to exit your app in any way.
Your app will almost certainly be rejected if you force it to quit programatically. You should simply present a pop-up informing the user they cannot use the app unless they accept the disclaimer, and ask them to press the Home button to exit. Basically, don't kick the user out of the app at any point. Let them decide when to leave.

Can I require that a user enable push notifications?

Naturally this is programmatically possible (using enabledRemoteNotificationTypes). This is a policy question.
Can I require that a user has push notifications enabled to be allowed to use an app, or will this behaviour cause the app to be rejected by Apple?
The App Store Review Guidelines includes a section on push notifications (§ 5), but does not cover this.
Sometimes I might not want any notification from any application because I am busy. Therefore I turn Notifications on or off as I choose. All you can do is display an UIAlertView reminding the user that push notification is disable when they enter your app.
Submit and see what happens. First, try it with the app closing itself if the user has push notifications turned off, showing them an alert letting them know why the app won't run and how to fix it (and a button that will take them to the right part of Settings if that's possible). If Apple rejects it, then just take out the app quiting code and let them continue by dismissing the nag screen.
Like you say, there's nothing explicitly forbidding it in the guidelines that you can find, so the only way to get an answer is to submit code and see what happens, since you generally can't get a straight answer out of Apple regarding these issues until you have something specific and real for them to consider.

Immediately exit this iPhone app if launch-password is wrong

The iPhone app I'm writing has an option in the SETTING page: "ask for password when launching this app". (As a security measure.)
If the user types in the correct password... the app runs.
If the user types in the wrong password... the app needs to immediately exit.
There isn't any kind of "immediately exit this app" in any framework (that I can find).
What is the app-store legal way to do this?
http://developer.apple.com/library/ios/#qa/qa2008/qa1561.html
There is no API provided for gracefully terminating an iPhone application. Under the iPhone OS, the user presses the Home button to close applications. Should your application have conditions in which it cannot provide its intended function, the recommended approach is to display an alert for the user that indicates the nature of the problem and possible actions the user could take - turning on WiFi, enabling Location Services, etc. Allow the user to terminate the application at their own discretion.
Just display a screen that says "The password you entered is invalid." Not sure why you wouldn't allow them to try again, though - I'd find being made to relaunch the app each time I make a typo quite frustrating.
There is none. Applications are not supposed to exit. What you can do, however, is what an application I wrote that needed network access does: present a UIAlertView with no buttons so that the user is forced to quit the app (press the home screen button).
Just keep in mind that with iOS 4.0 and multitasking, you’ll have to give the user another opportunity to enter the password if the application is put into the background and then restarted.
You can use
exit(0);
although not recommended as explained by others.

iPhone Notifications is possible to

I read more post regarding iPhone notification, and I have a simple question....
Where a device receive a notification (so I can display a message contains the message notificatio ti advise the user).
I understand that message is managed by the application.
The question is:
...when my application receive the notification is it possible to start it?
Or in other world the application became run when receive the notification or it simple became active only to manage the message and at the end of notification management the app return to sleep?
The main application windows is opened on the device ?
Many thanks in advance
Lukenukem
Ciao
With push notifications you can prompt the user to take action, which if they agree (by tapping the "open application" button), will open the application automatically.
The caveat is that you can't do this without the users consent. They have to tap the open application button for your app to open. There's no way to open the app automatically without the user's action, nor is there any way to open, perform the required actions and quit the app automatically.
The apps dont "sleep" they are either running or not (till 4.0 OS that is), im assuming you are asking about push notification, what happens when a user receives a notification is that they can choose to close it, or go ahead and "view" the notification which can cause the app to open automatically...thats as far is it goes in the current system i blive...

Attach XCode Debugger

I'm developing an iPhone app that needs a web login.
As usual I call
[[UIApplication sharedApplication] openURL:loginURL];
This close the app and calls the login page inside Safari.
Once logged, the app is opened once again using a callback address and the iPhone URL registration feature.
The question here is:
Since the app is closed when I call Safari, the debug stops. How can I continue the debug?
Thanks
You can, however, get XCode to connect to an application the next time it's launched. You bring up the inspector on your executable and check the "Wait for next launch/push notification" box. This is explained in more detail here.
The other alternative would be to use a UIWebView inside your app rather than switching to Safari.