为什么 Firebase 在明确更改设备的本地日期时停止同步?

Why Firebase stops syncing when local date of device is changed explicitly?

当我将 Phone 的本地日期设置更改 1 个月或更长时间,然后在重新启动使用 Firebase 实时数据库的 android 应用程序后,它不会从数据库并永远加载。 为什么会这样? Firebase 在获取数据之前是否检查设备的本地时间?

这是 Android 应用程序的 onCreate() MainActivity

在设置中更改日期(10 天或更多天)然后关闭并重新打开应用程序后,进度条永远不会消失。 甚至 onCancelled 函数都没有被调用。

    final ProgressBar progressBar = findViewById(R.id.progress_bar);
    final TextView textView = findViewById(R.id.textView);
    progressBar.setVisibility(View.VISIBLE);

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("message");
    myRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            String value = dataSnapshot.getValue(String.class);
            textView.setText(value);
            progressBar.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onCancelled(DatabaseError error) {
            progressBar.setVisibility(View.INVISIBLE);
        }
    });`

应用级别gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.akzarma.testapplication"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'

下面是这个项目的Github repistory link,这只是一个从 firebase 实时数据库获取数据的示例应用程序。:https://github.com/akzarma/testApp

如评论中所述,最有可能的原因与 SSL 有关。 SSL 不能很好地处理不正确的日期,因此它无法安全地连接到 Firebase。解决此问题的一种可能方法是通过 http 连接到 Firebase,但 1) 它不安全 2) 我不确定它是否仍受支持。