3 weeks ago - last edited 2 weeks ago 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.
3 weeks ago
fdf88fb3b3b2300adf61f4c9e93c68eda905374a3d68a51090ca608254bc1c54
3 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
I see, I did not use that object, i use directly "Device GPS location" to set my variables.
95dd39f48a747f22d06661979a6f640cd579341d79c8dca5ca85f83e0b750b8e
2 weeks ago - last edited 2 weeks ago
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"
2 weeks ago
The one liner formula seems interesting! Thanks for the tips Daniel.
2 weeks ago
2 weeks ago
My Hash: f5f257949eb93bbc7426bb0ee821e496103694a9b01e1b8e722ab312f4aa538d
2 weeks ago - last edited 2 weeks ago
Part 1:
Hash : 2ea183ae4e7826800a618ced5d0c77c5703811ba84c12feb776f050925380527
Part 2:
It was great learning, thanks for the month-long challenge, learnt a lot.
2 weeks ago
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
2 weeks ago - last edited 2 weeks ago
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:
2 weeks ago
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.
2 weeks ago
@Dan_Wroblewski thanks for the clue, hoping this time it is correct:
891d85afe3c68cec7d0335af69aa33f5031902dd7c88100a2caafda797e86774
2 weeks ago
2 weeks ago
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.
2 weeks ago - last edited 2 weeks ago
Here's my hash: c20121f9f09def9ee2c23239cdb6c79746eb93fa5631198368763a294ba439a6
Screenshot from Part-1:
Screenshot from Part-2:
2 weeks ago - last edited 2 weeks ago
Here my Hash -
e070dd59b916de9ecf23d9f4c03903faac9e91443a9edb09bfa91f21baec6b0f
part-1:
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago - last edited 2 weeks ago
Hello,
Task1:
Hash: 24cc8a822e8ff93ec82ff3aff04eee6e07e5b61e7be6c274d7aac3722dbfa663
Part 2:
Edit 1: the second task was added.
Edit 2: thank you for the great challenge!
2 weeks ago
Great challenge - Thanks for challenging me 😉
HASH
4a28b3a8d628148deb86e559b7feba5cfc3deaaa0979c9040631105206e34b8d
Part 1
Part 2
2 weeks ago
2 weeks ago - last edited 2 weeks ago
Another try (had hashed the name at the left): 9276fedb6a9767c19c8868ea52b8e08d7ed0f73dad699df613fcd61cfa2ab49a
2 weeks ago
2 weeks ago - last edited 2 weeks ago
D0a2aec79b9b932a1322521d22e81d42528d798171d87abd738ee8462d47d5b2
2 weeks ago
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?
2 weeks ago - last edited 2 weeks ago
4525a31fbb4024c83ffe33fc73121d804138d41449741c4955135d0e1a7777f1
I hope this one is correct!
2 weeks ago
Please help.. i created an account in foursquare yesterday but it's not allowing me to create any project.
2 weeks ago
@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.
2 weeks ago
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?
2 weeks ago
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.
2 weeks ago
2 weeks ago
2 weeks ago
Hash: 1a036c4670da19ed22001afe7fa9ff123ef6a7c3c31b7e38196d97f6da4ccdd2
2 weeks ago
bcb9d15e59a98b1eb0c3e09d68541e04f2664adcea09bae78ae18ac3289ddf6b
2 weeks ago
hash:
c3f881f94ab3494b301b0e5a1e6e96acfb3e49e65c32507daa980d50cf012dac
2 weeks ago
My Submission
Task1 :
ad19443be163bbce27855f872e914368f00568d9e630ebfb1a5a39757c1c6029
Task2:
2 weeks ago
9b4c51a168f8c7fa4b69dae360be18a3b5a81e677018af7a2297a252c9270caf