2024 Apr 24 3:17 AM - last edited on 2024 May 02 8:19 AM by Dan_Wroblewski
The challenge is now over. See our wrap-up blog.
In Task 3 of our challenge, you added theme, styles, and layout design for a new but otherwise empty app. This week, you’ll connect the app to Foursquare APIs and enable native mobile capabilities to end up with an app for finding activities near your area.
You’ll need to have done Task 3 first, or at least download the skeleton app.
The challenges so far:
________________________________________________________________________________
There are few readily available native device capabilities in SAP Build Apps which can be found by invoking the logic canvas from the lower drawer once you click on a control such as a Button.
Scan QR/barcode, Take Photo and GPS Location are native device capabilities provided by SAP Build Apps.
The output from these flow functions can be sent to an API to retrieve more information or for further processing.
In this task, we want you to explore the GPS location (latitude, longitude) capability to find user’s location, send it to Foursquare’s Place Search API to get and display places near the user. You will add logic to the place of interest buttons (Cafes, Movies, Bars, Restaurants) to retrieve the Places Search API response by providing a search query and the latitude and longitude obtained from the GPS Location.
Foursquare: Sign up for a foursquare account and get started with the Places API. Skip the “Apply for Movement SDK Access” step as it is not required for this task. Login to your foursquare account, create a project and generate an API key to access Places API as described here. In this task, we will use Place Search API using the Latitude/Longitude as described here.
1.Sign up
2.Login
3. Create Project
4. Generate an API Key
SAP Build Apps: To learn more about how to connect to REST APIs, use page, data, app variables and page parameters used in this task, you can use the references below:
In Part I, we want you to hook up the app to the Foursquare Place Search API and make it so that when the user clicks one of the buttons, say Cafes, the app will show a list of cafes.
In Part II, we want you to enhance the Details page with Photos and Address received from Get Photos API, Get Place Details API as well as add a custom logic to calculate the user’s distance from the selected place.
The skeleton app already has 2 pages (Homepage and Details page) with a basic structure of the pages. You just need to do the following:
Rest API Direct Integration
Configure REST API
Note: The query and ll query parameters configured for the REST API in the data tab should be non-static, optional value as it will be coming from the Build Apps based on the selection of buttons and latitude/longitude respectively.
Tips:
2. Save the solution: Be sure to set your community id as the app variable on this app if it is not already set. Provide the name of the main object that stores the readings such as accelerometer, barometer, compass, geolocation etc. from device sensors, as the value(maintain the case sensitivity) for String to Hash input field on the Generate Hash page and generate a hash. Hint: You can explore this object in the Formula Editor of SAP Build Apps. Take a screenshot of the homepage, save it along with the hash. You might need it to submit later.
There is a Details page provided in the skeleton app.
Below is a sample reference function that returns true/false based on calculations to determine if the user is near to a location. For our task, we want to display the distance, a user is from a venue, by clicking the Check distance button. Use formulas in SAP Build Apps to achieve this functionality. Display the distance in km in the placeholder text provided below the button.
function arePointsNearBy(currentLocation, venueLocation, km) {
var ky = 40000 / 360;
var kx = Math.cos(Math.PI * venueLocation.lat / 180.0) * ky;
var dx = Math.abs(venueLocation.lng - currentLocation.lng) * kx;
var dy = Math.abs(venueLocation.lat - currentLocation.lat) * ky;
return Math.sqrt(dx * dx + dy * dy) <= km;
}
To implement the check-in functionality, we could use true/false to determine if we can allow the user to check in. We will not be implementing the check-in functionality as part of this task.
Post a reply with the following:
Task 4 – Part 1 output
Task 4 – Part 2 output
If you have reached till here, Nice Work! You have now completed Week 4 of Developer’s challenge successfully.
Thanks for participating and enjoy using the app to search for places of interest! Feel free to add in the comments any improvements you can think of on the app or mention the parts of the exercise you found to be tricky.
2024 Apr 27 8:18 PM
fdf88fb3b3b2300adf61f4c9e93c68eda905374a3d68a51090ca608254bc1c54
2024 Apr 28 5:39 AM
2024 Apr 28 2:34 PM
2024 Apr 28 3:09 PM
2024 Apr 28 3:17 PM
I see, I did not use that object, i use directly "Device GPS location" to set my variables.
95dd39f48a747f22d06661979a6f640cd579341d79c8dca5ca85f83e0b750b8e
2024 Apr 28 6:27 AM - edited 2024 Apr 28 7:59 AM
Had to try it 😺
Part I
9d2e4d6c2969fa6888838133085c1e9890cdebc79a9c631eaabdbeb5058e4828
Tips:
Part II
My formula:
"You are " + FORMAT_LOCALIZED_DECIMAL(SQRT(POWER(ABS(data.FS1.geocodes.main.longitude-appVars.longitude) * COS(PI() * data.FS1.geocodes.main.latitude / 180) * 40000/360,2) + POWER(ABS(data.FS1.geocodes.main.latitude-appVars.latitude) * 40000/360,2)),"en",2) + " km away"
2024 Apr 29 7:31 AM
The one liner formula seems interesting! Thanks for the tips Daniel.
2024 Apr 28 6:33 AM
2024 Apr 28 2:23 PM
2024 Apr 28 4:49 PM - edited 2024 Apr 29 5:57 AM
Part 1:
Hash : 2ea183ae4e7826800a618ced5d0c77c5703811ba84c12feb776f050925380527
Part 2:
It was great learning, thanks for the month-long challenge, learnt a lot.
2024 Apr 29 7:55 AM
Screenshots look good! Unfortunately, the hash seems incorrect. Community ID seems fine on the homepage, so must be the value that needs to go into "String to Hash" field. Also please check if the "String to Hash" field is bound to the App Variable -> stringToHash
2024 Apr 29 8:48 AM - edited 2024 Apr 30 5:25 AM
Thanks for the suggestions @eshrinivasan . I am not sure what went wrong.
The "String to Hash" field is bound to app variable, see screenshot below:
I am using the GPS object name from formula editor, see selected in below screenshot:
I tried the hashing API in data tab,
hash:
2ea183ae4e7826800a618ced5d0c77c5703811ba84c12feb776f050925380527
see screenshot below:
2024 Apr 30 5:30 AM
GPS location is not the correct string. We are looking for the name of the JavaScript object that you will see in the formula editor that contains all the mobile capability data. Go into the formula editor and see the object that holds all the sensor information.
2024 Apr 30 7:28 AM
@Dan_Wroblewski thanks for the clue, hoping this time it is correct:
891d85afe3c68cec7d0335af69aa33f5031902dd7c88100a2caafda797e86774
2024 Apr 28 10:46 PM
2024 Apr 29 2:07 PM
Thanks for the feedback. Since its the last week of the challenge, its designed to be little harder than the previous weeks and many steps to perform without step by step instructions. I am glad that many participants were able to do the complete challenge.
2024 Apr 28 11:08 PM - edited 2024 Apr 28 11:11 PM
Here's my hash: c20121f9f09def9ee2c23239cdb6c79746eb93fa5631198368763a294ba439a6
Screenshot from Part-1:
Screenshot from Part-2:
2024 Apr 29 5:42 AM - edited 2024 Apr 29 5:43 AM
Here my Hash -
e070dd59b916de9ecf23d9f4c03903faac9e91443a9edb09bfa91f21baec6b0f
part-1:
2024 Apr 29 1:53 PM
2024 Apr 29 2:04 PM
Looks good. Thanks for participating in the challenge!
2024 Apr 30 7:44 PM
2024 Apr 29 4:17 PM - edited 2024 Apr 30 4:07 PM
Hello,
Task1:
Hash: 24cc8a822e8ff93ec82ff3aff04eee6e07e5b61e7be6c274d7aac3722dbfa663
Part 2:
Edit 1: the second task was added.
Edit 2: thank you for the great challenge!
2024 Apr 29 5:25 PM
Great challenge - Thanks for challenging me 😉
HASH
4a28b3a8d628148deb86e559b7feba5cfc3deaaa0979c9040631105206e34b8d
Part 1
Part 2
2024 Apr 30 5:42 AM
2024 May 01 10:18 AM - edited 2024 May 01 10:19 AM
Another try (had hashed the name at the left): 9276fedb6a9767c19c8868ea52b8e08d7ed0f73dad699df613fcd61cfa2ab49a
2024 May 03 3:30 PM
2024 Apr 30 10:24 AM - edited 2024 Apr 30 10:28 AM
D0a2aec79b9b932a1322521d22e81d42528d798171d87abd738ee8462d47d5b2
2024 Apr 30 11:08 AM
Excellent job with homepage and Details page calculations. However, the hash doesnt seem to be right. Could you look into the formula editor for the name of the object that we are looking for?
2024 Apr 30 11:50 AM - edited 2024 Apr 30 11:51 AM
4525a31fbb4024c83ffe33fc73121d804138d41449741c4955135d0e1a7777f1
I hope this one is correct!
2024 Apr 30 10:29 AM
Please help.. i created an account in foursquare yesterday but it's not allowing me to create any project.
2024 Apr 30 10:53 AM
@anumalasingh Had similar last week using a business e-mail address and had to raise a support ticket with foursquare but they can take a day to fix. Alternatively, try using a gmail account.
2024 Apr 30 1:47 PM
but i used my personal email account. not sure what is the problem.
@eshrinivasan Do we need to complete this challenge by 30th april only? or we can extend?
2024 Apr 30 2:03 PM
Today is the official end date for Build Apps Challenge and from tomorrow a different topic challenge starts. However, you can continue to complete the challenge beyond today.
2024 Apr 30 2:11 PM
2024 Apr 30 3:07 PM
2024 May 01 11:34 AM
Hash: 1a036c4670da19ed22001afe7fa9ff123ef6a7c3c31b7e38196d97f6da4ccdd2
2024 May 02 8:44 AM
bcb9d15e59a98b1eb0c3e09d68541e04f2664adcea09bae78ae18ac3289ddf6b
2024 May 02 9:14 AM
hash:
c3f881f94ab3494b301b0e5a1e6e96acfb3e49e65c32507daa980d50cf012dac
2024 May 03 10:48 AM
My Submission
Task1 :
ad19443be163bbce27855f872e914368f00568d9e630ebfb1a5a39757c1c6029
Task2:
2024 May 03 6:38 PM
9b4c51a168f8c7fa4b69dae360be18a3b5a81e677018af7a2297a252c9270caf