How to Check Latest Version in sketchware with Firebase Database



1) Create a new project in Sketchware.

2) Add Firebase library in the library.
Make sure the rules in your Firebase database are read and write true.
3) Add Firebase Database component as
version:version
4) Add String variables as package_name, your_version, latest_version and Add map variable as map
5) Then OnCreate event set string package_name to your app package. In this tutorial I am using sketchware.check.version
6) Then below set string block add two add source directly block. First code is
try {
android.content.pm.PackageInfo pinfo = getPackageManager().getPackageInfo( package_name, android.content.pm.PackageManager.GET_ACTIVITIES);
your_version = pinfo.versionName; }
catch (Exception e){ showMessage(e.toString()); }

Second code is
DatabaseReference rootRef = _firebase.getReference(); rootRef.child("version").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
if (snapshot.exists()) { } else {

7) Then add following block.
8) Then add an add source directly block with code
} }
@Override
public void onCancelled(DatabaseError _error) { } });
After doing the above instructions your OnCreate event will look like
9) Then add a list map as map1
10) Then OnChildAdded event of Firebase Database component version:version
Do as below

Code used is
version.child("app").child("v").setValue(your_version);

That's all
Save and run the project.
You can watch below the video.

Comments

Popular posts from this blog

How to make a website in 2019 with no investment.

Make a layout with rounded corners in sketchware

Add menu in actionbar in Sketchware