The app uses API from World Weather Online. The API is free to use but requires registration in order to get a special API Key. Please register to get your key.
Building the UI
- To start, we are going to create a new app. From Apps tab, click Start Now button
- Under App Builder, click Go
- Under Mobile App, click Start Now
- Select Blank Mobile App app and click Next Step button
- Enter WeatherApp for app name and click Create.
- Once the mobile editor loads, you should see an empty phone in the middle of the screen (Blue theme selected):
On the left-hand side, Palette with Mobile components should be open:
On the right-hand side you will see Properties, and Events views
-
We are ready to build the UI. If you look at the phone, you will see Caption label at the top. That's part of the header. Double-click on it and change the label to Weather App, to look like this:
Note: you can control whether to show header or footer in Properties
- Now, from the Mobile palette, drag and drop Label component into the screen. When a component that holds a text value dropped into a screen, its label goes into edit mode. Change the label to: Zip code. The result should look like this:
- Next, drag and drop Input component, right below the Label component. Delete its label text.
- Because we are going to reference this component when defining services, we should rename the component. Select the component and head to Properties. In Properties, change its name to: zipCodeInput.
- Drag and drop Button component and change its label to Get Weather. The result should look like this:
If you want to change the spacing between each component, select the component and change its Padding property in Properties.
-
We are done with input portion, now we need to create UI for displaying weather result. We are going to display the temperature and an image. Drag and drop a Label component below the button. Delete its label text.
- We will need to reference this component when we use services so it's better to rename it. Select the component and head to Properties. In Properties, changes its Name to: temperature.
- The last component we are going to use is Image. Drag and drop Image component, below the label.
- In Properties, changes its default name mobileimage0 to icon.
- The final UI should look like this:
- One of the nice features in Tiggr is that you can test the app and see how it looks in browser. Simply click Test button to open the app in browser (make sure you allow pop-up for *.gotiggr.com domain).
- To view the app on mobile device, open Test menu and check Public, to make the app link public. There are three ways to get the app link to open in mobile browser:
- Type the app link in mobile browser
- Scan the QR code
- Email the link to your device
Defining REST service
- We are ready to create a service which will connect to weather REST service. Open Palette > Services.
- Drag and drop REST Service component into the screen. You will be prompted to select a service. As the service doesn't exist yet, click Add new.
- A service editor will open:
- For service URL enter: http://free.worldweatheronline.com/feed/weather.ashx
- For Data type, select jsonp
- Now that we are done defining service settings, next step is to define service inputs. Open Request Parameters panel
- This is where you define request parameters for the service. The weather service requires three parameters:
- q - zip code
- format - response fomrat
- key - API key (get a free API key here).
- In the input field, enter q and click Add.
- Now create two more parameters, format and key. The result should look like this:
- For format, enter json as the Default value.
- For key, enter the API key as Default value.
- Let's now test the service, click Test Connection button.
- Enter any zip code value for q
- Click Test. The result should look something like this:
- The next step is to define service response parameters. If you scroll through the test results, you will notice that the Weather REST service returns a large number of parameters. Creating them all by hand could be time consuming and error prone. Of course you can only define the parameters that you need. However, another solutions exits.
- Run service test again.
- Click Populate Response Structure button. This feature will automatically create the service response based on parameters present in sample test.
- Click Close, Response Parameters panel should now be open, listing all response parameters (after expending data and weather):
- We are done defining the service. Click Save and then Close. You should be back at the screen editor, and the service just created shown on the right-hand side:
Mapping UI and Service
- Now we need to map UI to the service. With the rest service1 instance selected, click Data Mapping tab. Request Mapping should be selected by default.
- Define the mapping by selecting Text property and connecting it to q property on the service side. Both format and key are predefined.
- Now click on Response Mapping button to map service output to UI.
- Define the following mappings:
- temp_F --> temperature/Text
- weatherIconURL/value --> icon/Asset
The result should look like this:
- Click Save
Defining Action to Invoke the Service
- One last thing left to do is invoke the service on button click. Select the button and switch to Events view (on the right-hand side)
- Click Add Event > Click.
- For Click event, click Add Action button and select Invoke Service action
- Select rest service1, click OK
- We are ready to test the app. Click Test button, enter any zip code and click Get Weather button.
Testing the app
The resulting app should look like this:
There are three ways to test the app:
- In Web browser
- Launching the app from Tiggr Mobile Tester app
- Installing the app on Android device
1. Testing in Web browser
Click Test to launch the app in Web browser. You can also select Test > Launch in Web Browser.
To test on mobile browser, from the Test window make the app URL public and pick one of the options:
- Email app link to your phone
- Scan QR code
- You can also go to http://gotiggr.com on your mobile device. Sign in and you will see your app listed. Click on the app to run it.
- Just enter the URL in mobile browser by hand
2. Launching the app from Tiggr Mobile Tester app
Tiggr Mobile Tester is an app from which you can test apps built in Tiggr. Tiggr Mobile Tester is available for iPhone and Android.
To install the app on Android, click Test and select one of options:
- Scan the QR code for Android or click Android Market button
- You can also search for Tiggr Mobile Tester in Android Market app on your device
- You can also find it here:: https://market.android.com/details?id=com.exadel.tiggr.projectlist
To install the app on iOS device, click Test and click the Download button for iOS
- Tiggr Mobile Tester for iPhone source code is available for download as an open source project. Please follow the instructions outlined in readme.txt on “How to Build an iOS Binary”.
Once the app is installed, launch it and log in. Use the same credentials as for http://gotiggr.com Find your app in the list and tap it.
3. Installing the app on Android device
To download Android binary file, select Export > Android binary. Save the file and install it on your device. One quick way to install the file is to email it to your device. When the email arrives, the phone will recognise .apk attachment extension and you should see Install option.
|