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. Refreshes are especially useful when updating a user on the current status of an Activity, such as the location of a user's last order. However, you do not need to have an Activity to use a refresh.

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 in your view file:

  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 another example of using refresh in the reference page. You can also check out the Refresh Sample Capsule.

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

result-view {
match {
Activity (this)

}
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

This Activity.view.bxb file displays to users the details of the ride-share status. The delay-seconds key handles how often the view is refreshed, which is checked using a conditional for the countdown property. The with-request key has an intent to execute during each refresh interval. It calls the CheckRideShareStatus:

action (CheckRideShareStatus) {
type (Calculation)

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

output (Activity)
}

View on GitHub

Once the ride is over (in this case, when the countdown reaches zero), the refresh will stop.

Note

If you have a transactional capsule and you need to access information from a 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.