React Native Firebase RT Database Error - "Undefined is not a function" - react-native

I have been trying to get Firebase Real Time Database to work. Though, I consistently get errors. I followed this guide and have successfully gotten other packages from here working. I have the 16.5.0 version. The rules of the Database is set to true.
I installed React Native with Expo.
Code inside of a function:
database()
.ref('/users/123')
.once('value')
.then((snapshot) => {
console.log('User data: ', snapshot.val());
});
Database:
{
"users": {
"123": ""
}
}
Calling of the function results in:
TypeError: this._database.native.once is not a function. (In 'this._database.native.once(this.path, modifiers, eventType)', 'this._database.native.once' is undefined)
While hovering over database() VS Intellisense says:
database(app?: ReactNativeFirebase.FirebaseApp | undefined): FirebaseDatabaseTypes.Module
import database
I have tried different methods for database() and ref(), according to the documentations, but nothing seems to be working.
Anyone know why I get this error, and how to fix it?

Running npx expo run:android and updating the Android Emulator solved the issue.

Related

Vue 3 Vite and ZoomSDK

I’m having problems implement the zoom meetings sdk with vue 3 and vite. This is a boiler plate init of vue 3 project using the vue-create cli
I’ve also resisted my add with zoom and the my sdk key and sdk secret.
Following the steps in the zoom dev site I’ve installed the zoom meeting sdk with
npm install #zoomus/websdk --save
Following various example from the zoom dev site and zoom git I added this import to a the base HelloWord.vue component. This first error it get is
import { ZoomMtg } from "#zoomus/websdk";
Error
Uncaught TypeError: c2 is not a function
After seachinig for Similar problems I found a solution to this and change the import to this which gave no errors
import ZoomMtg from "#zoomus/websdk/dist/zoomus-websdk-embedded.umd.min.js";
The next bit of code I got from the zoom meet sdk vue 2 example
ZoomMtg.setZoomJSLib('https://source.zoom.us/2.8.0/lib', '/av');
However this produced another error
Uncaught TypeError: ZoomMtg.checkSystemRequirements is not a function
At this point I’m stuck.
I’m trying to create a zoom component that can be used on multiple pages however I can’t seem to get passed this early stage.
Help would be much appreciated.
As you wish you can create client view using embedded.
you can import ZoomMtgEmbedded from '#zoomus/websdk/embedded';
import ZoomMtgEmbedded from '#zoomus/websdk/embedded';
export default {
created () {
},
data () {
return {
client: ZoomMtgEmbedded.createClient(),
// This Sample App has been updated to use SDK App type credentials https://marketplace.zoom.us/docs/guides/build/sdk-app
sdkKey: "",
meetingNumber: "123456789",
passWord: "",
role: 0,
signatureEndpoint: "",
userEmail: "",
userName: "Vue.js",
// pass in the registrant's token if your meeting or webinar requires registration. More info here:
// Meetings: https://marketplace.zoom.us/docs/sdk/native-sdks/web/component-view/meetings#join-registered
// Webinars: https://marketplace.zoom.us/docs/sdk/native-sdks/web/component-view/webinars#join-registered
registrantToken: ''
}
}
}
here is full example updated recently.
If you would like to use component view, you should add lodash
script in index.html.

"Unknown error, the response body from fetch is: undefined" at Auth.confirmSignIn

I am trying to send the verification code received by the user to confirm the signIn, I have the SMS_MFA enabled. However, I keep getting this error Unknown error, the response body from fetch is: undefined and thats all I get, there is nothing else to help me understand what the error is about. And everything else is working fine, I call signIn, signUp, confirmSignUp and resendSignUp, they all work fine. The problem is only with confirmSignIn and I have no idea what it could be, I already researched online, but had no success. Another strange thing that happens, when I enter the wrong code, it shows me the 'CodeMismatchException', but it fails with 'Unknown error' when code is the right one. PS: I already have cognito configured to work with SMS MFA
I'am having this problem in android and iOS. React native version 0.55.4 and aws-amplify version ^1.0.11
I have a file where a call all the Auth functions and export them
export const confirmSignIn = (cognitoUser, code) => Auth.confirmSignIn(cognitoUser, code, 'SMS_MFA');
Then I call that confirmSignIn function from a different file
confirmSignIn(cognitoUser, code).then((userSession) => {
console.log(userSession);
}).catch((error) => {
switch (error.name) {
case 'CodeMismatchException':
this.codeInput.clear();
break;
default:
console.log(error);
break;
}
});
I already tried upgrading aws-amplify version, but it didn't work, tried to do it with cognitoUser.sendMFACode() but didn't work either. I just keep getting Unknown error, the response body from fetch is: undefined
I also opened an issue in the aws-amplify repo.

AsyncStorage is not returning the callback

I am using redux-persist in a react native project, that runs just fine in a broad number of devices except Android 7. I am trying to debug the problem on why my local storage is nor persisting and found this:
The following code executes inside React Native component lifecycle's
componentDidMount() {
attachObservables(store)
setInterval(async () => {
console.log('Inside setInterval')
const data = await AsyncStorage.getAllKeys()
console.log('inside the getAllKeys')
data.forEach(async k => {
const value = await AsyncStorage.getItem(k)
console.group(k)
console.log(value)
console.groupEnd()
})
}, 3000)
}
Code after 'Inside setInterval' is never called. It only runs once if outside the setInterval. If I call once the code outside the setInterval it appears to run just fine. I also tried callback format vs async / await version but it does not seem to matter.
Same problem I had using firebase js library (callbacks never return after the first one). I am now looking for alternatives to workaround the problem.
Any ideas?
As of React Native 0.51 in some Android versions, the runtime can get blocked by other native modules, impeding the resolution of the mentioned methods.
It can be fixed via https://github.com/facebook/react-native/issues/14101#issuecomment-345563563, ensuring this methods use a free thread from the thread pool.
A PR has been submitted and I hope that will be released in future versions. If you want it to use this fix right now, it is available here https://github.com/netbeast/react-native
EDIT:
I am not experiencing this anymore on real devices over react-native#0.53, anyhow others have also reported, so the issue is still open.

How can i check app installed in react native code

i tried to check other app install in my react native project, I'm used module like: https://www.npmjs.com/package/react-native-check-app-install
But always got this error:
Cannot read property 'pkgName' of undefined
Here is my code:
AppInstalledChecker
.isAppInstalledAndroid('com.skype.raider')
.then((isInstalled) => {
// isInstalled is true if the app is installed or false if not
console.log('App Skype status: ', isInstalled);
});
Anyone can suggest me one way so check app install in react native (both: iOS/android)
install this
https://github.com/KjellConnelly/react-native-shared-group-preferences
and
async check() {
try {
await SharedGroupPreferences.isAppInstalledAndroid("com.farsitel.bazaar")
// IF IS INSTALL
} catch (e) {
// IF IS NOT INSTALL
}
}
Google Play considers the list of installed apps to be personal and sensitive user data.
As we are using
AppInstalledChecker
.isAppInstalledAndroid()
method for checking app installed check, for that we have to white-list the queries in manifest.xml
Reference : https://developer.android.com/training/package-visibility
<queries>
<package android:name="com.instagram.android"/>
…
</queries>
For adding Queries need to upgrade build gradle version:
new default settings and features for package visibility in Android 11 that need to add  you must update your android gradle plugin version
Reference: How to fix "unexpected element <queries> found in <manifest>" error?
I have updated from 3.5.2 to 4.0.2
Now react-native-check-app-install module working as expected
Hope this is resolved!
Android
I. For app's which has deep links like 'waze://', 'mapsme://' you can use:
import { Linking } from 'react-native'
...
Linking.canOpenURL('waze://ul?ll=${latitude},${longitude}&navigate=yes')
OR
II. You can use for absolutely all apps (for example with deep links like "https://...")
https://github.com/KjellConnelly/react-native-shared-group-preferences
iOS
import { Linking } from 'react-native'
...
Linking.canOpenURL(iOS_app_URL_Scheme)
...
where iOS_app_URL_Scheme you can find via Google for each separate app. Like "waze://", "comgooglemaps://", "osmandmaps://" etc

LockModule.init undefined error in auth0 react-android getting started

I'm following the instructions to get auth0 running in react-native android https://auth0.com/docs/quickstart/native/react-native-android
And I am getting the following error
undefined is not an object (evaluating 'LockModule.init') show auth0-lock.js:33
The error implies that the LockModule variable is undefined; by checking the code for auth0-lock.js we can see that the variable is being initialized by the following logic:
var { NativeModules, Platform } = require('react-native');
var LockModule = NativeModules.Auth0LockModule;
According to react-native documentation in order to use a module implemented as a native module you need to register it.
The package needs to be provided in the getPackages method of the MainApplication.java file. This file exists under the android folder in your react-native application directory.
You should have something similar to:
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new LockReactPackage()
);
}
If this is not the root cause of the issue you'll need to update your question with more details.
I ran into this issue while trying to get Auth0 working on iOS. Our fix is here (react-native run-ios to see more detailed messages for the issue; correct header search paths; update podfile with OneSignal; add OneSignal library)
https://github.com/auth0/react-native-lock/issues/133