与 Firebase 失去联系
Lose connection with firebase
我对 Firebase 有很大的疑问。该应用程序从 Firebase 注销,什么也没说,实际上通过启动该应用程序标志着我用户已正确登录。但这不是现实,因为例如当我去 Firebase 数据库中添加一个项目时,它保存在本地而不是在服务器上。这是一个问题,因为数据没有保存,我需要重新验证才能重新建立连接。当我这样做时,未保存的数据将被删除。
给我的错误如下。我已经在堆栈上看到了一个问题,但我提供了帮助。需要错误的文件我下载成功了。我不明白为什么这件事会发生在我身上,第一次没有。
谢谢你的帮助
W/PersistentConnection: pc_0 - Provided authentication credentials are invalid. This usually indicates your FirebaseApp instance was not initialized correctly. Make sure your google-services.json file has the correct firebase_url and api_key. You can re-download google-services.json from https://console.firebase.google.com/.
编辑
问题是当我重新启动设备时。当我打开设备时,通知接收器会自动加载通知警报,我认为这是 firebase 的问题。我该如何解决?
通知接收者
public class NotificationReceiver extends BroadcastReceiver {
SharedPreferences sharedPrefs;
Calendar calendar;
public void onReceive(Context context, Intent intent) {
sharedPrefs = context.getSharedPreferences("SETTING_NOTIFICATION", MODE_PRIVATE);
if (sharedPrefs.getBoolean("on", true))
Notification(context);
}
private void Notification(Context context){
calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 20);
calendar.set(Calendar.MINUTE, 15);
calendar.set(Calendar.SECOND, 0);
Intent intent1 = new Intent(context, AlarmReceiver.class);
PendingIntent pendingIntent1 = PendingIntent.getBroadcast(context, 0,intent1, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntent1);
}
}
清单中
<receiver android:name=".AlarmReceiver" />
<receiver android:name=".NotificationReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
问题似乎与错误日志中提到的 google-services.json 文件有关。您可以从您的 firebase 项目中重新下载并重试吗?或者 post 您遇到问题的函数的源代码。
我对 Firebase 有很大的疑问。该应用程序从 Firebase 注销,什么也没说,实际上通过启动该应用程序标志着我用户已正确登录。但这不是现实,因为例如当我去 Firebase 数据库中添加一个项目时,它保存在本地而不是在服务器上。这是一个问题,因为数据没有保存,我需要重新验证才能重新建立连接。当我这样做时,未保存的数据将被删除。 给我的错误如下。我已经在堆栈上看到了一个问题,但我提供了帮助。需要错误的文件我下载成功了。我不明白为什么这件事会发生在我身上,第一次没有。 谢谢你的帮助
W/PersistentConnection: pc_0 - Provided authentication credentials are invalid. This usually indicates your FirebaseApp instance was not initialized correctly. Make sure your google-services.json file has the correct firebase_url and api_key. You can re-download google-services.json from https://console.firebase.google.com/.
编辑 问题是当我重新启动设备时。当我打开设备时,通知接收器会自动加载通知警报,我认为这是 firebase 的问题。我该如何解决?
通知接收者
public class NotificationReceiver extends BroadcastReceiver {
SharedPreferences sharedPrefs;
Calendar calendar;
public void onReceive(Context context, Intent intent) {
sharedPrefs = context.getSharedPreferences("SETTING_NOTIFICATION", MODE_PRIVATE);
if (sharedPrefs.getBoolean("on", true))
Notification(context);
}
private void Notification(Context context){
calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 20);
calendar.set(Calendar.MINUTE, 15);
calendar.set(Calendar.SECOND, 0);
Intent intent1 = new Intent(context, AlarmReceiver.class);
PendingIntent pendingIntent1 = PendingIntent.getBroadcast(context, 0,intent1, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntent1);
}
}
清单中
<receiver android:name=".AlarmReceiver" />
<receiver android:name=".NotificationReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
问题似乎与错误日志中提到的 google-services.json 文件有关。您可以从您的 firebase 项目中重新下载并重试吗?或者 post 您遇到问题的函数的源代码。