Webinar Recording: Building a Barcode Scanner App Integrated with Backend Services

In case you missed our webinar, watch this recording to learn how to use Appery.io to build a barcode scanner mobile app. (At the end of this post is some of the coding used in the webinar.)

Check out many other videos on the Appery.io YouTube channel.

Code used in webinar demo

Server Code script to check for low inventory and to send a push message and e-mail:

var databaseId = "database_api_key";
var collectionName = "Products";
var result = {};

var params = {};
params.criteria = {
  'quantity': {
    "$lt": 5
  }
};

result.query = Collection.query(databaseId, collectionName, params);

var emailText = [];
var productCount = result.query.length;

if (productCount !== 0) {
  for (var i = 0; i < productCount; i++) {
    emailText.push(result.query[i].name + ": " + result.query[i].quantity);
  }
  // send email
  sendemail(emailText.toString());
  
  PN.send("push_api_key", {
    "message": emailText.toString()
  });  
}

response.success({
  "status": "Inventory check completed"
}, "application/json");

Server Code library (a script that can be easily reused) that sends e-mail using the SendGrid API:

function sendemail(emailText) {
  
  var url = "https://api.sendgrid.com/api/mail.send.json";
  
  var xhr_response = XHR2.send("POST", url, {
    "parameters": {
      "api_user": "sendgrid_user",
      "api_key": "sendgrid_password",
      "to": "to_email",
      "from": "from_email",
      "fromname" : "Warehouse Update",
      "subject": "Inventory update",
      "text": "The following products need your attention: \n\n" + emailText
      
    }
  });
  
}