NearBY is inspired from CognitiveConcierge. CognitiveConcierge is an end-to-end Swift application sample with an iOS front end and a Kitura web framework back end.
- Auto detection of Location using CLLocationManager.
- Bluemix Mobile Analytics.
- Plug and play options (You can add any category like museums, movie-theater etc.,).
- Flexible Kitura calls. Easy to add Google Place types.
- Push Notification via OpenWhisk whenever there is a significant location change.
- Mobile Foundation Authentication and Security added
More to follow....
Note: Most of the UI and backend is adopted from CognitiveConcierge app.
The app has two parts
-
NearBY-Server: Built using Kitura, a lightweight HTTP Web framework written in Swift allowing you to write complex routes easily and quickly. You will be using Kitura to talk to Google Places API.
-
NearBY-iOS: An iOS app written in Swift and using Watson Cognitive Services like Conversation, Text-to-Speech, Speech-to-Text and enhanced with Bluemix Mobile Services like Push Notifications and Mobile Analytics
For this project, you'll need an API Key from Google Places. Instructions for obtaining a key can be found here.
Once you have an API Key, go to the Google Developer's Console, and enable the Google Places API for iOS as well. Make note of the API key for later use in your server and iOS applications. Wait at least 10 minutes for the key to become active.
-
Install IBM Cloud Tools for Swift for MacOS.
-
Once you've installed the application, you can open it to get started.
-
Goto IBM Cloud Tools for Swift( App Menu) -> Advanced -> Create Sample Project from Github Repo and paste this link https://github.com/IC2017/NearBY and click Next.
-
Give a unique name to your project. Also a unique name (without special characters) to your Cloud Runtime (Server-Side). Click Save Files to Local Computer to clone the project.
-
This deployment to Bluemix may take a few minutes. Your Kitura server and other Bluemix services required for your app is provisioned along with the deployment.
-
Once the project is cloned, open up the .xcodeproj file that was created for you in ICT under Local Server Repository. Edit the Sources/restaurant-recommendations/Configuration.swift file's Constants struct with your own Google API Key for Web.
-
Re-deploy your server changes via ICT or via Cloud Foundry CLI
cf push
In ICT, ensure that the Connected to: field in the Client application is pointed to your server instance running on Bluemix. You can also point to your localhost for local testing, but you need to be running a local instance of the server application for this to work.
- Open Terminal and point to NearBY-Server under the cloned folder.
- Run
swift build
- This pulls all the dependencies mentioned in package.swift file including kitura.
- Run
./.build/debug/restaurant-recommendations
open a browser and point to localhost:8090 to see Kitura running.
- Once ICT has provisioned your Cloud Runtime, you should see that you have a Conversation Service instance in your Bluemix dashboard. This Service enables you to add a natural language interface to your applications. While you could create a conversation tree manually, ICT has run some set up scripts (found in the
Cloud-Scripts/conversation
folder) to add a populated workspace to your conversation service. This workspace is populated using the json found inResources/conversationWorkspace.json
-
Install Cocoapods Dependency Manager in Terminal with the command
sudo gem install cocoapods
-
Install Carthage Dependency Manager. Either download and run the .pkg file for their latest release https://github.com/Carthage/Carthage/releases or simply run
brew update
followed bybrew install carthage
-
From Terminal, change directories into the YourProjectName/NearBY-iOS folder.
-
Run the following commands to install the necessary dependencies:
carthage update --platform iOS
pod install
-
Open the NearBY.xcworkspace file in Xcode 8+ either from ICT or from your terminal using
open NearBY.xcworkspace
-
For your iOS application to run, it needs access to some credentials from Bluemix. ICT has run some set up scripts to generate and populate the
NearBY-iOS/CognitiveConcierge/CognitiveConcierge.plist
file. You will need to open this file and add your Watson, Mobile service usernames and passwords. Also the Google API Key. -
To point to localhost, open Bluemix.plist and set isLocal to YES.
-
Press the Play button in Xcode to build and run the project in the simulator or on your iPhone!
-
You can configure Bluemix Mobile Analytics by creating the service on Bluemix and adding the key in CognitiveConcierge.plist.
-
Also, Configure Push Notifications following the instructions here
- Provide Push Notification service credentials under AppDelegate.swift
var pushAppGUID:String = "" var pushAppClientSecret:String = "" var pushAppSecret:String = "" var pushAppRegion:String = ""
-
Mobile Foundation UserLogin Authentication
- Follow the instructions here to add authentication to your app via Mobile Foundation.
- Check the code under login folder on Xcode.
- Create a Mobile Foundation service on Bluemix and add the url to mfpclient.plist file.