Crashes on iOS 14.4 when selecting 'Cancel' or 'Done'
Make sure to check the demo app(s) for sample usage
Issue occurs on the sample app and my app.
Make sure to check the existing issues in this repository
Checked.
If the demo apps cannot help and there is no issue for your problem, tell us about it
Please, ensure your title is less than 63 characters long and starts with a capital letter.
This occurred after upgrading from NS6 to NS7. Crash occurring on iOS intermittently (about 50% of the time) after selecting either 'Cancel' or 'Done' on the datepicker, regardless of PickerOptions or the date selected. If the crash does not occur then it will not occur until the app is closed, reopened, and you try again.
Which platform(s) does your issue occur on?
- iOS/Android/Both
- iOS/Android versions
- emulator or device. What type of device?
Real device and emulator - iOS 14.4.
Please, provide the following version numbers that your issue occurs with:
- CLI: (run
tns --versionto fetch it) - Cross-platform modules: (check the 'version' attribute in the
node_modules/@nativescript/core/package.jsonfile in your project) - Runtime(s): (look for the
"tns-android"and"tns-ios"properties in thepackage.jsonfile of your project) - Plugin(s): (look for the version numbers in the
package.jsonfile of your project and paste your dependencies and devDependencies here)
dependencies: "@nativescript/appversion": "2.0.0", "@nativescript/core": "7.3.0", "@nativescript/webpack": "4.1.0", "moment": "2.29.1", "moment-timezone": "0.5.33", "nativescript-modal-datetimepicker": "2.1.5", <-- (I tried lower versions as well, like 2.0.1) devDependencies: "@nativescript/android": "7.0.1", "@nativescript/ios": "7.2.0",
CLI: 7.2.1
Please, tell us how to recreate the issue in as much detail as possible.
Describe the steps to reproduce it.
- Open the sample app
- Tap 'Pick a Date'
- Tap 'Cancel' or 'Done'
- If the issue does not occur, close the app completely and go to step 1
Is there any code involved?
- provide a code example to recreate the problem
- (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible.
@davecoffin Any help would be appreciated as this will heavily impact our app. Thank you.
Do you have a catch block in your code? like .catch( after .then? I removed it and no longer having the crashing error.
@enich-dev did this work for you?
I tried @pandabuilt's suggestion and it didn't work, the app still crashes when tapping the Done button on the date picker modal even when the catch block is removed. Here is the code:
export function showDatePicker(title: string, value: Date): Promise<Date> {
const picker = new ModalDatetimepicker();
return picker
.pickDate({
title: title,
theme: 'light',
startingDate: value
})
.then(result => {
console.log('in then, result: ', result);
return result ?
new Date(result.year, result.month - 1, result.day) : null;
});
}
Interestingly, it doesn't make it into the then or catch functions when it crashes, nor does it show any errors in the logs. It simply quits the app. Then if I reopen the app, the date picker works fine. Forcing a rebuild of my app causes it to error again when I tap the Done button in the date picker modal.
Some observations that I had that contradict others' experiences in this ticket:
- I can observe this error only when tapping the Done button. Tapping the Cancel button works fine for me every time.
- I can reproduce this error not just on iOS 14.4 but also iOS 13.2, so it doesn't seem to be specific to 14.4.
- It works fine on Android, no crashes.
Was anyone able to get past this error?
Nevermind, I stand corrected. It's reopening the app that works not my removal of the catch block.
i have the same error...
Hey all, unfortunately my team and I did not have time to dig into this further and we decided to use NativeScript's own datetimepicker that can be found here. In doing so, we are no longer seeing crashes. I hope this will help others as well. Thanks.
i have the same problem.
@Atomico001 As @enich-dev suggested, switch to NativeScript's datetimepicker. It works much better.
@Atomico001 As @enich-dev suggested, switch to NativeScript's datetimepicker. It works much better.
Thanks you, i have a problem... other plugin ask me the "context", i tried application context but doesn't work.. any idea?