How to get time sets by user or automatically ios - ios

I want to get value of time sets by user or automatically , is there any way to do it in ios ?
Value that i want for :
Settings > General > Date&Time > Set Automatically
or
I'm looking get correct time while there is no internet connection.When i'm set the automatically in settings,the time sets correctly by phone so is it a way that same value.
Thanks

No, you cannot access that setting value. You need to rely upon a network based time to be sure of actual time.

Related

How to use Dart's Difference Method and DateTime using a dynamic date?

The application I'm building uses a sort of "Days since" counter using Duration Difference and DateTime, but I want the counter to begin on the day they started using the app by default, and have the option to put in whichever date they desire.
My Question is, how do i dynamically generate the start date of the counter to be the day they start using the app, and would this be easiest achieved with a database?
Ok, so from my point of view a good way to do it seems to use shared_preferences. Shared preferences allow to store some key/value pair for the user, it's persistent and you can update it.
Here's the package: https://pub.dartlang.org/packages/shared_preferences
Here's a good article giving you details about it : https://www.didierboelens.com/2018/04/shared-preferences---how-to-save-flutter-application-settings-and-user-preferences-for-later-re-use/
The idea would be to create a function, checking if the key of first_use_date exists.
If it does do nothing (or you can actually update it)
If not you create it with the date of today.
Of course it's persistent since the app stays installed on the device.
For printing duration I let you check this class : https://docs.flutter.io/flutter/intl/DateFormat-class.html
And especially this method (which is not implemented yet) : https://docs.flutter.io/flutter/intl/DateFormat/formatDurationFrom.html
Hope it's helps !!

UIPrintInteractionController set minimum number of copies

I'd like to know if there's a way to set a minimum number of copies to be printed via code, because I need a document to be printed by duplicate.
I read the documentation on Apple developers page but I couldn't find anything.
I know you can set the number of copies from the printer dialog, but I need the minimum to be 2 by default.
Thanks in advance!
EDIT:
I tried this and it didn't work for me, at least in Xamarin.
There is nothing exposed via UIPrintInteractionController or its delegates that allows you to change/override the number of copies.
The way I approach this is to write my own UIController that defines the properties that the user is allowed to change and then use UIPrintInteractionController.PrintToPrinter to directly print the content.
Another approach is to disable the number of copies display:
UIPrintInteractionController.ShowsNumberOfCopies = false;
And then provide a two element array to PrintingItems vs. PrintingItem that just contains two copies of your print object.
Another approach just allow the user to select the printer via UIPrinterPickerController, save the UIPrinter to skip it in the future and then call PrintToPrinter twice.

Umbraco7 - ContentService.SaveAndPublishWithStatus VS ContentService.SendToPublication

I have an application that uses a combination of ContentService.Saved & ContentService.Saving to extend Umbraco to manage content.
I have two websites in one Umbraco installation I am using those methods to keep content up to date in different parts of the tree.
So far I have got everything working the way I wanted to.
Now I want to add a feature that: depending on which Umbraco User is logged in, will either publish the content or simply send it for approval.
So I have changed some lines of code from:
cs.SaveAndPublishWithStatus(savedNode, 0, false)
To this:
cs.SendToPublication(savedNode);
Now the problem that I am finding is that unlike the SaveAndPublishWithStatus() method, the cs.SendToPublication(); doesn't have the option of passing false so that a save event is not raised. So I get into an infinite loop.
When I attach the debugger and manually stop the infinite loop the first time it calls cs.SendToPublication(savedNode); I get exactly the behavior I want.
Any ideas about how I can get round this problem? Is there a different method that I should be using?
You are correct in saying that it currently isn't possible to set raiseEvents to false when sending an item to publication - that's a problem.
I've added that overload in v. 7.6 (http://issues.umbraco.org/issue/U4-9490).
However considering that you need this now, an interim solution could be that you make sure your code is only run once when triggered by the .Saved / .Saving events.
One way to do this would be to check the last saved date (UpdateDate) in your code. If the content was saved within the last second of the current save operation, you know that this is a save event triggered by the save happening in SendToPublication action. Then you also know that the item has already been sent to publication and that this doesn't need to be done again - thereby preventing the endless loop from happening.

How to reset the PrimaryLanguageOverride?

I have been going through the process of localizing my apps and in doing so I temporarily set the language to Chinese like this:
ApplicationLanguages.PrimaryLanguageOverride = "zh-CN";
However, after commenting out the line and rebuilding / re-deploying, now my app is still stuck in Chinese instead of what my development machine's default language at the OS level (English)!
How do I reset this to go back to the default OS setting?
Just assign an empty string to the PrimaryLanguageOverride property :
ApplicationLanguages.PrimaryLanguageOverride = string.Empty;
The PrimaryLanguageOverride setting is persisted between sessions. It
should not be set each time the app is loaded. It should only be set
based on user input presented in settings UI. The property can be read
at any time. If the property has never been set, it returns an empty
string.
So if you set the property to an empty string, the app will use the default language.

Use Tasker to disable WiFi if not connected

I want to use Tasker to turn WiFi OFF IF it is not connected to my home network. How can I do that with a variable? Thanks.
Is there any particular reason you need to use variable for that? This can be easily achieved without variables.
step 1
set a profile with a State -> Net -> Wifi connected
in a task add action set variable name it wifiConnected and set it to "yes" or "true" or whatever you want, but keep in mind that variable name must contain at least one capital letter, to be public (be visible in all tasks)
step 2
set a second profile with a State -> Net -> Wifi connected but this time select option invert (so the profile will become active, when wifi disconnected)
in a task use set variable and set it's value to "no" or "false" or whatever you want
step 3
create profile with a state -> variables -> variable value
in the left field type in variable name wifiConnected
in the right one type "no" or "false" or whatever you set it to on disconnecting
as a task for this profile use net -> WiFi -> Off
that's about it.
I'd really suggest you on reading some more about Tasker and how it works, as such things are the very basics
//edit
to do the same without setting variable, just do a profile from step 2, but instead of setting variable, use task from step 3, to disable wifi
Sorry, but I think what you wrote above does what it's supposed to do only the first time, then it needs something to trigger it automatically like a builtin variable or so...in my opinion that doesn't work as intended...no offence :)
Well, you will need something that will trigger the task for the first time, it's about the task that verifies what's the wificonnected's value. If it is "no", that means you don't have any SSIDs to connect to.You will add a wait task, let's say 2 minutes and net-wifi-off, because you will want to disable wifi if, after a specific period of time when your phone wasn't able to connect to any network.
But, you will want something continuous, in loop so you will have to add a task/goto action, like this!
Let's say you have this action:
A1: task/wait-2 minutes
A2: if %wifiConnected ~no then set WIFI off
goto A2
This way you'll phone will scan for %wifiConnected's value, continuously. As an alternative, you may cancel that loop once your wifi has already set to off because you don't need that value anymore.
I mean, your screen on-> task activated->elapsed 2 minutes-> no ssids to connect to-> wifi off
Then, you manually or not necessarly turn your wifi back on, but the task won't be triggered anymore because the screen is already on, this is why you will have to use that goto action :)
Or, you could go and disable/enable tasker such that your task( that checks for wifiConnected's value) being triggered again :)...hope that helped...my profile works like smooth :)

Resources