Application run different in debugger - ios

Currently working on an application and when run on the simulator or device behaves normally. When you close and reopen the application is behaving strangely.
For example I want to upload the application on the device (iPad), the first run everything is proceeding normally, then I close the application and it is open in the background and behaves strangely, cells no longer have same order.
If you delete the application and run it again after the device from Xcode everything returns to normal.
I tried both ways: Release and Debug.
I checked the code and did deallocate.
  Can someone help me with more advice? Thanks in advance!

I suppose you mean pressing the Home button when saying "close". iOS transforms your app in a special suspended state and it seems you don't restore from it correctly. iOS sends a applicationWillEnterForeground notification when your app is being restored from the suspended state and you may need to behave differently than app being launched the first time.
Here you can find more info about this method.

Related

libGDX iOS home button kills the game

I'm developing a libGDX game for Android and iOS (MobiDevelop's RoboVM fork). Android works perfectly, but I have a issue on iOS. When the iPhone home button is pressed to leave the game, and I launch the game again by tapping on icon, the game does not resume from where it was paused, but instead restarts, which means the loading screen is displayed, all assets are reloaded, and the main menu appears. Like a fresh/new start of the app. I do not have any specific configuration for the iOS module in my libgdx project and am using what was pregenerated.
Is it possible to tell iOS that I do not want to kill the process? I want to switch to pause/sleeping mode only.
I found a reason of this problem. I tested it on the real device, therefore I was unable to see a logs. When I switch to simulator and look at the logs, I found a NullPointerException. This was a cause of application crash. When I fix this bug, everything works as I expected. After iPhone home button is pressed, pause() method of com.badlogic.gdx.Screen is called and after rerun the game, it continues from exactly where it stops / pauses.
I learned a lesson: make a tests on simulator at first :-)
While I am entirely unfamiliar with libGDX, I can tell you that except for a few very specific cases (VOIP etc.), you cannot control what iOS does with your app when the home button gets pressed.
Furthermore, it is the responsibility of the developer to save the app's state when the app leaves the foreground since this is not something that is or can be handled automatically in a performant way.

In iOS 11.2, opening forcefully closed apps, sometimes shows the previously visible view and redirect to the launch screen

In iOS 11.2 application I have noticed an unusual behaviour (opening forcefully closed apps, sometimes shows the previously visible view and redirect to the launch screen), I don't know whether it is bug with OS or something else but it can sometime appear in Google app also.
You can find the related video in below link.
https://s3.amazonaws.com/uploads.hipchat.com/37040/3355524/7K3EL8N5X55tN8p/ScreenRecording_12-13-2017%2013%3A23.MP4.
Please help me to figure it out whether it is a feature or bug.
In my opinion, it's rather a bug or just normal behaviour, not a feature. There is some time before the app is dropped from the RAM, used to save some data, e.g. in appWillTerminate, etc., but it should not make an effect like you have observed. From the second hand, maybe device holds the image of how app looks like before the rage quit and shows it up, then freshly opens the app.

(iOS Swift) Some features work on simulator but not on device

I'm making an alarm app. There are two things that work on the simulator but not on my device.
1) According to this website, if UIApplicationExitsOnSuspend is set to "YES", then the app should always be running even if the device is locked (provided that it's in foreground). I used this information to make sure that NSTimer runs even if device is locked. On the simulator, no matter how much time passes by (even like 10+ hours) the NSTimer always works and the sound always fires (even if I lock the simulator screen). When I connect my iPhone device to the computer and run the app through xcode it works well too. But the problem is that as soon as I disconnect my phone and load the saved app, sometimes the NSTimer works and sometimes it doesn't.
2) Local Notifications: On the simulator the local notifications work well but on the iPhone device the notifications are fired at random times and sometimes they don't even fire. But on the simulator the local notifications fire accurately. I tested in different ways (such as setting local notification to fire 20 seconds after app loads and then exiting the app to be in background mode) but it doesn't fire on the specified time and like I said it sometimes doesn't even fire.
In such case, should I trust simulator or the iPhone device? Could this be a bug or is it something I'm doing wrong?
Always trust the device. After all, that's how the end user is going to run your app!
It is well known that you should not trust the Simulator for background behavior. The NSTimer issue is an excellent example. The problem is that the Simulator is your computer, not an iOS device. Timers do not in fact run in the background; the Simulator is misleading you. (The issue where the app behaves differently on the device if being run from Xcode vs. being run independently is a bit more suprising, but in this case I suppose it isn't all that surprising; you were very clever to think of testing both ways.)
And of course there are lots of iOS features that don't work on the Simulator at all.
I figured out the problem for #2. I simply canceled previous notifications before firing new ones.
I'm still facing issues with the first problem.

ios "Slide to View" never launches app after push notification

Im working on an IOS app in 7.1 using APNS. I get the push
notification successfully, however it never seems to launch my app
after I "Slide to View". APNS works successfully when app is in "Active"
state, and even when the device is still lit but at the home screen (no
apps running except in background), it will launch and go to the screen i want.
From everything Ive read, this should enter at 'didFinishLaunchingWithOptions'
Ive tried running the app in XCode, then hitting the home button and waiting for
the screen to timeout and go blank, then pushing a notification to see if I could
breakpoint it but that didnt work either.
Suggestions? or better way to debug this?
Any help is appreciated.
Thank you!
Turns out this is not a problem. Text messages behaves this way already.
I had thought that it launches the app but it does not, it only opens to
the home screen. Not an issue now.

UIApplicationExitsOnSuspend and screen refresh

I have an app that has the UIApplicationExitsOnSuspend info list property set to TRUE.
And now I am noticing a curious issue.
I start up the app and let it run on my phone and do not touch my phone. Eventually the phone screen goes dark and the phone goes into standby mode. When I wake the phone up, what I see is a screenshot of the last screen displayed on the app. (This seems according to spec, since the Apple documentation says that in the process of moving an app to the background, ios takes a picture of the app and uses that for transitions when the app comes back to life). If I double click on the home button to see running apps, I do not see an instance of the app running. (again, working as intended since UIApplicationExitsOnSuspend is set to true).
My question is, how do I make sure that when the phone wakes up, it comes back to the default home screen and not the picture of the app ? Clearly the app is not running on waking up, so there is nothing I can do from within the app that will refresh the screen. I could try to exit when the app is going to background, but then apple guidelines say, never exit programatically!!.
Any ideas ?
You misunderstand what is happening. If you enable UIApplicationExitsOnSuspend, this means your app will terminate when normally the app would go to the background. If you run your app then let the phone sit idle until the screen goes dark, your app is still in the foreground so it is not terminated. When a device goes into standby mode, the current app is still the current app. When you wake the device, you are not looking at snapshot of your app, you are looking at your running app. Double-tapping the Home button at this point doesn't show your app because your app is the currently running app.
Your app will be terminated if you return to the home screen or switch to another app. But it will not terminate just because the device went into standby mode.
If you want your app to return to its main screen when the device is woken up, then you need to put code in the UIApplicationDelegate applicationDidBecomeActive: method to reset your user interface.

Resources