Bixby Developer Center

Guides
References

Refreshing Your Content

Definition and Implementation

You might have instances in your capsule where you need to poll your content provider with updated information, for example if you need to update the contents displayed to your user about some information. In these cases, you can use the refresh reference key in a result-view, input-view, or confirmation-view file to accomplish this.

For example, you might want to create a ride-sharing capsule. In order for users to get live updates of when their ride will arrive, you can update the views with refresh.

  refresh {
if (this.countdown != 0) {
spec {
delay-seconds (5)
with-request {
intent {
goal: CheckRideShareStatus
value {
$expr (this)
}
}
}
}
}
}

View on GitHub

Note

Bixby will refresh if and only if the user is still on Bixby. Once they leave Bixby, the refresh will no longer happen.

Examples

You can find an example of using refresh in the reference page.

To further expand on the ride-sharing capsule, the refresh key is declared in a result-view file:

result-view {
match {
Activity (this) {
min (Required)
max (One)
from-output: CheckRideShareStatus (check)
}
}
message {
if (this.countdown != 0) {
template ("Your ride will arrive in #{value(this.countdown)} seconds.")
} else {
template ("I hope you are enjoying your ride")
}
}
refresh {
if (this.countdown != 0) {
spec {
delay-seconds (5)
with-request {
intent {
goal: CheckRideShareStatus
value {
$expr (this)
}
}
}
}
}
}
render {
layout-macro (activity-map-macro) {
param (activity) {
expression (this)
}
}
}
}

View on GitHub

The capsule uses a transactional workflow. This Activity.view.bxb file displays to users the details of the ride-share status. After showing the initial results, if the transaction has moved to the activity state, then the view will refresh. The delay handles how often the view is refreshed, which is checked using a conditional for the countdown property. The with-refresh has an intent to execute during each refresh interval. It calls the CheckRideShareStatus, which is of the RefreshActivity type.

action (CheckRideShareStatus) {

type (RefreshActivity)

collect {
input(activity){
type (Activity)
min (Optional)
default-init {
intent {
goal: Activity
value: Countdown(20)
}
}
}
}

output (Activity)
}

View on GitHub

Once the ride is over, which is checked with the condition by the existence of a receipt, the refresh will stop.

Note

Your goal does not need to be an action of type RefreshActivity to use refresh. For example, in the viv.flightStats capsule, the goal is the structure concept FlightStats. However, if you have a transactional capsule and you need to access information from the content provider, in order to get a refreshed state of the action, that action needs to be of the type RefreshActivity.

To learn more about how to use Activity Cards to update users during Refresh Activity, see Giving Updates with Activity Cards.