iOS - Dump Item App
This iPhone app is to update inventories information in stores. When user goes to a store, the app locates which store it is by iPhone GPS.
We use its camera to scan the product barcode (UPC). The GPS location and UPC data send to web server (IIS) through internet. The server gets required data from database and responses back to the app.
Then user can adjust the quantity of the product.
Use iPhone's camera as scanner to scan barcode (UPC). Add a framework "AVFoundation.framework" into project in XCode. Create a header file name "ScanUpcViewController.h" and put these code in.
Create a file called "ScanUpcViewController.m" and put these code in.
Use iPhone GPS location feature to get geocode (longitude and latitude).
First of all, we get geocode from iPhone. We add framework called "CoreLocation.framework", "#import ", and "CLLocationManagerDelegate" in header file.
Then we initialize the CLLocationManager. In XCode 5, the initWithCoder method will run first so that we put location manager initialization there.
After location manager initializes, we can get geocode by these code:
And then it sends location data to web server.
The server analyses the location data and finds which store is closest. SQL Server 2008 or later version database has geography data type which is easy to handle geolocation.
Here I use SQL Server 2000 which doesn't support geography data type. So I create a function in database called "fnCalcDistanceMiles". It calculates the distance between two points (geocodes)
How to use the above function? For example, we search a shortest distance of a customer. The SQL is:
It returns the shortest distance data.