Firebase RemoteConfigSettings doesn't reflect minimumFetchInterval changes - swift

I'm trying to change the minimumFetchInterval for my RemoteConfigSettings. I set the value to 0 but the value doesn't update. As a workaround, I can create a new RemoteConfigSettings object, set the value there, and assign the settings to the remoteConfig instance.
let remoteConfig = RemoteConfig.remoteConfig()
remoteConfig.configSettings.minimumFetchInterval = 0
Reading back minimumFetchInterval still shows the default of 43200.
The header is defined in Obj-C as:
#property(nonatomic, assign) NSTimeInterval minimumFetchInterval;
So I would expect the value to reflect assignments.
This does work:
remoteConfig = RemoteConfig.remoteConfig()
let configSettings = RemoteConfigSettings()
configSettings.minimumFetchInterval = 0
remoteConfig.configSettings = configSettings
I am able to work around this issue, but this should be fixed. Am I missing something, or should I continue to expect these APIs to be incorrect?
The documentation of the RemoteConfigSettings class doesn't even mention the minimumFetchInterval property, but their how to docs do.

As mentioned in the link, Firebase remote config minimum fetch interval depends on 3 parameters:
parameter passed in fetch(long seconds) call.
The parameter in FirebaseRemoteConfigSettings.setMinimumFetchIntervalInSeconds(long seconds)
Default value of 43200 seconds which is 12 hours.
When using FirebaseRemoteConfigSettings.setMinimumFetchIntervalInSeconds(long seconds)
you need to do it using "Builder" pattern & set it in FirebaseRemoteConfigSettings as
get() operation on FirebaseRemoteConfigSettings does not return the original object being used by the SDK.
Also, you can see the same in sample project provided by Firebase team here. i.e.
let settings = RemoteConfigSettings()
settings.minimumFetchInterval = 0
remoteConfig.configSettings = settings

Related

"Unable to cast to Dictionary" error occurred when trying to tween

I was trying to make a tween for a text so whenever when player loaded and wait for at least 5 seconds after they loaded in, the text transparency will set to 0 smoothly
Then, I tried to make that happen with a service called TweenService but I was greeted with an error "Unable to cast to Dictionary"
I tried another way by checking the documentation and Forums but didn't find or solve any solutions
Here's my code:
local loadingrobloxos = LoadingAssetsGUI.LoadingBootBackground.LoadingRobloxOS
local goallro = loadingrobloxos.TextTransparency == 0
local tweeninfolro = TweenInfo.new(
0.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
1,
false
)
local tweenlro = TweenService:Create(loadingrobloxos, tweeninfolro, goallro):Play()
What is actually wrong?
If you look at the documentation for TweenService:Create, you'll see that the last argument of the function is supposed to be a dictionary.
TweenService:Create(loadingrobloxos, tweeninfolro, goallro)
The error is telling you that whatever you passed in for the variable goallro, it cannot be converted to a dictionary. And that line is...
local goallro = loadingrobloxos.TextTransparency == 0
This line is not creating a dictionary, it is asking the question, "is loadingrobloxos's TextTransparency currently set to zero?" So the variable goallro is set to false. TweenService doesn't know what to do with false, so it throws the error.
Instead, try this :
local goallro = {
TextTransparency = 0
}

Correct parameters for rotation using $BitmapDecoder.GetSoftwareBitmapAsync

I have this PowerShell code:
$AsyncTask = $BitmapDecoder.GetSoftwareBitmapAsync()
But discovered that some of the images coming in are rotated, so experimenting I came up with this:
$BmTf = [BitmapTransform]::new()
$BmTf.Rotation = [BitmapRotation]::None
# $BmTf.Rotation = [BitmapRotation]::Clockwise90Degrees
# $BmTf.Rotation = [BitmapRotation]::Clockwise180Degrees
# $BmTf.Rotation = [BitmapRotation]::Clockwise270Degrees
$AsyncTask = $BitmapDecoder.GetSoftwareBitmapAsync(
[BitmapPixelFormat]::Bgra8,
[BitmapAlphaMode]::Ignore,
$BmTf,
[ExifOrientationMode]::IgnoreExifOrientation,
[ColorManagementMode]::DoNotColorManage
)
While it does work, I'm not familiar BitmapPixelFormat, or the other parameters. The documentation for GetSoftwareBitmapAsync() doesn't appear to give any hints on what the default value it is using for BitmapPixelFormat.
Does anyone know the best values to pass to the version of GetSoftwareBitmapAsync() that takes 5 parameters to mimic the version of GetSoftwareBitmapAsync() that takes 0 parameters?
EDIT:
Just found out that trying [BitmapPixelFormat]::Unknown causes this error:
Exception calling "GetSoftwareBitmapAsync" with "5" argument(s): "The
parameter is incorrect. Windows.Graphics.Imaging: The bitmap pixel
format is unsupported."
But no errors with [BitmapPixelFormat]::Bgra8.
I don't know why GetSoftwareBitmapAsync doesn't like [BitmapPixelFormat]::Unknown, but here is the solution I found.
I need to first load the image to see if it needs rotating. That is done with the original command:
$AsyncTask = $BitmapDecoder.GetSoftwareBitmapAsync()
$SoftwareBitmap = GetAsync( $AsyncTask, ([SoftwareBitmap]) )
Then extract its BitmapPixelFormat:
$BitmapPixelFormat = $SoftwareBitmap.BitmapPixelFormat
And then use $BitmapPixelFormat for all calls to the 5 parameter version of GetSoftwareBitmapAsync().

Migration to change the configuration of CoreData

I started a macOS project using Default configuration of CoreData. Application was released and some users started to use it. Now, I need some data to be synced with iCloud and some data to be only stored locally. If I understand correctly, the only way I can achieve this is to create two different configurations (in CoreData data model), add the needed entities in each configuration, and configure the NSPersistentContainer accordingly.
However the above method might lead to some data loss since I wont be using the Default configuration anymore.
Is there any way I can "migrate" the data saved under the Default configuration to another configuration?
After some trial and error I found a solution that seems to do the work (however, it seems dirty).
First, when instantiating the container, I make sure I add my 3 storeDescriptors to persistentStoreDescriptions (each representing an scheme)
let defaultDirectoryURL = NSPersistentContainer.defaultDirectoryURL()
var persistentStoreDescriptions: [NSPersistentStoreDescription] = []
let localStoreLocation = defaultDirectoryURL.appendingPathComponent("Local.sqlite")
let localStoreDescription = NSPersistentStoreDescription(url: localStoreLocation)
localStoreDescription.cloudKitContainerOptions = nil
localStoreDescription.configuration = "Local"
persistentStoreDescriptions.append(localStoreDescription)
let cloudStoreLocation = defaultDirectoryURL.appendingPathComponent("Cloud.sqlite")
let cloudStoreDescription = NSPersistentStoreDescription(url: cloudStoreLocation)
cloudStoreDescription.configuration = "iCloud"
cloudStoreDescription.cloudKitContainerOptions = "iCloud.com.xxx.yyy"
persistentStoreDescriptions.append(cloudStoreDescription)
let defaultStoreLocation = defaultDirectoryURL.appendingPathComponent("Default.sqlite")
let defaultStoreDescription = NSPersistentStoreDescription(url: defaultStoreLocation)
defaultStoreDescription.cloudKitContainerOptions = nil
defaultStoreDescription.configuration = "Default"
persistentStoreDescriptions.append(defaultStoreDescription)
container.persistentStoreDescriptions = persistentStoreDescriptions
Note: One important thing is to make sure that NSPersistentStoreDescription with the Default configuration is added last.
Secondly, I am for-eaching thought all data saved in core data checking if managedObject.objectID.persistentStore?.configurationName is "Default" (or any string containing Default. With my empiric implementation I got to the conclusion that configuration name might be different from case to case). If the above condition is true, create a new managedObject, I copy all properties from the old one to new one, delete the old managed object, and save the context.
for oldManagedObject in managedObjectRepository.getAll() {
guard let configurationName = oldManagedObject.objectID.persistentStore?.configurationName else {
continue
}
if (configurationName == "Default") {
let newManagedObject = managedObjectRepository.newManagedObject()
newManagedObject.uuid = oldManagedObject.uuid
newManagedObject.createDate = oldManagedObject.createDate
......
managedObjectRepository.delete(item: oldManagedObject)
managedObjectRepository.saveContext()
}
}
With this implementation, old data that was previously saved in Default.sqlite is now saved in Local.sqlite or 'Cloud.sqlite' (depending on which configuration contains which entity).

How to read UnitPrice from invoice line in QBO API v3 .NET

The bizarre properties in the .NET SDK continue to baffle me. How do I read the UnitPrice from an invoice line?
If I do this:
sild = (SalesItemLineDetail)line.AnyIntuitObject;
ln = new QBInvoiceLine(); // My internal line item class
ln.Description = line.Description;
ln.ItemRef = new QBRef() { Id = sild.ItemRef.Value, Name = sild.ItemRef.name };
if (sild.QtySpecified)
ln.Quantity = sild.Qty;
else
ln.Quantity = 0;
if (sild.ItemElementName == ItemChoiceType.UnitPrice)
ln.Rate = (decimal)sild.AnyIntuitObject; // Exception thrown here
The last line throws an invalid cast exception, even though the debugger shows that the value is 20. I've tried other types but get the same exception no matter what I do. So I finally punted and am calculating the rate like so:
ln.Rate = line.Amount / ln.Quantity;
(With proper rounding and checking for divide by zero, of course)
While we're on the subject... I noticed that in many cases ItemElementName == ItemChoiceType.PriceLevelRef. What's up with that? As far as I know, QBO doesn't support price levels, and I certainly wasn't using a price level with this invoice or customer. In this case I was also able to get what I needed from the Amount property.
Try this-
SalesItemLineDetail a1 = (SalesItemLineDetail)invoice11.Line[0].AnyIntuitObject;
object unitprice = a1.AnyIntuitObject;
decimal quantity = a1.Qty;
PriceLevelRef as an 'entity' is not supported. This means CRUD operations are not supported on this entity.
The service might however be returning readonly values in the transactions sometimes, but since this not mentioned in the docs, please consider it as unsupported.
Check that both request/response are in either json or xml format-
You can use the following code to set that-
ServiceContext context = new ServiceContext(appToken, realmId, intuitServiceType, reqvalidator);
context.IppConfiguration.Message.Request.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
context.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
Also, in QBO UI, check if Company->sales settings has Track Quantity and Price/rate turned on.

AMFPHP overiding default function arguments?

I've got this odd problem.
If I make a call on that function through amfphp service browser and give it a valid ID and leave the $num_images field blank amfphp will actually pass a blank string as the argument.
// if i call this function width just an ID
function getWorkers($id, $num_images = 100) {
...
// num_images will be set as ''
}
I can easily override using a check:
function getWorkers($id, $num_images = 100) {
if($num_images=='') $num_images = 100;
...
// num_images will now be really set as 100
}
Anyone experiencing the same with amfphp?
That's odd, I never got that from AMFPHP. If you don't have the latest version try updating your installation of AMFPHP. Also make sure Flash doesn't somehow pass an empty variable as the second variable.
(Copied from the comment.)