Using Parse for IoT to Create an Order Button

Yesterday, Amazon announced the Dash button, a small device with a single button and a single purpose: Pressing the button orders an item on Amazon. This is just the latest in the continuing trend toward connected smart devices, and we immediately saw the possibilities for our developer community to create devices for their own apps. Feeling inspired to experiment, we spent half an hour with an Arduino Yún, a push button, and the new Parse for IoT SDK to create a device that simulates ordering toilet paper when we’re running low. As you’ll see here, it’s amazingly simple to build a working order button that connects to your app using Parse tools. Here’s how we did it:

We connected a push button to the Arduino and used a small breadboard so the button would sit neatly on top of the Arduino. As you’ll see later, we used the Arduino’s packaging as an enclosure.

IMG_2266

The code on the Arduino is as simple as it gets. You can find the full sketch file in the Github repo, but here’s the meat of it. It just calls a Cloud Function:

// Send request to parse from the Arduino Yùn
ParseCloudFunction cloudFunction;
cloudFunction.setFunctionName("orderToiletPaper");
ParseResponse response = cloudFunction.send();
response.close();

Deployed in Cloud Code, we have this bit of JavaScript. It makes a request to the Shopify store we created, to order some toilet paper.

// Define the 'orderToiletPaper' Cloud Function
Parse.Cloud.define("orderToiletPaper", function(request, response) {
  var shopifyAppId = 'your-shopify-app-id';
  var shopifyAppPassword = 'your-shopify-app-password';
  var shopifyStoreName = 'your-shopify-store-name';
  var shopifyURL = 'https://' + shopifyAppId + ':' + shopifyAppPassword + '@' + shopifyStoreName + '.myshopify.com/admin/orders.json';

  Parse.Cloud.httpRequest({
    url: shopifyURL,
    method: 'POST',
    headers: { 'Content-Type' : 'application/json' },
    body: {
      order: {
        email: 'matt@parse.com',
        send_receipt: true,
        line_items: [
          { title: 'Parse Toilet Paper', id: 443357149, quantity: 1, price: 0.00 }
        ]
      }
    }
  }).then(function(data) {
    response.success('Ordered some TP.');
  }, function(error) {
    response.error(error);
  });
});

Some of our industrial designers and materials engineers used our state-of-the-art facility to create a truly beautiful product that you can’t help but fall in love with. As you can imagine, we used nothing but the latest technologies to create this masterpiece:

making

The next time we’re running out of toilet paper, you can be sure it will be promptly refilled with another cloud-soft roll.

IMG_2272

Taking this example further, you could associate devices with user accounts, fully integrate with Shopify or another API (or build your own!) and offer a premium push-button experience for people using your app. You can find the full source on our Github repository, but most of it is already in this blog post. The whole app is less than 100 lines of code!

We’re excited about the possibilities of Parse for IoT, including order buttons and much more. Let us know what you build!

Mattieu Gamache-Asselin
April 1, 2015

Introducing Parse Pigeon

*pigeon noises*At Parse, our goal has always been to find ways to make developer’s lives easier. In the past we have kept this strictly digital — taking care of all of the complicated backend server technology so you can focus on what makes your app awesome. Today we’re happy to announce that Parse is taking that core principle one step further to its next logical evolution, the physical world — with an infinitely scalable, on-demand pigeon fleet specializing in aerial delivery.

Recently, we’ve seen a growing mobile trend toward offering on-demand delivery of products and services. These apps provide real, tangible value to their customers, but it’s an extremely costly field to enter. The logistics behind moving things around in the real world are complicated and ridiculously time-consuming to get right. We think birds can help, providing a revolutionary shift of power to any developer who wants to offer near-instant delivery experiences. Enabling that shift is our goal with Parse Pigeon.

Pigeon was hatched from a hackathon project I worked on with one of our front end engineers, Andrew. He had recently adopted a pet pigeon and we were both amazed by its intelligence and navigational ability. It became obvious to us that we could use this animal’s skills to bring a game-changing product offering to life. A few Arduinos and pigeon-poo covered t-shirts later, and we had a working proof of concept.

We’re really excited to see how this helps our developers create new and unique products centered around on-demand delivery. We’ve been privately testing this with a few pigeon-friendly partners (one of them might rhyme with ghost-dates) and they’ve told us that Pigeon has changed the way they’re looking at the future of their delivery back-end.

Head over to the Parse Pigeon page to learn more about this exciting new product. We’ve opened up our waitlist for new partners, so be sure to sign up early if you’d like to be the first to integrate the power of pigeons into your app.

George Kedenburg III
April 1, 2015

Five New Products, Live From F8

F8 Roundup

Today we’re incredibly excited to share five new product announcements with you plus an update to our SDKs, live from the F8 Developer Conference at Fort Mason in San Francisco.

Since F8 2014, our community of developers has grown to include over 400,000 of you from around the world, moving fast and shipping great experiences on Parse every single day. This community is powering more than 500 million active app installations in the last month alone.We’re always looking for ways to help you build, scale, and secure the most successful app experiences possible.

Introducing the latest and greatest updates to the Parse platform:

Better Security with the New Enhanced Sessions
Giving you more control than ever over your app’s security, the new Enhanced Sessions feature allows you to manage session logins for each device that your users log in with. Read more

Parse for Web, Parse for Mobile, and now Parse for Internet of Things
Starting today, it is easier than ever to use Parse to build apps for devices like garage door openers, smart batteries, thermostats, security cameras, and much more. Using our new SDK for the Arduino Yún and our Embedded C SDK for Linux and Real Time Operating Systems (RTOS), you can now use the power of Parse to more easily connect apps to hardware devices. Check out the new SDKs

Let’s Build Together — with Parse + React
Meet our new Parse + React library, making it incredibly easy and seamless for you to access and store Parse data from React applications. Build complex and dynamic apps like never before. Access these tools now

Endless Possibilities, No Matter Which Server You Love
With the new Cloud Code Webhooks, you now have the freedom to write code in whatever language or framework you want. As long as you have a server running it, your Cloud Code can integrate with it. Get started here

Chart New Territory with Parse Explorer
Try our brand-new, powerful debugging tool for production issues in your Parse app. Investigate what’s happening with a subset of your app’s API requests with our powerful yet easy-to-use query language. Find out more

Supporting Facebook SDK v4
Prior to today, integrating the Facebook SDK with our Parse iOS and Android SDKs has been a seamless process. With the new release of Facebook SDK v4, we’re excited to continue to offer the same level of support for the new v4 SDK from day one—while continuing to support the v3 SDK. Download the new SDKs here

We hope you enjoy exploring these new releases. Tune in to the livestream today and tomorrow to catch five in-depth Parse sessions, in addition to exclusive online content from F8. Happy building!

Nancy Xiao
March 25, 2015

Parse and React, a Shared Chemistry

Parse + React

As a web engineer, I love React. I’ve been using it since it was an experimental technology within Facebook, and each new version has helped make complex app development simpler. A few months ago, I started exploring how to best bring our Parse tools into the React ecosystem, in a way that feels like a natural extension of React. And today at F8, we’re excited to launch these tools for Parse and React developers. Our Parse+React library makes it easy to read and write Parse data from React, and gives React developers a way to effortlessly add remote storage to their applications.

Parse+React, available now on Github and npm, gives components the ability to subscribe to Parse queries, and allows them to update Parse data while still preserving React’s single direction of data flow. To give a component access to a Parse query, you simply have to subscribe to it from the component. Data requirements are co-located with the component itself — that way, there’s no need to worry about fetching data when a component renders, or routing the data through the component tree to its destination. Consider this component, designed to render a list of comments:

// Render a list of comments passed into the 'comments' prop
var CommentBlock = React.createClass({
  render: function() {
    return <ul>
      {this.props.comments.map(function(c) {
        return <li>{c.text}</li>
      })}
    </ul>;
  }
});

It requires fetching the comments somewhere else, and ensuring that they get passed into this component when it renders. With Parse+React, adding data from a Parse Query is this simple:

// Render a list of comments from the Parse API
var CommentBlock = React.createClass({
  mixins: [ParseReact.Mixin],

  observe: function() {
    return {
      comments: (new Parse.Query("Comment")).descending("createdAt")
    };
  },
  
  render: function() {
    return <ul>
      {this.data.comments.map(function(c) {
        return <li>{c.text}</li>
      })}
    </ul>;
  }
});

This component includes the Parse+React Mixin, which lets it subscribe to Parse Queries. The observe() method declares subscriptions to different queries, and makes the results available on this.data.

When it comes to modifying data, Parse+React takes a functional approach to maintain a single direction of data flow. This helps applications scale easily, preventing deadlocks or synchronization issues when many components share data.

// Create a new Comment object
ParseReact.Mutation.Create("Comment", { text: "Parse and React work well together" })
  .dispatch();

A mutation is applied to an object and dispatched, and the result will be immediately available to components with subscriptions. So, if we created a new Comment object, it would be added to the result set of the CommentBlock above. This lets you build snappy interfaces that immediately respond to user input.

With these two tools — query subscription and object updates — you’ll be able to build React applications that easily include data persistence. I’m thrilled to be bringing the power of Parse to React developers, and this is just the beginning. We’ll continue to work closely with the React team to ensure that our tools take advantage of the latest features. In fact, when React Native becomes available to the public, you’ll be able to use Parse with it from day one! The field of app development is changing, and we’re here to help you at each stage.

Andrew Imm
March 25, 2015

Connecting Hardware with the Cloud: Parse for IoT

Parse for IoT

At Parse, our passion is making developer experiences easier on any platform—including platforms that extend beyond mobile. Of these platforms, one of the most exciting new spaces is the Internet of Things. We believe that connecting more hardware devices with the cloud has the potential to change the world for the better. We are already seeing devices that add tremendous value to people’s lives, from wearables that help you sleep better to insulin trackers that aid people living with diabetes.

But, as with mobile, connecting these devices to the cloud can be difficult. In addition to maintaining a backend, developers must contend with notoriously constrained environments on the client. We’ve been listening to feedback from a wide range of Parse customers who are already using our platform in hardware products — like Chamberlain, who makes a line of smart garage door openers that interact with our REST API; Milestone Sports, who make the wearable running tracker Milestone Pod; and Roost, who make smart batteries for smoke detectors. From these conversations, we decided we could go one step further.

Today, we’re proud to announce Parse for IoT: an official new line of SDKs for connected devices.

The first is an Arduino SDK targeted for the Arduino Yún, a microcontroller board with built-in WiFi capabilities. The SDK interface is in Wiring, and, in the spirit of Arduino, we designed it to be as simple as possible. For example, all it takes is a few lines of code to save temperature data from a smart thermostat:

ParseCreateObject create;
create.setClassName('TemperatureReading');
create.add('currentTemperature', 175.0);
create.send();

From there, the data will be available in your Parse app ready to be retrieved by your mobile app, another device, or simply logged for analytics purposes. Beyond the Yún, we’re already working on SDKs for upcoming platforms such as the Arduino Zero with the WiFi 101 shield.

In addition, we’re releasing an Embedded C SDK, targeted for Linux and Real Time Operating Systems (RTOS). These open source SDKs serve as reference implementations that are being used by leading chipset manufacturers to provide support for their hardware platforms. If you are a chipset manufacturer interested in working with us, please reach out at iotpartners@fb.com.

The C SDK provides a simple interface for our REST API. For example, to save the same temperature data you would do:

char data[] = '{ \'currentTemperature\': 175.0 }';
parseSendRequest(client, 'POST', '/1/classes/TemperatureReading', data, NULL);

You’ll be able to find these SDKs on GitHub, as well as a full set of Quick Starts and Guides on Parse. With these SDKs, your device will be able to receive push notifications, save data, and take advantage of the Parse Cloud. It’s easy to get started from scratch, and the process should be very familiar for developers who already use Parse. Check out the Quick Start guide and start adding Parse to your hardware device in minutes.

The possibilities are endless. You could make a smart thermostat that can be controlled via a mobile app, or a security camera that saves images every minute, or even a music device that can be controlled via a web app. We’re so excited to see what you build.

James Yu
March 25, 2015

Chart New Territory with Parse Explorer

Parse Explorer

Today we’re excited to announce a new, powerful debugging tool for production issues in your Parse app: the Parse Explorer.

For a large app, it can be complicated to track down when something is going wrong. With thousands or millions of API requests, how do you fix it when a small fraction of these are broken? How do you improve it when some section of them are running slowly?

The Parse Explorer offers a powerful query language to let you investigate what’s happening with a subset of your app’s API requests. You can use this powerful query language to dig through timestamped, heavily denormalized logs tracking each bit of communication that your app does with Parse. This approach is powerful, yet simultaneously easy to use.

We’re also surfacing something we’ve never explicitly exposed before: the measured latency on each of your requests. We start counting immediately upon receiving your API request and stop counting right before we return a response, so you know just how long your app was waiting for Parse to do its work. We think it’s a pretty powerful way to start drilling down on which actions are most costly for your users.

Here’s an example. Say our Parse app is growing and we want to figure out what part of the app the increased usage is coming from. Here’s where we start:

Explorer Hero

We don’t know what sort of data we’re looking for yet, so let’s pick the most flexible format choice: a table.

We’ll start off by looking at the pure number of requests, grouping by time to confirm that this usage is growing. We’ll also group by request type hitting Parse to confirm that the distribution of requests is what I’d expect of my app.

Explorer Group By Day

Sorting by the Count of rows tells us that — yep, the last few days have all been pretty active, and the most common type of request that has recently taken place is an update. I wonder if we can figure out which classes are receiving those updates — and from there, why.

Explorer Which Classes

Either my app is going through crazy growth, or there’s something funky going on with extra _Installation updates hitting Parse — and if we keep digging in, we’ll discover more and more. Check out the Parse Explorer for your app and let us know what you think! Access will be rolled out gradually to accounts on Parse.com, so keep an eye out and think about what you’d like to see next. Happy exploring!

 

Christine Yen
March 25, 2015

Introducing Cloud Code Webhooks

Webhooks

Ever since launching Cloud Code, we’ve been amazed at what Parse developers have built with bits of JavaScript code. From simple object mutations to complex game state management systems, Cloud Code has proved to be a versatile tool. But one of the biggest requests we’ve received is the ability to run any kind of language or framework to manipulate your data.

Today, we’re excited to announce the launch of Cloud Code Webhooks. With this, you can now specify any URL to receive a POST in response to triggers like beforeSave and afterSave on objects, as well as when a Cloud Function is called. You now have the freedom to write code in whatever language you want. As long as you have a server running it, your Cloud Code can integrate with it.

To get started, head over to the new Webhooks section located in the Core dashboard. For example, let’s say you want to hit your server at www.example.com/process_puppy whenever a Puppy object is saved. All you have to do is specify this as a beforeSave webhook:

Screen Shot 2015-03-24 at 8.06.32 PM

When Parse receives a request to save a Puppy, your server will receive a POST with the following JSON payload:

{
  "object": {
    "className": "Puppy",
    "name": "Spot",
    "type": "Corgi",
    "age": 1
  },
  "triggerName": "beforeSave"
}

Now, your server can process the Puppy data however you want. In addition to these parameters, you can get data about the User, Installation, and other relevant fields.

Similar to regular Cloud Code triggers, you can change the Puppy by returning a 200 response with an altered object. For example, if you wanted to change the name of the Puppy to Rover, you would return:

{
  "success": {
    "className": "Puppy",
    "name": "Rover",
    "type": "Corgi",
    "age": 1
  }
}

The possibilities are endless. Perhaps you want to reliably save and process all your object data for offline analytics. You could easily stand up a Rails app on Heroku to receive this. Or, maybe you have extensive experience running LAMP stacks on AWS—now it’s possible. Whatever server you love, Parse can integrate with it.

Check out more in our Cloud Code Guide on Webhooks and get started today.

James Yu
March 25, 2015

Announcing Enhanced Sessions

Enhanced Sessions

At Parse, we’re constantly striving to provide the tools you need to make your app more successful. One of the most important aspects of an app’s success is security, so that people can trust your app when they use it. Parse already provides several tools to secure your app, including Access Control Lists (ACLs) for Parse Objects, Class-Level Permissions for each data table on Parse, and Cloud Code for even more in-depth security customizations. Today, we’re excited to announce an update to our previous sessions functionality. With the new Enhanced Sessions feature, we’re giving developers and people more control than ever over data security.

Prior to this launch, if a user logged into your app through multiple devices, this same session token was shared across all devices. This session token was not revocable, and upon logging out, the token was not destroyed.

Now, with Enhanced Sessions, the Parse Cloud will assign a unique revocable Session object for each user on a given device for your specific app. This means different devices and web browsers will have different session tokens for the same user in your app. On mobile and web apps, you don’t have to worry about creating and destroying sessions yourself. When users log in or sign up, the Parse Cloud automatically creates the corresponding Session object. When users log out, the Parse Cloud automatically destroys the corresponding Session object, which invalidates the session token that was previously assigned to that user’s device.

We’re also introducing a flexible Revocable Sessions API that lets you easily understand and securely manipulate user sessions in your app. You can see your app’s Session objects in your Parse account’s Data Browser, just like any other Parse object. If a user contacts you about his or her account being compromised in your app, you can use the Data Browser, REST API, or Cloud Code to forcefully revoke user sessions using the Master Key. These new APIs also allow you build a “session manager” UI screen where your app’s users can see a list of all devices they’ve logged in with, and optionally log out of other devices. This empowers people who use your app to help monitor and protect their accounts. In addition, for increased security, you can configure your app to automatically expire user sessions due to inactivity.

Sessions

Today, we also announced Parse for IoT. The Revocable Sessions API lets you implement scenarios where people can use your app on their phone to provision restricted user sessions for their IoT connected devices. This not only allows IoT devices to securely access user data, but also protects your users’ accounts in case their IoT device gets stolen. For example, the session token on an IoT device cannot be used to modify User objects on Parse.

The new Revocable Sessions API is available on all Parse SDKs (iOS, Android, C#, JavaScript, PHP) as well as our REST API. All new Parse apps created after today will have Revocable Sessions enabled by default (configured in your app’s Parse.com dashboard settings page). You can use existing login/signup/logout APIs in the same way as you did prior to this new feature. The only significant change is that you’ll have to handle a new invalid session error on Parse API requests, and prompt the user to log in again when necessary. Your app will encounter this invalid session error when that device’s user session token is revoked from elsewhere. This happens when your user logs out of that phone from the “session manager” screen of another phone, or when you (the app developer) use the Master Key to programmatically delete that Session object in the Parse Cloud.

If you currently have a production app on Parse, we recommend that you upgrade to the new Revocable Sessions API as soon as possible to take advantage of the new, more secure model with unique tokens for each device, and the ability to easily revoke user session tokens when necessary. We’ve prepared a Session Migration Tutorial to help you upgrade your app smoothly.

For more about our Revocable Sessions API, please see our documentation.

Stanley Wang
March 25, 2015

Tune in to F8 Tomorrow

F8 kicks off tomorrow, and we have many surprises in store for you.  Attend F8 online from wherever you are through our livestream event.  There, you can catch the keynotes, five Parse sessions, and exclusive content for our online community.

Be sure to check out The Latest and Greatest from Parse session on Day 1, Wednesday, March 25th to hear about new products and features as well as ecosystem updates.

On Day 2, we’ve got tons more content for you:

  • Getting Started With Parse by Fosco Marotto and Christine Yen — Here, we’ll be giving an interactive introduction to Parse, where you’ll get everything you need to build an awesome app in just minutes. We’ll walk through building a simple app on Parse using the breadth of the platform.
  • The Next Level: Building Complex Apps on Parse with Héctor Ramos and Eric Nakagawa — We’ll dive into advanced functionality, under-the-hood product insights, and commonly asked questions when building a complex app on Parse.
  • Running at Scale on Parse by Charity Majors and Thomas Bouldin — We’ll share tips from high-traffic apps powered by Parse today, plus tips for designing and building your app with scalability in mind from the start.
  • How Mobile-Focused Startups Are Building Their Businesses on Parse — We’ve invited startup CEOs and leadership from Stubhub, Kitchenbowl, MileIQ, and Apalon to share their best practices and learnings from building successful businesses by leveraging Parse and Facebook tools.

For our Bay Area friends, we will be co-hosting a Happy Hour with FbStart following the close of Day 2.  Attendance to F8 is not required.  RSVP here.

We can’t wait to see you tomorrow–there will also be updates throughout the day right here on our blog.  Stay tuned!

 

Nancy Xiao
March 24, 2015

MileIQ Finds a Mobile Backend that Goes the Distance with Parse

MileIQ

“How much would you pay for an app that put more than $500 extra into your pocket each month without any effort or behavioral change on your part? That’s the question that MileIQ users are asking themselves after just a few days of using the mileage tracking and reporting app.”  – PandoDaily, January 2015

Since its launch in late 2013, MileIQ has saved both time and money for countless users with its highly popular iPhone and Android apps. It has topped the charts as the #1 grossing Finance app in the App Store for many consecutive months, and continues to dominate headlines and home screens alike. Much of MileIQ’s rousing popularity can be attributed to the app’s acute focus on developing an incredibly delightful user experience for a very tedious user problem: mileage tracking and reimbursement.

Reimbursable miles are one of the most commonly audited things by both employers and the government.  However, an easy way for employees to log these miles is a problem less commonly tackled.  With MileIQ, employees can easily track the distance they’ve driven so they can efficiently and seamlessly file for a tax deduction or employer reimbursement.  This has proven to be hugely useful across the globe–and for the 50 million workers driving a significant amount for business in the U.S. alone.

The MileIQ app automates the capturing of miles, in addition to detecting the information the IRS needs–including departure, arrival, times, and distance.  With so much data to maintain and capture on-the-fly, the MileIQ team sought a robust mobile backend service.  From the team’s early development stages, Parse became crucial for prototyping and eventually as a stable backend:

The confidence we had in Parse was especially useful in the early stages of the development process–it enabled us to iterate rapidly towards a product that delights users with its ease of use across mobile and web.

Everything from user registration to capturing geopoints are stored in Parse with the use of Parse Core.  In addition, the MileIQ team uses Parse Push to engage with drivers through highly targeted notifications, including an alert when a drive has been logged.  The team describes using Parse to be an influentially positive decision for their app:

Parse enabled us to focus on each of the different parts of the system and reduce our development burden and operational overhead…The Parse toolkit helped with everything from account passwords and provisioning to push notifications and in-app purchases–it is easy to recommend it as an indispensable tool for developing mobile first user experiences.

 

The MileIQ app is now available for download on the App Store and Google Play Store, and visit their website here.

Nancy Xiao
March 13, 2015

Archives

Categories

RSS Feed Follow us Like us