-1

Working on an app using block programming on sketchware since I don't know anything about coding. My problem is, I want my app to disconnect when the internet is not available. I have put a command that if my app can access a certain data on firebase then that means it is online but if not then it is disconnected, but it seems that my app can still access the data on firebase even without internet because of the cache...

FIREBASE CONSOLE DATABASE RULES : rules

SOURCE CODE - onPageFinished : Source Code onpagefinished

BLOCK 1: Blocks 2

BLOCK 2: Blocks 1

Johndan
  • 1
  • 2
  • As you have not provided any code, I have posted an answer according to what I understood. Have a look at it. –  Aug 21 '18 at 06:53
  • I tried the simulator, it says simulation failed - unexpected server error. How do I put it there? Please take a look at my rules linked in my question. @SuryakantBharti – Johndan Aug 21 '18 at 07:41
  • Oh! I didn't realize that you weren't using Android Studio. My answer below is for Android Studio Java programmers. –  Aug 21 '18 at 07:48
  • I saw the link you have shared. It is a screenshot of the Firebase Console. But, for turning caching off for Firebase, you need to do it from your client side code (web, ios, android, etc.). Not from the Firebase Console. –  Aug 21 '18 at 07:50
  • Since you are using "sketchware", I don't think such complex things are possible in it. Anyways, if you find an answer, share below. Good luck :) –  Aug 21 '18 at 07:54
  • it has add source directly. will that do? – Johndan Aug 21 '18 at 07:59
  • You are saying that it has option to add source code directly? If yes, which programming language does it use? Because I haven't used "sketchware" ever. –  Aug 21 '18 at 08:02
  • Can you share how (the block code) you are using the Firebase Database in the "sketchware"? –  Aug 21 '18 at 08:04
  • I think it's in java? I don't know hahaha – Johndan Aug 21 '18 at 08:26
  • Keep exploring what you like, you will learn it soon. :) –  Aug 21 '18 at 08:28
  • yah I hope so :) – Johndan Aug 21 '18 at 08:31
  • added pics about the blocks and source code @SuryakantBharti – Johndan Aug 21 '18 at 08:43
  • Please include your code, rules and such as text instead of an image. – André Kool Aug 21 '18 at 11:08
  • I can't, sketchware won't let me copy from the source code. All I can do is take screenshots of what I think will be of use to you. – Johndan Aug 21 '18 at 11:28
  • omg I am doomed haha – Johndan Aug 21 '18 at 11:29
  • I had a look at the screenshots you have shared, but I can't find any Firebase code in it. First, you need to find the code where the App is interacting with the Firebase database. Then only we can modify it according to our needs. –  Aug 21 '18 at 21:46

1 Answers1

0

I think this should work for your needs:

mDatabase.getReference().keepSynced(false); 
FirebaseDatabase.getInstance().setPersistenceEnabled(false);

Further Reference

UPDATE : This is for Android Studio users.