I would like to close the threads or clear cache if the App crashes or Phone switch off or some other abrupt actions. Please advise if this method only gets called when the user kill the App or Signout from the App.
I'm pretty sure stop() gets called when you force kill the app, switch apps, lock the screen, phone auto locks, or anything really where the app is no longer visible.
You can also check edge cases by connecting your Android (in dev mode) to your laptop, downloading platform-tools (logcat), adding a print statement inside the stop() function and using the following command "./adb logcat -s "System.out" inside the platform-tools directory. Not sure how to do it on iOS.
Related
On iOS 11, there seems to be something different in the app state when an app is backgrounded using the home button vs when it opens an external webview link and goes to safari.
On returning to my app, I am requiring the user to validate with touch ID. If the app is backgrounded using the home button and returns, the call to LAPolicy.deviceOwnerAuthenticationWithBiometrics shows a prompt and waits for the user interaction. However, the user goes to an external website through a link in the app, and returns to the app using the "Back to app" button that shows in the status bar, a call to LAPolicy.deviceOwnerAuthenticationWithBiometrics results in an error immediately without displaying the touch ID prompt.
I've checked that the application state in both cases when the call is made is that the app is active. It's being done on the main thread, and it's being made on applicationDidBecomeActive.
This is the error I see:
Error Domain=com.apple.LocalAuthentication Code=-1004 "User interaction is required." UserInfo={NSLocalizedDescription=User interaction is required.}`
Any insights into the behavior of LAPolicy.deviceOwnerAuthenticationWithBiometrics? The code used to call it is:
let context = LAContext()
context.localizedFallbackTitle = ""
print("--> internalAuthenticateBiometrics background \(UIApplication.shared.applicationState == UIApplicationState.background)")
context.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason:NSLocalizedString("Place your finger to sign in.",comment: "")) { [weak self] (success, error) in
print("--> internalAuthenticateBiometrics completion success \(success) error \(error)")
}
We discovered that this specific issue was happening on older versions of iOS 11. We were testing on devices that had iOS 11.0.3 and 11.1.2. I updated my OS to 11.4 and the issue went away.
As of right now, I can only assume that Apple fixed some app foregrounding and biometrics issues. FYI this issue didn't have anything to do with the views being backgrounded or covered, because we made sure everything was visible, appDidEnterForeground was called, viewDidAppear was happening, and we even added delays in triggering biometrics after several seconds.
I implemented a local notification test per this example https://www.codenameone.com/blog/local-notifications.html
I have the following two questions:
1) can I test local notifications from CN1 simulator. In the link above, I see a local notification test screenshot using the iPhone 6 simulator. Is there a way to force the app to run in background form the simulator in CN1?
2) If a local notification is sent when the app is running in foreground, I understand that the notification will not fire. Is the message lost in this case or is it queued somewhere?
Currently you can only test this on the device, it will work in the native simulator for iOS as you saw in the screeshot. You can run on the native iOS simulator using a Mac and include source.
The message would be lost if you fire in the foreground on iOS as it's the assumption that this is something you can notify within your app more effectively. You can determine if your app is in the foreground using the Display.isMinimized() method. In the foreground case you can use a tool like ToastBar to show a notification.
I am developing an app for Windows Universal 8.1, facing an issue where the App gets Exit on going background. The scenarios are as follows
When the app goes background on clicking Windows key(FAS), the app get exit.
When I launch Share Task i.e Data Transfer Manager Interface, after completing the share operation the app exit.
Works fine in Debug mode but issue found after deploying to the device.
PS : I am using the Navigation Service Interface to navigate to pages using MVVM and navigating from viewmodels.
Please help if its known issue, if not help to rectify this.
Thanks in advance.
Sounds like your App crashes in The Suspending Event. As apps in Debug mode are not suspended, you are unlikely to see that happen.
You can manually fire the event from Visual Studio when debugging: It is in the debugging toolbar under Application Lifecycle Events.
Most common error in this case: Using complex objects as navigation parameters, which cannot be serialized.
I have an android app designed using codename one
1)I run my application
2)I click on the home button of the phone.My app is taken away from my app and home screen is shown to me.
3)I again click on my application after navigating to it from the menu.
I expect that the state of my application be restored. But what happens is, my application restarts.
Also, this behaviour is arbitrary. Sometimes the application restarts and at other times the application resumes its state. Most of the times it restarts.
How do i ensure that my application always resumes its old state?
Android restarts running applications on some conditions to preserve RAM, battery etc. If you use the task switcher the application will resume properly but relaunching it often restarts it.
We are working on improving this behavior in the next update to Codename One, but you can use the stop method to store the application state into storage and use the start method to restore the application state.
We have a Silverlight application that runs OOB (out of browser) so the user can install it. When it's running OOB we display a button that calls Application.Current.MainWindow.Close() so that the user can exit the application. This works perfectly fine on windows, but causes an error saying the application has quit unexpectedly on OS X. Anyone have any ideas why this might be? Thanks!
Found out the problem. This is apparently a "protected" action and must be done directly in response to a user action. It cannot be scheduled to happen later (we were playing an animation on the button click and then after a timer expired trying to close the window; we have to just close the window).
An exception was actually thrown on the windows version, it just never displayed any sort of message box.