Cloud Execution App Status

The app status is a mechanism to check the status of your app when you run it in the cloud.
Unlike the browser, you can't see the result of cloud execution, so you can check it with the app status.

If you don't do anything in the cloud, the program will end at a specified time (depending on the plan) and the timeout will be recorded as the app status.

You can update this status from the app program. As you can see in documentation, there is a special function for this purpose.

First, it determines whether it is executed in the cloud or not with Obniz.App.isCloudRunning(), and updates the app status with Obniz.App.done() if it is executed in the cloud.

If the app is running in the cloud, it updates the status by Obniz.App.done(). Calling `done()' updates the app status and the cloud execution.

if (Obniz.App.isCloudRunning()) {
  Obniz.App.done({
    status: 'success',
    text: `It's OK`
  })
}

You can store any string of characters, so you can record the value of the temperature sensor, for example.

if (Obniz.App.isCloudRunning()) {
  var temp = '27'
  Obniz.App.done({
    status: 'success',
    text: `${tmp} degree`
  })
}

You can choose error as the status. If it is error, it shows an error.

if(temperature > 30) {
  Obniz.App.done({
    status: 'error',
    text: `Too hot ${temperature} degree`
  })
} else {
  Obniz.App.done({
    status: 'success',
    text: `It's fine ${temperature} degree`
  })
}

関連の質問