Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
928 views
in Technique[技术] by (71.8m points)

firebase - Using Offline Persistence in Firestore in a Flutter App

I'm developing a app that uses Firebase's Firestore to send data to the web. One of the functions of the app is being able to save data in the device while being offline and send it to Firestore when internet connection is restored. I activated offline persistence but it dosen't work.

DEBUG CONSOLE:

W/OkHttpClientTransport(28536): Failed closing connection
W/OkHttpClientTransport(28536): javax.net.ssl.SSLException: Write error: ssl=0x7f7acfc408: I/O error during system call, Broken pipe
W/OkHttpClientTransport(28536):     at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_write(Native Method)
W/OkHttpClientTransport(28536):     at com.google.android.gms.org.conscrypt.NativeSsl.write(:com.google.android.gms@[email protected] (040406-222931072):4)

How can I activate offline persistence and sync with Firestore when internet is restored?

MY CODE:

Future<Null> sendFirebaseData(var selectedModel) async {

    Firestore.instance.enablePersistence(true);
    var certID = await getIDCertificado();

    var dateTime = new DateTime.now();
    var nowHour = new DateFormat('kk:mm:ss').format(dateTime);

      Map<String, dynamic> dataHeader = {
        'ID':                certID,
        };

      Map<String, dynamic> finalDataMap = {}..addAll(dataGeneral)
                                          ..addAll(dataInstrumento)..addAll(dataPadrao)
                                          ..addAll(dataAdicional)..addAll(dataHeader);

      await Firestore.instance.collection('certificados').document((certID.toString()))
          .setData(finalDataMap);}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...