I'm facing an issue after updating all my libraries to comply with AndroidX.
Specifically, when I try to use the package "cloud_functions", I receive this error message:
flutter: throwing generic exception
flutter: Exception: Unable to call function funName
Now, I didn't touch the code handling the call, I simply updated the packages in the yaml file.
My code is:
cfResponse = await CloudFunctions.instance.call(
functionName: 'funName',
parameters: {
"p1": p1,
"p2": p2,
},
).then((response) {
return response;
}).catchError((error) {
print(error);
return null;
});
I'm having the same issue both on Android and iOS.
My libraries are at version:
- cloud_functions: ^0.1.1
- firebase_auth: ^0.8.1+4
I'm on Flutter 1.2.1 and Dart 2.1.2
I ran into the same issue but only on iOS and came across cloud_functions bug. I manually set the region like the PR does and was able to get it to work. It looks like the fix will be in a coming release.
Related
When I test my React Native app that un my firebase config file
const auth = initializeAuth(app, {
persistence: getReactNativePersistence(AsyncStorage),
});
I get the error message: Cannot find module '#firebase/auth/react-native' from 'node_modules/firebase/auth/react-native/dist/index.cjs.js'
The app works fine in runtime, but doesn't seem to work during tests.
Any ideas to what this error could be caused by?
I was having the same issue this morning. Did you get it resolved?
I found that creating a file in the mocks directory called #firebase/auth/react-native.js and exporting a named function getReactNativePersistence resolved the issue (for now) for me. It's just a dummy function at this point, but my tests run.
__mocks__/#firebase/auth/react-native.js
export const getReactNativePersistence = () => {
return;
};
Am getting this error after following the steps mentioned in the nativescript-plugin-firebase readme file.
JS: firebase.init error: TypeError: Cannot read property 'database' of
undefined
https://github.com/EddyVerbruggen/nativescript-plugin-firebase
but i dont really understand nor do i know how to solve that.
the version of the plugin am using is : 6.4.0
with tns 4.1.2
EDIT: init code, from app.js
var firebase = require("nativescript-plugin-firebase");
firebase.init({ persist: true
// Optionally pass in properties for database, authentication and cloud messaging,
// see their respective docs.
}).then(
function (instance) {
console.log("firebase.init done");
},
function (error) {
console.log("firebase.init error: " + error);
}
);
I finally solved it by installing the plugin manually via the CLI (i initially installed it through NativeScript sidekick) apparently they didnt take in count the fact that some plugins may require some user inputs, to do write specific config file (which nativescript-plugin-firebase), so by installing it manually i got to provide the user input needed, it got configured and it worked!
I'm at a loss about why this won't log anything but "null" or "undefined" to the console. I'm testing this from the Google Cloud Platform testing browser interface. I've also tried logging EVENT (instead of CHANGE and CONTEXT) with the same result. I have also tried opening the security rules, but that also didn't help. Any advice is highly appreciated.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.fanOutLink = functions.database.ref('/userLink/BLAH584H5BLAH30BLA/link').onWrite((change, context) => {
console.log('value is:'+change.before.val());
});
And here is the JSON I'm using to test the code above:
{
"userLink": {
"BLAH584H5BLAH30BLA": {
"link": "https://blabla.com"
}
}
}
A Cloud Function must always return a Promise (or if you cannot, at least a value).
Your function should work as is but with a delay and an error in the log like "Function returned undefined, expected Promise or value". It may happen that the Cloud Functions instance running your function shuts down before your function successfully write the message in the log.
If you change your code as follow you will get a (quasi) instant reply:
exports.fanOutLink = functions.database.ref('/userLink/BLAH584H5BLAH30BLA/link').onWrite((change, context) => {
console.log('value is:'+change.before.val());
return true;
});
I would suggest you have a look at those 2 videos from the Firebase team: https://www.youtube.com/watch?v=7IkUgCLr5oA&t=511s and https://www.youtube.com/watch?v=652XeeKNHSk&t=37s
Following our "discussion" in the comments below, it appears that you use the new Cloud Functions syntax but with an old version of the library. Look at this documentation item: https://firebase.google.com/docs/functions/beta-v1-diff, and do as indicated, before redeploying:
Run the following in the functions folder:
npm install firebase-functions#latest --save
npm installfirebase-admin#5.11.0 --save
I'm trying to use lambda to restore a table in dynamoDB,
but keep getting this error message.
TypeError: dynamodb.restoreTableFromBackup is not a function
Could anyone tell me how to fix it?Thanks~
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#restoreTableFromBackup-property
'use strict';
const AWS = require('aws-sdk');
const dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = (event, context, callback) => {
const params = {
BackupArn: 'arn:aws:dynamodb:us-east-1/xxxxx',
TargetTableName: 'xxx',
};
dynamodb.restoreTableFromBackup(params, function (err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
};
I ran the code you provided in my own lambda and got the same result.
It seems the AWS SDK that is provided natively in Lambda isn't the latest version, with the restoreTableFromBackup function.
If I do the same test while using the latest available in npm, it seems to work fine.
As a work around, I suggest uploading your lambda as a zip file, and including the the node_modules/aws-sdk along with your code.
This will ensure it uses the latest aws-sdk which includes the restoreTableFromBackup function.
To assist further, I've written a walk through of how to use On-Demand backups / restore and how to schedule these backups.
https://www.abhayachauhan.com/2017/12/dynamodb-scheduling-on-demand-backups
HTH
'npm install aws-sdk' in Cloud9 terminal for the Lambda
I'm trying to login with Google but it throws me this error:
code: "auth/operation-not-supported-in-this-environment"
message: "This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled."
This is the code:
const provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('profile');
provider.addScope('email');
firebase.auth().signInWithPopup(provider)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.log(error);
})
Aditional Information:
"firebase": "^3.7.1"
"react-native": "^0.42.0"
platform: Android
any ideas?
thanks in advance!
First I used react-native-google-signin to Sign In with Google. Follow these steps to configure it.
Make sure you correctly sign your APK (debug or release).
In app/build.gradle exclude com.google.android.gms from the dependencies that use it like so:
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
Then link you Google token with Firebase:
const provider = firebase.auth.GoogleAuthProvider;
const credential = provider.credential(token);
firebase.auth().signInWithCredential(credential)
.then((data) => {
console.log('SUCCESS', data);
})
.catch((error) => {
console.log('ERROR', error);
});
I'm using firebase 3.7.1
This is how my dependencies look in app/build.gradle
dependencies {
compile project(':react-native-facebook-login')
compile (project(':react-native-fcm')){
exclude group: "com.google.firebase"
}
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
compile ('com.google.firebase:firebase-core:10.0.1') {
force = true;
}
compile ('com.google.firebase:firebase-messaging:10.0.1') {
force = true;
}
compile ('com.google.android.gms:play-services-auth:10.0.1') {
force = true;
}
}
Firebase Documentation
"Headful" auth methods such as signInWithPopup(), signInWithRedirect(), linkWithPopup(), and linkWithRedirect() do not work in React Native (or Cordova, for that matter). You can still sign in or link with a federated provider by using signInWithCredential() with an OAuth token from your provider of choice.
The general issue is not about changing the code with the solution, is more than we you use npm link the solution will be broke again, as the npm link will be re-adding the new line causing the error again.
npm link will search with regex, the current line is
compile(project(":react-native-google-signin")){ so we need to change it to the format compile project ("package") and split to the next like the bracket char.
In the following way:
compile project(":react-native-google-signin")
{
exclude group: "com.google.android.gms" // very important
}
so when you run npm link, it will detect the dependency and won't be duplicated but also the if block code will be persisted.
I am replying late but it will be helpful for others, if you are using firebase with google sign then you must exclude some libraries and those your app gradle like that
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
compile ('com.google.android.gms:play-services-auth:10.2.6'){
force = true;
}
compile ("com.google.android.gms:play-services-base:+") { // the plus allows you to use the latest version
force = true;
}
compile (project(path: ':react-native-fbsdk')){
exclude group: "com.google.android.gms"
}
compile(project(":react-native-firebase")){
exclude group: "com.google.android.gms"
}
This is discussion about that issue for more detail answer
I find all other answers to be either incorrect or deprecated.
react-native-firebase which is the officially recommended collection of packages that brings React Native support for all Firebase services on both Android and iOS apps.
Be sure to follow Firebase Authentication setup instructions: https://rnfirebase.io/auth/usage
Setup Firebase Authentication with google-signin: https://github.com/react-native-google-signin/google-signin