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.
Library
Add firebase project in your sketchware and turn on appcompact library.
Oncreate
Leave oncreate section empty
Components section
Add a request network component as shown in picture.
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"
}
}
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 .
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
On network no response
Do whatever you want to do with it
I added textview set text error
Done now run and check the app
If any error caught comment below or leave a message to our tg group
thanku ☺️
Comments