Requirements:
- A webpage
- APK Editor plus or alternatives for editing Android Manifest.
(Related post for more information: https://blog.sketchub.in/2020/03/how-to-add-intent-filter-in-sketchware.html)
Welcome to Sketchub Blog, in this blog I will try to explain how to create post/profile link sharing option just like Sketchub. (There is no special need of Firebase Dynamics for this).
For example you have a webpage "https://project.sketchub.in". Then in index file, you will need to add a button with id "btn_open_project" which will be used for opening the app:
Here, link_main is the id of button or text which will be used to open the project through the page. We will explain, why we added "project.sketchub://" before the URL, in end of this post.
Now lets move to the Sketchware project.
In MainActivity, preferably in OnCreate , add this code for obtaining the link when app is opened via link:
If your app is opened via link, it will get the link in the string shared_data. The value of shared_data will be "project.sketchub://project.sketchub.in/?id=123" (why project.sketchub:// , we will explain later).Now, in the link, "id" is URL parameter, with value of "123". And we can add multiple URL parameters like: "project.sketchub.in/?id=123&userID=456&other=789" (here userID and other is another parameters with value 456 & 789 respectively).
In Sketchware, we will need to get value of "id" from the string "shared_data" by using this code:
Now, you will need to implement your own method to find the post with id=123 ;)
Here android:scheme="project.sketchub" means that it will only pick those links which starts from "project.sketchub://...". (This way also forces user to move to webpage first, you may edit it if you don't want so, but again, it is useful to send user to webpage.)
Now run the project, and edit APK's android manifest using APK Editor Plus or alternative apps.
Add this code after any </activity> in the existing code.
Here android:scheme="project.sketchub" means that it will only pick those links which starts from "project.sketchub://...". (This way also forces user to move to webpage first, you may edit it if you don't want so, but again, it is useful to send user to webpage.)
Build the APK and test it, it will work ;)
0 Comments