An authenticated Swift 4 + Vapor webserver and REST API + DB, and two iOS apps utilizing the API. Includes a ClientAPI for JS clients, with a populator.ts that populates the DB with randomish data.
$ git clone https://github.com/riyadshauk/coupon-retailer-shopper-app.git \
&& cd coupon-retailer-shopper-app && git submodule init && git submodule update
I’ve used two 3rd-party libraries when building the mobile apps (a QR Code reading library, and form-creating library, Eureka – to easily write a clean login form). To get them working properly for this project, we utilize git submodules, as shown above. Alternatively, Cocoa Pods or Carthage could have been used.
This project consists of an authenticated REST API + DB (written in Swift 4 + Vapor, can build on both Linux and macOS), which also contains a ClientAPI/db_scripts/populator.ts to populate the database associated with this REST API via a client-side JavaScript wrapper API.
This project also consists of two client-side applications (both written in Swift 4): A Retailer app, RetailerQRReader, and a Shopper app, ShopperQRCodeCouponClient.
I made these for a demo POC project. The two iOS applications were initially just hacked together over a couple days, so I didn’t spend nearly as much time on code quality and design as I did on the authenticated REST API + DB I built.
timesProcessed
variable associated with the coupon that was scanned has increased by oneFor the iPhone apps built in Swift 4, after properly cloning this repo, you will just need to open their corresponding .xcodeproj files to launch each app’s Xcode project.
Note that in order to run these apps, you will need to modify the URL of the webserver to wherever you run your webserver (which will probably be localhost:8080). However, connecting to an iPhone app on localhost:8080 doesn’t really work too well. For that, a simple solution is to download the Ngrok tool, then run ngrok http 8080
in your terminal, for example; this will open up your localhost webserver running on port 8080 at a specified temporary ngrok URL (with an 8 hour lifetime). Use that URL (outputted in your Terminal) as the webserver URL used in the Retailer and Shopper client apps (search for http
or ngrok
to find those locations, and do a simple find-replace).
Alternatively, you could run your webserver using a free tier account with vapor.cloud, made by the developers who built the Vapor web framework that this project’s backend webserver is running on (the webserver is actually an adaptation of the project generated from the following scaffolding command: vapor new WebServer --template=auth-template
, as documented on vapor.codes).
Go ahead and follow these directions for how to test an iPhone app on a real device using Xcode, or something similar, for more info.
Product > Scheme > Eureka
Product > Build
(make sure to have your device selected, similar to how you normally would)Product > Scheme > ShopperQRCodeCouponClient
Product > Run
(as you normally would)ShopperQRCodeCouponClient
in the Project Navigator pane.General
for the target ShopperQRCodeCouponClient
.Embedded Binaries
, click the plus-symbol, and select Eureka.frameworkiOS