firebase.initializeApp() vs FirebaseApp.initializeApp() - javascript

I currently trying to set up push notifications using the Notifications package from 'expo-notifications', Im just getting the following error and I cant work around it:
[Error: Encountered an exception while calling native method: Exception occurred while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager: Default FirebaseApp is not initialized in this process com.-----.-----. Make sure to call FirebaseApp.initializeApp(Context) first.]
The thing is, this message is completely enraging me because I do call:
import * as firebase from "firebase";
and after that:
firebase.initializeApp(ApiKeys);
at the start of my app.
Do I now need to install the Firebase/App package so I can do FirebaseApp.initializeApp()? Do I need to initialize my app 2 times then?
Neither the docs from expo are mentioning such an error, nor I found anything related to this error in the firebase docs and Im really struggling with this one.

Aperently there is an import into the app/build.gradle file which is not mentioned inside the expo docs at all. Its the following line which is missing:
implementation("com.google.firebase:firebase-iid")
you need to put it inside your app/build.gradle file to make it work.
I found it in the following forum, the posts are just one month old so its a quite new bug.

Related

Jest with Leaflet Markercluster

I have an issue testing something related to markerCluster. I'm using the leaflet.markercluster npm package, version 1.5.1. I'm doing something similar to an example on the git page, using the imports below:
import * as L from 'leaflet';
import 'leaflet.markercluster';
import "leaflet.markercluster/dist/leaflet.markercluster";
import "leaflet.markercluster/dist/MarkerCluster.css";
import "leaflet.markercluster/dist/MarkerCluster.Default.css";
the variable I'm writing:
const clusterItems = L.markerClusterGroup({
chunkedLoading: true,
showCoverageOnHover: false,
iconCreateFunction: customIcon,
removeOutsideVisibleBounds: true,
disableClusteringAtZoom:18
});
I'm also using react as my frontend library, with typescript if you needed to know.
Thing is, works fine when actually running the service. But when it comes to testing, using Jest and Enzyme, I always immediately get this error:
Test suite failed to run
TypeError: L.markerClusterGroup is not a function
And the results always point right back to the line of
const clusterItems = L.markerClusterGroup
I know others have had this same error, but normally that seems to happen when trying to run their project. In this case, I only get this error when trying to run tests. I've tried some ideas, like trying to use spyOn the clusterItems variable, mock an implementation, mock leaflet package, but no avail. And I can't find any specific case like this when looking around either.

NullInjectorError: No provider for Overlay! NgxToastr

I have been scratching my head for last one day on this. I am using Ngx-Toastr package in my angular application. Below are the points which I think help you understand the problem.
In dev server (ng serve) I didn't get any error there was no Nullinjector problem, then I make a production build using the following command (ng build). Until this point everything works fine. Now I need to optimize the bundle size so I ran this (ng build --prod). Build was successful no error Now it's time to serve the code (I am using Node server to serve this). Here the problem starts -
First it's asking for
'NullInjectorError: No provider for ToastrService'
which is coming from the Ngx-Toastr Package it self and It makes sense so I add that service to the appmodules and also in other Lazy loaded modules in the providers array. So after this the error has gone . But next is what I want to talk about -
Next it is asking for 'NullInjectorError: No provider for Overlay!' So I though there must be this service from the package which needs to be added in the providers array. So I tried to import it from the package it self and to add it in the providers array like below:
import { Overlay } from 'ngx-toastr/overlay/overlay';;
doing so got the below error
Module not found: Error: Can't resolve 'ngx-toastr/overlay/overlay'
Next I tried searching for this problem and found some stackoverflow solutions which suggest to add the following line:
import {OverlayModule} from '#angular/cdk/overlay';
I added this module in the imports array of every modules. Nothing got changed.
Now I have no clue what to import and where to import. And I am also not sure whether I am going right or not or where should I start looking into it. I also doubt that this error is coming from that package or what!! cause It should work without implicitly importing those services.
I run the following command to get the error ahead of production build:
ng serve --prod --optimization=false
Please also mention how to debug the following error, sometime after production build we get error like this which is undoubtly makes no sense:
ERROR Error: "StaticInjectorError[t -> t]:
StaticInjectorError(Platform: core)[t -> t]:
NullInjectorError: No provider for t!"
I hope my explanation makes some sense to you. Thanks for your time and sorry for this long question.
Lastly FYI : I have already removed node-modules and re-installed it.
Make sure you're using a version of ngx-toastr compatible with your version of angular and typescript. https://github.com/scttcper/ngx-toastr#dependencies
ngx-toastr v13 requires angular >= 10

typescript error on importing fuse.js library

I am getting the typescript error every-time time to compile the code. the issues in fuse.js library and it throws an error Module '"../../../../Users/moinahmed/react-icon-emoji-picker/node_modules/fuse.js/dist/fuse"' has no exported member 'FuseResult'.
I have tried everything but could not solve this issue, the localhost starts running for a few seconds and then the app crashes and throws this error
FuseResult isn't directly exported from fuse.js,
The remedy is to use type FuseResult<T> = Fuse.FuseResult<T>; to alias FuseResult to Fuse.FuseResult. Playground
You can also use Fuse.FuseResult everywhere, but since you wanted to directly import I am assuming you don't want to rewrite this every time.

require() finding process.version to be undefined

I am trying to create a dashboard based off an existing dashboard template located below:
https://github.com/creativetimofficial/vuetify-material-dashboard
I am trying to integrate azure-storage into my solution in order to upload files directly to Azure.
https://github.com/Azure/azure-storage-node
The following require statement is used to import azure-storage
var azure = require('azure-storage');
However I am getting the following error:
TypeError: process.version is undefined
I have tried reinstalling all modules as well as process. I thought that process was a globally defined variable, and I can't understand why version is returning undefined. What could be causing this issue?
Tried to debug by printing all properties of process and this is what I have:
Thanks.

NodeJS import error

I'm trying to use the resemblejs library (http://huddle.github.io/Resemble.js/) to compare two images. However, when I have created a directory and added resemblejs as a dependency, but when I try to run the following:
nodejs test.js, I get the following error
var api = resemble(fileData).onComplete(function(data){
^
ReferenceError: resemble is not defined
I've never used NodeJS before, so it might be something really simple. Any ideas?
You can't get directly node module instance from it. You can check this issue on its repo. node-resemble is an Node port of Resemble.js.
Hope it will be useful for you.

Categories