changes in firebase-admin from ver5.2 to 5.10 makes my code not working - firebase-admin

I started to use firebase for a project around a year ago at the suggestion of my son who wrote an android application for a project I got. We were able to figure how to do some basic requests and everything worked fine. I noticed that the version of the firebase-admin changed a lot(I was using 5.2 and now the latest version is 6.3 and when I tried my code in a development environment for my surprise It doesn't work and I couldn't find so far documentation on the changes. Here is a snippet of my code which works with version 5.2 and would not work in version 5.11(or 6.3).
ValueEventListener eventListener;
eventListener = jobRef.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot technicianSnaps : dataSnapshot.getChildren()) {
if (!technicianSnaps.getKey().equals("filler")) {
for (DataSnapshot serviceRequestsSnap : technicianSnaps.getChildren()) {
for (DataSnapshot srSnap : serviceRequestsSnap.getChildren()) {
if (srSnap.child("Date").getValue() == null){
jobRef.child(technicianSnaps.getKey()).child(serviceRequestsSnap.getKey()).child(srSnap.getKey()).setValue(null);
}
so basically I want to delete a record which was incorrectly set in firebase and i'm trying to set the value to null. everything is set correctly and when I change to version 5.2 it deletes the record, but in version 5.11 it just gets out of the loop. it seems that the method setValue(Object value) was deprecated and other methods replaced it - setValue(Object Value, CompletionListener listener). I cannot find much info about what how CompletionListener is set and how to use it. If anyone has a link to the documentation I will try to read and understand how to change it. thank you

Use setValueAsync(), which returns a Future and then wait on the Future. The main thing that has changed is that the SDK no longer uses the Task API for async operations. You can find more details here: https://medium.com/google-cloud/firebase-asynchronous-operations-with-admin-java-sdk-82ca9b4f6022

Related

Why is dataObjectDeserializer.getObject() not present?

I have created a spring-boot server for handling stripe webhooks.
However, webhooks are working - I am getting an event, but when i try to get the value of dataObjectDeserializer.getObject() its null. Any ideas why that might be and how to fix it.
Here is the code:
Event event = null;
try {
event = Webhook.constructEvent(
payload, sigHeader, endpointSecret
);
} catch (SignatureVerificationException e) {
// Invalid signature
logger.info("Webhook error while validating signature.");
return "";
}
EventDataObjectDeserializer dataObjectDeserializer = event.getDataObjectDeserializer();
StripeObject stripeObject = null;
if (dataObjectDeserializer.getObject().isPresent()) {
stripeObject = dataObjectDeserializer.getObject().get();
} else {
// Deserialization failed, probably due to an API version mismatch.
// Refer to the Javadoc documentation on `EventDataObjectDeserializer` for
// instructions on how to handle this case, or return an error here.
}
I ran into the same issue recently.
In my case (Which I believe might be yours as well). Is that the Event is not being properly deserialized because a version mismatch between the API you are using in your account and the models of the Stripe SDK in your project. You can check this by looking into: Event.getApiVersion() and Stripe.API_VERSION.
If they differ then you will need to properly upgrade them and take in consideration migration guidelines if they apply to your scenario.
On my case since it was a first time I didn't need to go through any migration and I just simply when to my dash board and upgrade the sdk:
Dashboard Note: It displays rollback because I did upgrade it. If you haven't you will have a "Upgrade" option available.
You can find more info on their documentation page:
Upgrade Stripe API
Versioning
Hope this helps!

How to load plugins when updating to MvvmCross 6.4.2 from 5.6.2

I've been tasked with maintaining a Xamarin native project using MvvmCross 5.6.2. Not knowing exactly how to approach this, I've decided to update to one major version at a time (6 first, then 7 and 8). I'm not sure why I specifically have chosen 6.4.2, but it was maybe because this was the latest version of the majority of the plugins I was using on Nuget.
So far, the update has been a success and I have been able to fix all build errors. However, when running the application, I've been getting a null reference exception which I can't fully trace.
Based on the limited application output, I've been able to determine that the problem lies somewhere in my Android's setup.cs class (I think). I've been following Nick's .NET Travels advice on MvvmCross debugging. From viewing the MvvmCross 6.4.2. source and pasting in the following code in my own overrides:
public virtual void LoadPlugins(IMvxPluginManager pluginManager)
{
Type pluginAttribute = typeof(MvxPluginAttribute);
IEnumerable<Assembly> pluginAssemblies = GetPluginAssemblies();
foreach (Assembly item in pluginAssemblies)
{
IEnumerable<Type> enumerable = item.ExceptionSafeGetTypes();
foreach (Type item2 in enumerable)
{
if (TypeContainsPluginAttribute(item2))
{
pluginManager.EnsurePluginLoaded(item2);
}
}
}
bool TypeContainsPluginAttribute(Type type)
{
object[] customAttributes = type.GetCustomAttributes(pluginAttribute, inherit: false);
return ((customAttributes != null && customAttributes.Length != 0) ? 1 : 0) > (false ? 1 : 0);
}
}
public virtual IEnumerable<Assembly> GetPluginAssemblies()
{
string mvvmCrossAssemblyName = typeof(MvxPluginAttribute).Assembly.GetName().Name;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
var test = from asmb in assemblies.AsParallel()
where AssemblyReferencesMvvmCross(asmb, mvvmCrossAssemblyName)
select asmb;
return test;
}
I'm able to see that GetPluginAssemblies doesn't return any enumerable, and the LoadPlugins method then produces the NullReferenceException. But I can't see what this NullReference actually is.
I followed the upgrading from 5 to 6 guide https://www.mvvmcross.com/documentation/upgrading/upgrade-to-mvvmcross-60.
I looked at the MvvmCross 6 and 6.4.0 release pages:
https://www.mvvmcross.com/mvvmcross-6.0.0-release/
https://www.mvvmcross.com/mvvmcross-6.4.0-release/
And I followed Benjamin Mayrargue's guide: https://medium.com/#bigoudi/upgrading-from-mvvmcross-5-to-mvvmcross-6-7ded83ecb69d
But I have been unable to load my plugins (previously they were bootstraps, but most of the guides say these can be discarded now and that loading plugins is easier).
I also attempted the answer suggested in this question How to use an mvvmcross plugin such as the file plugin.
But to no avail.
So I am asking if anyone knows a good guide or how to use plugins in MvvmCross 6.4.2.
Thank you.
Plugins are just a way to register things in the IoC Container. This is done by MvvmCross during startup using the LoadPlugins method in your Setup file.
Most of the time it should just work. However, there are some caveats.
If the Linker has gone ahead and linked away some of the plugins code, you will have a bad time. What you can do about that is to hint the mono linker to not strip the code away.
Add a LinkerPleaseInclude class and add a Include method in it that looks something like:
new MvvmCross.Plugin.Color.Platforms.Ios.Plugin().Load();
You can do that for every plugin you may want to use.
If LoadPlugins doesn't find the entry Assembly, sometimes it also does not register the plugins. You can override LoadPlugins in your Setup class and just call EnsurePluginLoaded:
public override void LoadPlugins(IMvxPluginManager pluginManager)
{
base.LoadPlugins(pluginManager);
pluginManager.EnsurePluginLoaded<MvvmCross.Plugin.Color.Platforms.Ios.Plugin>();
}
I want to thank Cheesebaron for his plugin support. I think I've fixed my issue and as it turned out, I don't think there is a plugin issue after all (yet).
Thanks to Toolmakersteve also. His suggestion for using a try catch in the OnCreate of my overridden MvxSplashScreenAppCompatActivity surfaced an issue with setting a theme for this activity. In actuality, this class was initially a MvxSplashScreenActivity.
Reverting this line, I then started getting NullReferenceExceptions on specific lines, all relating to IoC and lazy construction of singletons. The class Mvx seemed to be throwing up this error. On a sort of hunch from previous experience with my updating, I removed the MvvmCross.Platform using statement and checked what suggestions Mvx had available to it. It suggested MvvmCross and MvvmCross.Platform, so I tried the former instead. Sure enough, this moved my execution further, throwing up more Null Reference Exceptions. I also encountered one instance of failing to resolve IMvxResourceLoader from MvvmCross.Platform.Platform. Switching that to MvvmCross.Base did the trick.
This was only a chance fix through a bit of guess work. #CheeseBaron, should I add this as a note to this bit of documentation https://www.mvvmcross.com/documentation/upgrading/upgrade-to-mvvmcross-60? As mentioned, I'm as far as 6.4.2 now, so I'm not certain this is the right place for it.
I've got a few bugs with embedded resources to fix now, but if I encounter any more that are relevant to my question, I'll list them here.

Using an Android library that extends AppCompatDialog

So I'm trying to create a plugin that uses PrettyDialog (https://github.com/mjn1369/PrettyDialog) using the latest NativeScript seed.
However I've run into the following error when compiling:
Error: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
That happens using the following code, and calling show() (TypeScript):
export class PrettyAlert {
show() {
const alert = this.createAlert();
}
createAlert(width?: number) {
return new libs.mjn.prettydialog.PrettyDialog(app.android.context);
}
}
I've been looking into the error here (pure Android): You need to use a Theme.AppCompat theme (or descendant) with this activity
But none of the solutions have worked.
I figure it possible somehow, but I'm new a plugin building, and I'm sure there's some quirks I need to understand.
There are similar plugins - fancyalert / cfalert already if you are not very choosy about PrettyDialog.
NativeScript introduced support for AppCompatActivity from v5.x which seems just hit live. You should bypass this error if you upgrade to latest version.

Is ControllerBase.Execute(RequestContext) obsolete in MVC5?

I am upgrading a web site from MVC3 to MVC5. I simply used NuGet to install Microsoft.AspNet.Mvc version 5.2.3 and everything seemed to be working fine. But upon closer examination I noticed that this code was no longer running:
public abstract class BaseController : System.Web.Mvc.Controller
{
protected override void Execute(RequestContext requestContext)
{
LogRequest();
UpdateUserSession();
base.Execute(requestContext);
}
}
I found this lifecycle documentation (linked from here) which seems to confirm that Execute is no longer called by MVC.
However, this documentation is unclear, saying
This method is an implementation of Execute. You typically do not have to override this method. Override Initialize or ExecuteCore instead.
I would expect it to say "This method is no longer called by the MVC framework as of version 5 (or maybe 4)." Perhaps even mark it [Obsolete], although there may have been good reasons not to do that.
Furthermore, my testing shows that ExecuteCore does not get called either! It looks like OnActionExecuting is the best place to move the code that used to live in Execute, is that correct?
Maybe it helps to anybody:
Old version:
errorManagerController.Execute(requestContext);
New version:
Response.RedirectToRoute(routeData.Values);

V8 "Platform" is null

I'm calling "Isolate->IdleNotification(100)" within an isolate scope (via "v8::Isolate::Scope ..."), and at some point when "V8::GetCurrentPlatform()->CallOnBackgroundThread(...)" is called within V8, "V8::GetCurrentPlatform()" returns NULL, and the whole thing dies a fatal death. Any ideas why the current platform might be null? Or rather, what should be done to make sure it isn't? Everything else seems to be working just fine.
Addition details: I'm using Visual Studio 2013, and compiled the source, the resulting libraries of which I use with the V8.Net wrapper (on codeplex). I run the following code before triggering the idle notification call:
v8::Locker __lockScope(engine->Isolate());
v8::Isolate::Scope __isolateScope(engine->Isolate());
v8::HandleScope __handleScope(Isolate::GetCurrent());
I tried different combinations, and it seems only v8::Locker __lockScope is required, but the platform is still null;
v8::Platform* V8::GetCurrentPlatform() {
DCHECK(platform_); // <-- 'platform_' is NULL
return platform_;
}
Got this working shortly after, but forgot to post the answer. Here it is: Google changed stuff (surprise! :/), and now you have to initialize a platform first. I did this and it all works again:
v8::V8::InitializePlatform(v8::platform::CreateDefaultPlatform());
// Sets the v8::Platform to use. This should be invoked before V8 is initialized.
v8::V8::InitializeICU();
// Initialize the ICU library bundled with V8. (if using the bundled ICU)
v8::V8::Initialize();
// Initialize V8.

Resources