Copyright 2013 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This sample application is not an official Google product.
This sample source code and project is designed to work with Xcode 4.6. The application is tested on iOS 6.1.
Mobile Shopping Assistant iOS Client demonstrates how to build an iOS client that mirrors the functionality of the Android client by leveraging the same Mobile Shopping Assistant Java Backend with the help of Google APIs Client Library for Objective-C.
After downloading this iOS client sample, unzip the package to extract the files in a directory of your choice. Note that this client sample has dependency on the Mobile Shopping Assistant Java Backend, the following section will provide instruction on how to set up the backend.
This section provides a step-by-step guide so you can get the sample up and running in Xcode.
-
Download and install Xcode 4.6 on your Mac computer if you don't have it installed.
-
Download Mobile Shopping Assistant Java Backend. Follow the README.md and deploy the backend to Google App Engine. Note that the Bundle ID for this iOS client is
com.google.sample.MobileAssistantIOS
. -
Follow steps in README.md in MobileAssistant-Data directory to import sample data to the deployed backend if you have not already done so.
- Open a new Finder window and navigate to the directory you have extracted the Mobile Assistant iOS Client. Double click on the MobileAssistantIOS.xcodeproj file. It will open the project in Xcode automatically.
-
The Mobile Assistant Backend was configured to use a particular IOS_CLIENT_ID in step 2 of the Prerequisites.
-
Look up the client secret, that corresponds to the IOS_CLIENT_ID in the backend, from Google API Console, update the following constants in the
ShopsTableViewController.m
file in the MobileAssistantIOS project:
- kKeyClientID (in line 36)
- kKeyClientSecret (in line 37)
- In the MobileAssistantIOS/API/GTLServiceShoppingassistant.m file, replace the string "{{{YOUR APP ID}}}" with the Application ID where the Mobile Assistant Backend was deployed.
-
On the top left corner of the toolbar in Xcode, select
MobileAssistantIos > iPhone 6.1 Simulator
. Click theRun
button to execute the app. -
Switch to the
iOS Simulator
application from Xcode. You can now interact with the MobileAssistantIOS Client App.
- Since this application is location-sensitive, to work with existing data in the Mobile Assistant Backend, set the location to
{Latitude: 37.785834, Longtitude: -122.406417}
via the menuDebug > Location > Custom Location…
- If prompted, click "OK" to allow MobileAssitantIOS app to access your current location.
- The application may ask for your Google Account information. Sign in and consent to allow the application to
view your email address
andknow who you are on Google
. - On the first screen, click any store location. On the next screen, the application will display different recommendations and offers based on different store location.
In ShopsTableViewController.m
file, set breakpoints to the following methods:
- getAllShops
- getAllOffers
- getAllRecommendations
These methods are responsible for making the requests to the Mobile Assistant Backend via the Google APIs Client Library for Objective-C.
- Click here to learn more about generating iOS client library for Google Cloud Endpoint.