How to Check Latest Version in sketchware with Firebase Database
1) Create a new project in Sketchware.
Make sure the rules in your Firebase database are read and write true.
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
version.child("app").child("v").setValue(your_version);
That's all
Save and run the project.
You can watch below the video.
Comments
Post a Comment