Can an iphone app shut itself down programmatically - ios

I want the user to start the app and leave it running. At one point, the app will finish what it is doing and will shut itself down.
How can I do that in Objective-C?

This is possible by using method:
exit(0);
However, be warned that Human Interface Guideliness discourage the use of this function, as it looks as if the application had crashed. The good solution for such a usecase is to prompt user that the application has finished working, and that he may close it now.
Hope this helps,
Paul

Thanks Paul. I found another thread at Proper way to exit iPhone application?
Perhaps Apple doesnt like applications committing suicide ;)

Related

Accessing settings in an IOS app

I am trying to create an IOS app in which you assess the settings of the phone and in my case I need to access the mute setting in settings. Can someone please help me figure this out? Mainly i just want to know if you can and how to access the setting of an IOS deviceI do not have any source code yet but I will try to get some up once I get an answer or some help. Thank you
Pretty sure that is not allowed due to sandboxing restrictions.
You cannot accessing the Settings App from your own App, you can however adjust the system volume from an App if that is all you want to do.
Check out MPVolumeView.
https://developer.apple.com/LIBRARY/ios/documentation/MediaPlayer/Reference/MPVolumeView_Class/index.html#//apple_ref/occ/cl/MPVolumeView
What you are specifically writing about is not possible but you will probably find something that answers your use case in this SO question:
How to programmatically sense the iPhone mute switch?
No way to do this easily. If you want to do what you want in a one line way, take a look at this class : http://hoishing.wordpress.com/2014/05/08/mute-checking-in-ios7/

iOS Adding a device in the developer portal

I'm trying to add a device (iPhone 5) by the UUID, but the the loader never stop loading. I am not doing anything different then I normally do, but I feel like the loader will never stop since I have been waiting for a long while now.
Is there something wrong with my account or whatever or...
Thanks in advance
Use safari and not chrome, at least that seemed to be my issue.
Somehow the Apple developers site is having some issues with Chrome.
If you want to cut out the browser from this task completely you can have a look at Cupertino, part of the Nomad-cli toolset. Amazing work from #mattt
https://github.com/nomad/cupertino

Programmatically suspend/close the app

How can I suspend/close my iPad app programmatically? I wanted to show the terms of use on app start up. If user presses the Accept button the app should continue. If user presses the Decline button the app should be suspended/closed.
PS : The app is built using Titanium Appcelerator framework.
you could try calling exit() but, to be honest, i doubt that the behaviour you want is desirable. i haven't seen any other apps do it - i'm not sure it'd be considered acceptable by Apple.
You never exit from an iPhone or iPad application.
If it does apple takes it as a crash and surely reject your application.
In your case, the best solution will be displaying another screen which display a message like: "You cannot access the application until you accept the terms" or something like that.
You can use exit(0); whenever you want to exit the app. I have implemented this code in my project and it works perfectly fine for me.

iOS - kill the app with a button?

I have an app that runs for a while, but needs to be reset every day, because it's lifecycle is a bit different than most other apps. It seems that the easiest way to do this is to kill the app and re-launch it.
I found a solution that kills the app when the home button is tapped:
In your application's Info.plist, add a boolean key
UIApplicationExitsOnSuspend with the value YES
This is not something that I want to do. I need to give the user an option to kill/reset the app before it is used. I can certainly ask the user to double tap the home key and kill the app with a long press>x. Yet this is too complex for some users.
Another simple solution would be to have a button do something crashworthy, like divide by 0, although I'm not sure if the app store would penalize my app for "crashing" every single day for all users.
Has anyone found a way to add an "exit" button to an iPhone app? In android, I could do system.exit(0), which worked. What's the iPhone alternative?
iOS Human Interface Guide says -
Don’t Quit Programmatically
Never quit an iOS application programmatically because people tend to
interpret this as a crash. However, if external circumstances prevent
your application from functioning as intended, you need to tell your
users about the situation and explain what they can do about it.
Depending on how severe the application malfunction is, you have two
choices. ...
exit(0); can terminate the application (0 is a normal code), but Apple don't like this approach, and the application would be rejected in review.

iOS: Control the native Clock App from Another App

Is it possible to control the native Clock app from my app?
Is it for instance possible to start its timer, or disable and enable an alarm? I want my app to start up, do a modification, and then die.
If it's possible, where do I find more info about this?
This will be my first app. Thanks in advance!
Im pretty sure it isn't doable within public APIs, and i would be very surprised if it was doable at all. What are you trying to do?

Resources