suspend the application programmatically if no internet connection iPhone? - iphone

I have a problem which describes here
app crashes after checking network reachability in iphone?
this problem occurs when app launches at first time, and not yet solved! next solution I found is to close the app if no internet connection found at the first time of launching and tell the user to reopen.
can I use exit(0) if the action sheet ok button pressed, someone says that we can use exit(0); if we have a reason to use that.. any other solution?

Check your code and try to solve crashing problem because Quitting your application programmatically is a violation of the iOS Human Interface Guidelines, which usually doesn't well for getting through the review process:

You can use this sample application for your requirement. Provided by APPLE.
In this they have kept it under Application Delegate to be available to all the classes.
The Idea is, you will have to check status of internet connection and if it is not available than you can add a blank view containing information like you are not connected to internet and also make userinteraction to false with your application rootviewcontroller. In this way you will notify user and he/she will not be able to act further.
Again in reversal of this when u are connected to internet you need to remove that view from rootviewcontroller and make userinteraction to true.
Sample image attached herewith.
Hope it helps.

http://developer.apple.com/library/ios/#DOCUMENTATION/UserExperience/Conceptual/MobileHIG/UEBestPractices/UEBestPractices.html#//apple_ref/doc/uid/TP40006556-CH20-SW27

Related

iOS7 remoteControlReceivedWithEvent never being called

I'm building a testing app to see if I can get my app to work with remote control.
I followed the apple documentation for remote control event handling shown at:
https://developer.apple.com/library/IOS/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/Remote-ControlEvents/Remote-ControlEvents.html#//apple_ref/doc/uid/TP40009541-CH7-SW3
Right now I have a dummy app that has nothing but the function calls/implementations shown in that article.
I've put some print statements, and found out that
remoteControlReceivedWithEvent is never being called.
I've done some research, and I'm sure I didn't forget to implement
canBecomeFirstResponder
I even put a print statement in it.
When I press the play button on my apple earpod, it just plays a music from the music app and does nothing else.
Can anyone tell me what the problem is?
I'm using the latest version of iOS7
=============== Edit 1 ====================
I tested motion and touch event and they seem to be working fine.
It's just the remote controller.

Phonegap: force an app to quit instead of running in background

I'm developing an iPhone/iPad application through Phonegap, is there a way to implement a sort of "click here to quit app"? I mean quit for real, not "put it in the background and go to home screen".
Thanks in advance.
you can use following code to quite your app on click,
device.exitApp()
OR
navigator.app.exitApp()
Hope this may help you.
is there a way to implement a sort of "click here to quit app"?'
Yes, there is a way for really exiting the app and killing its process.
But never do that. Not only because Apple rejects your app if you do this. The problem with this is bad user experience. iOS is not a desktop operating system. You have a Home button for leaving apps (and again, there's a reason apps don't exit completely).
The window size is, conceptually, not spacious enough for maintaining an extraneous 44x44 pixel frame (44 pixel is the minimal size that can comfortably be touched, according to Apple's Human Interface Guidelines) dedicated only for exiting.
However, if you still want to exit after this lecture, there are several ways:
exit(0);
pthread_kill(pthread_self()); // on the main thread
[[UIApplication sharedApplication] terminateWithSuccess];
etc. Some of them may have a binding in PhoneGap (if not, it's easy enough to write one yourself).
You should not do that as this may considered as violation of iOS Human Interface Guidelines, lead rejection of your app.
Always Be Prepared to Stop
**Save the current state when stopping at the finest level of detail possible so that people don’t
lose their context when they start the app again.** For example, if your app displays scrolling data,
save the current scroll position. To learn more about efficient ways to preserve and restore your
app’s state, see “State Preservation and Restoration”.
Apple guidlines link :
http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/UEBestPractices/UEBestPractices.html
in the application's plist put
UIApplicationExitsOnSuspend = TRUE
and when the user hits the home button, the application will quit. No need for a button, no need for exit().
http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW23

How to make a Push Notification opens a specific uiview

I've been trying forever to get this to work, when I send a push notification to my app. When the user opens it, it just takes them to the app. I want to direct them to a specific uiview, how do I do that?
The method application:didReceiveRemoteNotification: is called if your app is running (whether in the background or not).
So that would be the starting point to direct them to the specific UIView.
You can tell whether your app was just brought to the foreground or not in the code in the following answer
Hope this helps .

IPhone SDK : Start my application from scratch when launched again

Here are my issues,
When I install my application on my test device it has the behaviour I want.
However if I close it with the IPhone main button and restart with the icon, it starts back from the view where I left it, whereas I would like it to restart from my main view controller (my start view).
In the same way, I load some animations with viewDidLoad in certain views. I want them to show only the first time the view is loaded each time the application is launched. Right now animations only works the first time the application is launched after installation, then they don't screen anymore when I launch again the application.
Does anyone have a clue ?
Thank you very much for your help.
(Sorry if this topic is a bit easy for you guys :D, I'm quite new at it !)
No problem about being new! This is happening because, for devices from iOS 4.0 on up, your app will support multitasking by default. To disable this features, Add the key
UIApplicationExitsOnSuspend
to your Info.plist file, and set its value to YES. Good luck!
In addition to Sam's answer above, you can also add a key named:
Application does not run in background and set the value to YES.
Both work fine, however.

Programmatically lock and unlock iPhone screen

How do I programmatically lock and unlock the main screen (i.e. the device itself) of an iPhone?
It's not possible. However, you can "prevent" your phone from locking when your app is running. [UIApplication sharedApplication].idleTimerDisabled = YES should do it.
It can be done by caling GSEventLockDevice (); from your app. This function can be found in GraphicsServices.framework.
This has already been resolved . You can find it on Github: https://github.com/neuroo/LockMeNow (work below IOS 7)
char*framework="/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices";
void *handle= dlopen(framework, RTLD_NOW);
if (handle)
{
void (*GSEventLockDevice)() = dlsym(handle, "GSEventLockDevice");
if (GSEventLockDevice)
{
GSEventLockDevice();
NSLog(#"Phone is Locked");
//.........
}
dlclose(handle);
}
It is probably possible with undocumented Apple functions (maybe GSEventLockDevice() ?) but it certainly leads to automatic App Store REJECTION.
Apple simply don't want anyone to fiddle with core functionalities like this.
If you want to do this so, Apple never approve this, your app must be jailbreak. you can do this by calling Private framework on your project. you can use GraphicsServices.framework.
NOTE :
This GraphicsServices.framework is a private framework. Apple will never accept your app. By calling GSEventLockDevice() method you can lock or unlock your Device easily. This GSEventLockDevice() resides in the GSEvent.h.
I hope this one helps you.
Please let me know if you still facing any problem
I don't believe that there is a way to achieve this.
One thing that i believe is possible is to stop the IPhone from locking. you could then build a view that copied the lock unlock function and you would still have control over the phone.
it basically isn't possible because this probably is part of the private frameworks which can be used by Apple only. There are apps such as the fake caller apps that utilize a "fake" lockscreen but as you've pointed out, pressing the home button quits the app, rendering your lock screen useless.
Describe lock and unlock. I would try a switch that enabled = YES and enabled = NO for the view property. So basically you can disable all the UIGestureRecognizers and 'lock' the screen, if this is what you mean. I do it with UIbuttons once I add them as an IBOutlet as well as IBAction, so they are an object and can be modified at the property level. I am working on this very thing right now. I will post my findings.