Sketchware Generate Firebase Dynamic Link (Long Url To Short) | sketchware blocks explained

 So Today I am going to discuss how to make long url to short link with firebase dynamic link







View

So first I'll design a ui for this app here is a example of app ui. I used a edittext to get long link a button to generate link. A textview to get generated link.



sketchware dynamic link
                                     ui example


Library


Add firebase project in your sketchware and turn on appcompact library.



sketchware library manager
                              Add Firebase Example

Oncreate


Leave oncreate section empty 

Components section

 
Add a request network component as shown in picture.



sketchware components


On Button Click

Add a string I used url_to_shorten as string name Add an another string named json
In the value of json put this a join and another join block inside this block. 

Code for first part

{
   "longDynamicLink": "https://sketchprojects.page.link/?link=

Change with you dynamic link 
After that add you string variable (whose value is long url)

Code for second part
",
     "suffix": {
    "option": "SHORT"
   }
}



sketchware pro button on click
Then create a map variable named map and put block as shown in picture

Put a request network block whose parama are map
Add second request network block with method get and url
https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=ADD_YOUR_FIREBASE_API_KEY


Add 2 Components as shown in picture .



sketchware pro events



Request network on response



Put asd  try{ 
So that you can catch error
Then get json response to map
Then text set text map get key shortLink
And then catch exception 



sketchware pro blocks


On network no response




Do whatever you want to do with it 
I added textview set text error


sketchware pro blocks



Done now run and check the app





If any error caught comment below or leave a message to our tg group 


thanku ☺️

Comments

Popular posts from this blog

what is sketchware and history of sketchware

How to import local library in sketchware

Create HTML Dialog in Sketchware

Create Percentage loading bar in sketchware

how to import export custom blocks sketchware

Sketchware Generate Firebase Dynamic Link (Long Url To Short) | sketchware blocks explained

Android 10/11 Storage Permission sketchware | New blocks + method

Auto Get text from camera || OCR in sketchware || free project | Sketchware pro tutorial

Image filter moreblocks for making black and white imageview