In phonegap, is it possible to show the time in am/pm or 24-hour format according to the device settings in iOS? On the device, I can set the "24-Hour Time" to be on or off in settings. In the phonegap app, I want to adjust the time format according to the settings.
Thanks.
I checked the phoneGap documentation and there doesn't appear to be a way to know what the device time format settings are. But it's a good idea, you should submit a feature request to the Cordova (aka Phonegap) team for this feature.
http://docs.phonegap.com/en/2.0.0/cordova_device_device.md.html#Device
Now this isn't to say that a third party library doesn't exist that can work along side PhoneGap. But you would have to hunt for a plugin that does that or write your own. I did a quick Google search for this and nothing turned up for me.
You can just cordova's built in globalization plugin. If you run for example,
navigator.globalization.dateToString(
new Date(),
function (date) { alert('date: ' + date.value + '\n'); },
function () { alert('Error getting dateString\n'); },
{ formatLength: 'short', selector: 'date and time' }
);
date.value will hold a dateString that will reveal the time format (just check if "AM" or "PM" is in the string).
Related
SwiftUI DatePicker in my app is displayed in three different formats:
In Xcode Preview:
In Simulator:
On Device:
I wonder, how will the users see it?
I want it to be displayed in the "14 Jul 2022" format, "Jul 14, 2022" is also fine, but I don't like the "7/14/22" format.
Please help me - How can I do it?
EDIT: It's even worse than that (although this happens only on the simulator) - the DatePicker uses different formats in different places in my app!
The SwiftUI DatePicker adheres to the user's locale and date settings. On iPhone, you can change them in the system settings General > Language & Region as well as General > Date & Time. Usually, you should not mess with the format of the DatePicker since if you hard-code a specific format a user from a different region may get confused.
You can override the locale and thus the formatting if you really insist on overriding the user's preference:
DatePicker(…)
.environment(\.locale, Locale(…))
Try to set locale explicitly to DatePicker, like
DatePicker(
// ... other things
displayedComponents: .date
)
.environment(\.locale, Locale(identifier: "us")) // << here !!
Documentation:
i have any problems with ngx.translate on IOS.
On android device all function perfectly but on IOS ngx-traslate not work.
In the main view i can choose the language, if i choose "fr" i set "fr" in db and then i take the value from db and use : this.translate.use(lng);
In db i change correctly the value, indeed the json that i download (in other views) is with the right language, but the variable on html code {{ 'MONTH.JENUARY' | translate }} it don't take the value.
Why on ios not work?
I tried to update ngx-translate, i tried to use ionViewWillEnter, but I don't understand because it works on android and not on ios
can someone help me?
I have tried previewanyfile cordova plugin to open files from external url's in Ionic 5 application. It works well with android but on IOS I noticed sometimes it doesnt preview/open PDF files. Just a grey screen with the file name on it. But strangely some PDF files open.
file preview screen
previewProductDocument(url: string) {
const loading = await this.loadingController.create({
message: 'Loading document...',
});
loading.present().then(() => {
this.previewAnyFile.preview(url).then((res) => {
loading.dismiss();
}).catch((err) => {
loading.dismiss();
this.presentToast('Error previewing the document try later', 'danger');
});
});
}
This is the plugin I have used
https://ionicframework.com/docs/native/preview-any-file
capacitor version "#capacitor/core": "^2.2.0",
Noticed this behavior only in IOS simulator + on Real IOS device.
Any idea what is going on here?
Special character (%2F) in the link is the cause of the issue.
For a quick win; either change the link or sanitise before processing.
In this case url.replace('%2F', '/') should work.
However, another link may, probably, contain a different character. Without being 100% sure, it worth a try decodeURI, which is decodeURI(url).
I am using a simple page with 1 text field.
Display type = Date/time
Display format = Date only
Date style = default
It works on a browser on the pc but on an iPad it returns "This field is not a valid date"
I notice that when picking a date on the iPad the format is different.
On a browser it is "Apr 21, 2017"
On the iPad "21 apr. 2017"
What am I doing wrong?
regards,
Peter
I created a PMR for this and IBM came up with this workaround.
Why it happens since FP8 and not before is not mentioned.
On mobile there is a iOS picker, which allows you to select the date. An user cannot add an invalid date, so therefore client side validation is not technically required. You would allow the data to go to the server and check server validation there.
On web it is different, as in there is a date time picker and an edit box so user's can enter anything.
The client side validation is only checking that invalid data is not entered (not possible on mobile because of the native iOS/Android pickers
The server validation checks things like if it is expecting constraints such as date must be between last year & this year etc
So the suggested workaround is to can turn client side validation off for certain controls on mobile. And leave it one for web.
There is a snippet of code on the date time control which will check whether you are on mobile or web and set this to true or false based on that
<xp:this.disableClientSideValidation><![CDATA[#{javascript:
if(deviceBean.isMobile()){
return true;
}else if(deviceBean.isTablet()){
return true
}else{
return false;
}}]]></xp:this.disableClientSideValidation>
IBM Reports the fix wil be in release 9.0.1.FP9. IBM proposes another workaround. See below.You can create a custom theme in your app, with the following:
<theme extends="Bootstrap3_flat" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="platform:/plugin/com.ibm.designer.domino.stylekits/schema/stylekit.xsd" >
<control>
<name>InputField.DateTimePicker</name>
<property baseValue="com.ibm.xsp.DateTimeHelper">
<name>rendererType</name>
<value>com.ibm.xsp.theme.bootstrap.form.InputDateDetect</value>
</property>
<property>
<name>disableClientSideValidation</name>
<value>#{deviceBean.mobile || deviceBean.tablet}</value>
</property>
</control>
</theme>
Then in xsp.properties, choose the custom theme in the application theme dropdown Themes
help doc: https://www.ibm.com/support/knowledgecenter/SSVRGU_9.0.0/com.ibm.designer.domino.ui.doc/wpd_theme.html
The effect of this is to disable client side validation for date time picker controls on mobile devices only.
I know that question has been asked and answered before, I have the code I think is the right, but I can't figure it out the right syntax, I think is about the quotes and double quotes.
I'm using phonegap version 2.9, in version 2.2 I could open an external link in Safari, but I had to upgrade to 2.9 or apple won't accept my app. and of course the external links will open inside the app without the back button.
This is an app that links to a mysql database with php trough Json.
This is the part I'm having problems:
if (employee.web) {
$('#actionList').append('<li><a href="#" onclick="window.open("http://' + employee.web + '", "_system");"><h3>Website</h3> ' +
'<p>' + employee.web + '</p></a></li>');
}
This worked perfect without the onclick option (but of course in phonegap version 2.9 it opens inside the application and get stuck there).
But now is just not doing anything when I click on it.
I've been many days trying to solve this problem and is the only thing I need to complete my application.
Yeah, your quotes are a bit messed up. Doing this inline can get hairy to say the least. I would separate my HTML from my JS by creating a separate function. Try something like the below:
if (employee.web) {
$('#actionList').append('<li><h3>Website</h3><p>' + employee.web + '</p></li>');
}
function openLink(url){
window.open('http://' + url, '_system');
}