-2

For an unknown reason, when I kill my app in the recent menu and try to launch it again, the last screen where I was appear again and the device is frozen. What I have to do is a hard reboot and after that, launching the app again work...

Alternatively, if I want to relaunch my app after the kill in recent without a reboot, I have to type this command in mobile Terminal

killall myapp

and after this, if I try to launch my app from homescreen, my app is working correctly...

What I wanted to know is how could I detect when the user exit the app with the home button and thereby launch an NSTask that send killall command ? I know NSTask is not allowed by Apple but this is a jailbreak app that is not intended to be published on Apple Store.

Also this bug really bored me... in viewDidLoad I've several NSTask and method that check if directory exist. Do you think that these things can disallow the app from being relaunched after a kill in recent and freeze the device ? Or this is because the app run as root and there is somethings to do especially from allow the device to relaunch the app in this situation ?

Thanks in advance for your help !

Synny
  • 542
  • 1
  • 4
  • 18
  • 1
    Yeah it's most certainly buggy code. But who knows, without seeing any? – Droppy Oct 20 '14 at 08:42
  • Yeah I know, but this is just some basic NSTask and Obj-C methods to check existing directory, that's why I've not posted any code sample. I'll try to remove that part of code to see if this the root of the issue. For the first question, do you know how to detect the exit of the app ? – Synny Oct 20 '14 at 09:03
  • Well using `NSTask` to check for the existence of directory is your first mistake. There are API methods provided for such things. – Droppy Oct 20 '14 at 09:40
  • I misspoke ^^ I check existing directory with Obj-c methods and create directory (if not existing) with NSTask and mkdir. Now, I've put the creation of the directory into the preinst script so no more need to mkdir into viewdidload, I'll have to remove this part of code so... – Synny Oct 20 '14 at 09:51

2 Answers2

1

First off, I want to point out that using NSTask isn't always the answer. You can use NSFileManager. to manage files and directories, and you can use exit(0) to terminate your process.

As far as your actual question, is your application running as root? When applications are told to close by iOS, they are sent a SIGSTOP signal by SpringBoard. Since SpringBoard runs as mobile, these signals are sent by the mobile user, meaning that root applications will not receive them. This means that whenever a root application is told to quit, it just ignores the request and keeps executing. To fix this, there is a key in the Info.plist you can change.

Go ahead and set UIApplicationExitsOnSuspend to the boolean true in your Info.plist and see if that fixes your problem.

Ryan Pendleton
  • 2,566
  • 19
  • 29
0

Ok for the first question I've found how to: I've placed a NSTask method into didEnterBackground (AppDelegate class) that kill the app when the user exit the application

For the second question I really don't know... I've deleted the method placed into viewDidLoad to see if that was the cause of the issue but nothing, as soon as I kill the app in the recent and try to relaunch it, the device froze.. Because there is nothing in viewDidLoad method, I think the issue is caused by the root right... The NStask in DidEnterBackroung solve this issue

Synny
  • 542
  • 1
  • 4
  • 18