无法调用方法 FirebaseApp.delete()
Unable to call method FirebaseApp.delete()
我正在尝试删除 secondaryApp 代码,因为我想阻止 firebaseAuth.createUserWithEmailAndPassword(email,password)
功能在用户创建后自动登录
我参考了下面的代码:
FirebaseOptions.Builder fbo = new FirebaseOptions.Builder();
fbo.setApiKey("YOUR_WEB_API_KEY");
fbo.setDatabaseUrl("https://[YOUR_PROJECT_ID].firebaseio.com/");
fbo.setProjectId("YOUR_PROJECT_ID");
fbo.setApplicationId("YOUR_APP_ID"); //Tested, App Id is required.
FirebaseOptions firebaseOptions = fbo.build();
final FirebaseApp secondaryAuth = FirebaseApp.initializeApp([JAVA_CLASS_NAME].this, firebaseOptions, "secondary_db_auth");
它有效,但是当我试图调用方法时
secondaryAuth.delete()
它 returns 一个错误,指出无法调用该方法,如下图所示。
我已经检查了来自 firebase [FirebaseApp.delete()][2] 的文档,并希望它能正常工作,但事实并非如此。其他一切都解决了它只是 delete()
不工作
https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/FirebaseApp
整个代码实现如下:
private void CreateAccount() {
String name = username.getText().toString();
String phone = phoneNumber.getText().toString();
String email = emailAddress.getText().toString();
String password = passwordTxt.getText().toString();
String confirmPassword = confirmPasswordTxt.getText().toString();
String points = pointsTransfer.getText().toString();
final DatabaseReference RootRef;
final FirebaseAuth firebaseAuth;
FirebaseOptions.Builder fbo = new FirebaseOptions.Builder();
fbo.setApiKey("YOUR_WEB_API_KEY");
fbo.setDatabaseUrl("https://[YOUR_PROJECT_ID].firebaseio.com/");
fbo.setProjectId("YOUR_PROJECT_ID");
fbo.setApplicationId("YOUR_APP_ID"); //Tested, App Id is required.
FirebaseOptions firebaseOptions = fbo.build();
final FirebaseApp secondaryAuth = FirebaseApp.initializeApp([JAVA_CLASS_NAME].this, firebaseOptions, "secondary_db_auth");
RootRef = FirebaseDatabase.getInstance().getReference().child("Users");
firebaseAuth = FirebaseAuth.getInstance(secondaryAuth);
if(TextUtils.isEmpty(name)){
Toast.makeText(this, "Please insert your user name.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(phone)){
Toast.makeText(this, "Please insert your phone number.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(email)){
Toast.makeText(this, "Please insert your phone number.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(password)){
Toast.makeText(this, "Please insert your password.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(confirmPassword)){
Toast.makeText(this, "Please insert your password again.", Toast.LENGTH_SHORT).show();
}
else if(!password.equals(confirmPassword)){
Toast.makeText(this, "Password does not match.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(points)){
Toast.makeText(this, "You need to send some points", Toast.LENGTH_SHORT).show();
}
else if(Float.parseFloat(currentUser.getPoints())<Float.parseFloat(points)){
Toast.makeText(this, "You do not have sufficient points.", Toast.LENGTH_SHORT).show();
}
else{
loadingBar.setTitle("Create Account");
loadingBar.setMessage("Please wait, we are checking the credentials.");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
ValidateAccount(name, phone,email, password, confirmPassword,points, RootRef, firebaseAuth);
secondaryAuth.delete();
}
}
据我所知 reference documentation 中没有方法 FirebaseApp.delete()
。
创建 FirebaseApp
实例后,它将在该应用程序的生命周期内存在。鉴于 FirebaseApp
实例非常轻量级,这通常不会成为问题。
但他们当然可以保留更昂贵的资源,例如服务实例。如果这对您的应用程序来说是一个问题,请务必隔离名称应用程序实例及其服务的使用,以便在不再需要它们时可以对其进行垃圾回收。
听起来你想检测你是否已经初始化了 FirebaseApp
,你可以通过调用 getApps()
, looping through the results and checking the name of each. Alternatively you can call getInstance("secondary_db_auth")
来完成并处理当应用程序实例不存在时抛出的异常还.
我正在尝试删除 secondaryApp 代码,因为我想阻止 firebaseAuth.createUserWithEmailAndPassword(email,password)
功能在用户创建后自动登录
我参考了下面的代码:
FirebaseOptions.Builder fbo = new FirebaseOptions.Builder();
fbo.setApiKey("YOUR_WEB_API_KEY");
fbo.setDatabaseUrl("https://[YOUR_PROJECT_ID].firebaseio.com/");
fbo.setProjectId("YOUR_PROJECT_ID");
fbo.setApplicationId("YOUR_APP_ID"); //Tested, App Id is required.
FirebaseOptions firebaseOptions = fbo.build();
final FirebaseApp secondaryAuth = FirebaseApp.initializeApp([JAVA_CLASS_NAME].this, firebaseOptions, "secondary_db_auth");
它有效,但是当我试图调用方法时
secondaryAuth.delete()
它 returns 一个错误,指出无法调用该方法,如下图所示。
我已经检查了来自 firebase [FirebaseApp.delete()][2] 的文档,并希望它能正常工作,但事实并非如此。其他一切都解决了它只是 delete()
不工作
https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/FirebaseApp
整个代码实现如下:
private void CreateAccount() {
String name = username.getText().toString();
String phone = phoneNumber.getText().toString();
String email = emailAddress.getText().toString();
String password = passwordTxt.getText().toString();
String confirmPassword = confirmPasswordTxt.getText().toString();
String points = pointsTransfer.getText().toString();
final DatabaseReference RootRef;
final FirebaseAuth firebaseAuth;
FirebaseOptions.Builder fbo = new FirebaseOptions.Builder();
fbo.setApiKey("YOUR_WEB_API_KEY");
fbo.setDatabaseUrl("https://[YOUR_PROJECT_ID].firebaseio.com/");
fbo.setProjectId("YOUR_PROJECT_ID");
fbo.setApplicationId("YOUR_APP_ID"); //Tested, App Id is required.
FirebaseOptions firebaseOptions = fbo.build();
final FirebaseApp secondaryAuth = FirebaseApp.initializeApp([JAVA_CLASS_NAME].this, firebaseOptions, "secondary_db_auth");
RootRef = FirebaseDatabase.getInstance().getReference().child("Users");
firebaseAuth = FirebaseAuth.getInstance(secondaryAuth);
if(TextUtils.isEmpty(name)){
Toast.makeText(this, "Please insert your user name.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(phone)){
Toast.makeText(this, "Please insert your phone number.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(email)){
Toast.makeText(this, "Please insert your phone number.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(password)){
Toast.makeText(this, "Please insert your password.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(confirmPassword)){
Toast.makeText(this, "Please insert your password again.", Toast.LENGTH_SHORT).show();
}
else if(!password.equals(confirmPassword)){
Toast.makeText(this, "Password does not match.", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(points)){
Toast.makeText(this, "You need to send some points", Toast.LENGTH_SHORT).show();
}
else if(Float.parseFloat(currentUser.getPoints())<Float.parseFloat(points)){
Toast.makeText(this, "You do not have sufficient points.", Toast.LENGTH_SHORT).show();
}
else{
loadingBar.setTitle("Create Account");
loadingBar.setMessage("Please wait, we are checking the credentials.");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
ValidateAccount(name, phone,email, password, confirmPassword,points, RootRef, firebaseAuth);
secondaryAuth.delete();
}
}
据我所知 reference documentation 中没有方法 FirebaseApp.delete()
。
创建 FirebaseApp
实例后,它将在该应用程序的生命周期内存在。鉴于 FirebaseApp
实例非常轻量级,这通常不会成为问题。
但他们当然可以保留更昂贵的资源,例如服务实例。如果这对您的应用程序来说是一个问题,请务必隔离名称应用程序实例及其服务的使用,以便在不再需要它们时可以对其进行垃圾回收。
听起来你想检测你是否已经初始化了 FirebaseApp
,你可以通过调用 getApps()
, looping through the results and checking the name of each. Alternatively you can call getInstance("secondary_db_auth")
来完成并处理当应用程序实例不存在时抛出的异常还.