Utility Commands
Last updated
Last updated
You finally did it. You built that (almost) perfect calendar event detail page. It looks pretty, it shows all the information. You even got the time zone right! If only you could have that "Add to Calendar" button like everybody else.
Well, now your calendar event detail page can be perfect. This command allows you to specify all the details of a one-time event and add it to the user's default calendar.
The first time this command (or any other that accesses the calendar) is used it will prompt the user to allow access to their calendars.
StartDateTime
DateTime
The start date and time of the event. If you provide any time zone information here it will be ignored.
EndDateTime
DateTime
The end date and time of the event. If you leave this blank then the time information from the StartDateTime will be dropped and it will become an all day event.
Title
string
The title (or name) of the event. Space is often limited when displaying the title so remember to keep it short.
Notes
string
Additional notes about the event. Think of this as the details when opened information.
Location
string
The location of the event. This can technically be anything you like such as "Main Auditorium", but if you put in an actual address then devices will usually make it link to the maps application.
Url
string
A URL that the user can follow to get more information about the event.
TimeZoneId
string
The IANA time zone identifier that the StartDateTime and EndDateTime are in. For example, "America/Phoenix". Time zone reference sheet
AlarmInMinutes
int
If set then an alarm will be added to the event that triggers this many minutes before the event happens.
The following properties are required at a bare minimum:
StartDateTime
Title
TimeZoneId
This is a special-use command. It allows you to chain multiple commands together. A common usage of this would be to combine the SetContext
and ReplacePage
commands to change an Entity context and then reload the current page.
You specify the child commands to execute by using an instance of the AggregateCommandParameters
object.
Commands
ICollection<CommandReference>
The collection of commands that will be executed. This is the default property so you don't need to explicitly specify it.
Some blocks, currently just the Content
block, support what is called Callbacks. You can learn more about these in the Advanced: Dynamic Content and the Developer chapters. But, for our purposes here, you can think of these as an API call back to the server's logic for the block.
If the CommandParameter
is a plain string, then it is used as the name of the callback function to be queried on the server. If you need to pass any parameters to that function then CommandParameter
should point to an instance of the CallbackParameters
object.
Name
string
The name of the callback to be called on the server. (Required Field)
Validator
Optional reference to a validator that will be executed before sending the command to the block. If the validator fails then the command is not sent.
Examples
This command sets text to the user's clipboard through the CommandParameter. It enhances the person experience by simplifying copy-and-paste actions.
The CommandParameter
accepts a string representing the text to be copied to the person clipboard.
This command can be used to download a pass directly to Apple Wallet (with user permission), providing a nicer experience when adding a pass without having to go through a browser intermediary.
Consider hiding this functionality on Android since it is mainly intended for iOS. On Android, this command will simply open an external browser with the URL matching the command parameter.
To show/hide content based on the device platform, check out the OnPlatform extension.
Normally, notifications are enabled by the application automatically on launch or during the onboarding process of a new user. But sometimes you might want to display a custom page that talks about why you are going to be sending them push notifications to encourage a better response. This command allows you to initiate the request to enable push notifications.
You might want to check out the Push Notification State section for an example of how to integrate this command with UI that updates automatically based on notifications being enabled or disabled.
The optional CommandParameter
is an instance of the EnablePushNotificationsParameters
object that is outlined below.
EnabledMessage
string
The message that will be displayed if notifications have been enabled by the individual. Set to an empty string to not show this message.
Defaults to You're all set to receive push notifications.
DisabledMessage
string
The message that will be displayed if notifications have been disabled by the individual. Set to an empty string to not show this message.
Defaults to Looks like you didn't allow push notifications. If you need to turn them on you can do that in your Settings app.
Be aware that Android does not ever show a popup message. Instead, it will just automatically enable notifications and then show your EnabledMessage
.
This command will allow you to logout the current person from the application. It will then redirect to the homepage.
A string that contains either the value "True" to indicate that the current page should be reloaded, or the Guid of the page to show instead of the home page.
An instance of the LogoutParameters
object that is outlined below.
ReloadPage
bool
If true then the current page is reloaded instead of navigating away. Defaults to false.
PageGuid
Guid?
The page to navigate to instead of the home page. Defaults to null.
Parameters
List<Parameter>
Optional parameters to pass to the page in the query string. Defaults to empty.
Prayer is a big thing for churches, at least it should be. To that end, we wanted to make prayer in your mobile applications as easy as possible. Rather than being limited to specific blocks that support prayer, we decided to give you a command that is available in any block. Using this command you can easily add "Pray" buttons to any page and any content block.
The CommandParameter
can either be a plain string that represents the unique identifier (Guid) of the prayer request, or it can be an instance of the PrayForRequestParameters
object.
Guid
Guid
The unique identifier of the prayer request to be prayed for.
RecordInteraction
bool
By default, all pray actions will record an Interaction record in Rock. You can override that by setting this to false. Defaults to true.
WorkflowTypeGuid
Guid?
The pray action can launch a workflow to let you do custom processing on the server for that pray action. Provide a Workflow Type unique identifer here to indicate which workflow should be launched. Defaults to null.
Examples
The first example is a simple Pray button. No special processing happens, it just increments the prayer count for the request.
This second example makes use of the PrayForRequestParameters
object to disable the interaction and also provide a workflow to be launched.
You learned, or will learn, elsewhere that you can use Lava on the mobile shell to handle certain page events and respond to them. Normally these page events are just ones generated by the system for you. However, you can trigger your own custom page events using this command.
The CommandParameter
can either be a plain string that indicates the event name to be triggered, or it can be an instance of the PageEventParameters
object. This latter method allows you to pass parameters into your lava logic.
Event
string
The name of the event to be triggered.
Parameters
List<Parameter>
Any parameters that will be passed to the Lava engine, these manifest as lava variables.
Examples
This is to perform Haptic Feedback on a user's device. If you are unfamiliar with what haptic feedback is, here is a good reference.
The CommandParameter
is a string, but can be left out unless you specifically want to implement the "LongPress" type. Everything else will default to the "Click" type.
HapticFeedbackType
string
The type of haptic feedback you want to implement. Only two accepted values are "Click" or "LongPress".
Examples
This instructs the application to reload as if you had just forced quit and started it again. This is a development tool that saves a few seconds when debugging stuff. It's not a command you'll want to use in a public app.
The CommandParameter
is not used and will be ignored.
This instructs the application to reload the currently displayed page.
The CommandParameter
is not used and will be ignored.
There are two ways to initiate this command, we'll show them below. But the basic syntax is you specify the Anchor element that should be scrolled until it becomes visible. Think of this like the HTML Anchor href, or a "jump to" button.
You can either pass the view to be made visible directly by reference in the CommandParameter
or you can pass an instance of the ScrollToVisibleParameters
object.
Anchor
VisualElement
The view which resides inside a ScrollView that should be made visible.
Position
ScrollToPosition
The position to put the view at after scrolling (see below). Defaults to MakeVisible
Boolean
Sets whether the scroll should be animated.
Defaults to True
The options you have with the Position
parameter are as follows:
MakeVisible
- Just make sure the anchor is visible on screen
Start
- Attempt to scroll until the anchor is at the start (top or left) of the screen
Center
- Attempt to scroll until the anchor is at the center of the screen
End
- Attempt to scroll until the anchor is at the end (bottom or right) of the screen
Examples
The above will scroll the first ScrollView in the view tree above the Label we specified as our anchor so that the label is visible. This by itself may be just fine for what you need, but it may not end up doing what you want. By default, the anchor will be scrolled until it becomes "just visible". In this case, since we need to scroll down, the label will end up at the bottom of the screen.
To accommodate those situations, you can specify a parameters object like so.
This still indicates the same Label we want to use as the Anchor, but it also specifies the position we want it to end up at. Now, this is not a forced position. If there were nothing below the label, it wouldn't be possible for it to end up at the top. But since we have a lot of content below as well, there is enough room to scroll.
Finally, due to the way XAML works, there is a shorthand to the XAML above.
The mobile shell has a concept of AppValues. These are values that survive for the life of the application and allow you to save and read the values later. But what good are app values if you can't set them? The syntax of this command is pretty straightforward. You either provide a parameter value of just a key name; or a key name followed by an equals sign followed by a value.
To utilize an app value, you have access to an AppValues
dictionary in Lava:
This command allows you to set an entity context value based on a user's action. For example, you could build a custom Campus Context Picker and set the context when the user taps an action button.
The parameter should be an instance of the SetContextParameters
class, which is described below.
Name
string
The name of the entity whose context is to be set. For example Campus
.
Value
Guid?
The Guid value to set the context name to. If this is left blank then the context is unset. Defaults to null.
Save user-specific properties that we only store on the shell. Be careful not to go overboard with these, as they directly affect your application size. In reality, this is just a SetAppValue command that prefixes the key with user-preference-
.
There may be times you want to modify the appearance of something or hide it completely, in response to a user action. This command will let you change a property value on a view in your XAML. Here are a few quick examples:
Change the StyleClass values applied to a view
Show or hide a view by changing IsVisible
Disable another button
You might be tempted to try disabling the button that the command is attached to. This will most likely not work. When the command finishes executing the button will be automatically re-enabled. In these cases, you might need to hide the button and show a different, already disabled, button instead.
The CommandParameter
must specify an instance of the SetViewPropertyParameters
object.
View
View
The view that will have it's property value changed.
Name
string
The name of the property to change.
Value
object
The value to set. This will almost always be given as a string, but it will be automatically converted just as if you typed the same value into a normal XAML property.
You may notice above that there are two ways to set a property value. If you are only setting a single value you will probably find the Name
and Value
properties easier to deal with. But you can also set multiple properties at one time by using the Values
collection instead. You cannot set properties on multiple views; for that, you would need to use multiple SetViewProperty commands.
Examples
This first example demonstrates a simple action. When the button is tapped then the style class will change from success to danger.
Our next example will show a more advanced version that changes two properties. We are going to do the same transition to a danger button, but also change the text displayed in the button. The first example showed the concise form, but it's a bit harder to read because of how long that string is. The second example will also show the more verbose form, which is a bit easier to read.
Our final example shows how to modify two views in response to a single action using the AggregateCommand. In this case, we want to disable the button after it is tapped. But since we can't directly modify the IsEnabled property (since it gets re-enabled after the command finishes) we have to swap it out with a different button. Instead, we first make "myButton3" visible and then make "myButton4" invisible.
This action will show an action panel (think action sheet in iOS terms). This is basically a popup that contains a short message and a number of buttons the user can choose from. A common example of this would be a "reply" button in a mail application. When tapping the button it might then pop up an action sheet that contains a few buttons to help you decide what you intend to do: Reply, Reply All, Forward.
These popups usually have a Cancel button (though it's not strictly required). Additionally, you can specify a single "destructive" button that stands out to the user. Often, this would be a Delete type action and is usually styled red.
The CommandParameter
must specify an instance of the ShowActionPanelParameters
object.
Title
string
The title of the action panel; keep it short!
CancelTitle
string
The text to display in the cancel button (optional). Defaults to empty string.
DestructiveButton
ActionPanelButton
Defines the button that implies a destructive operation, for example on iOS this button becomes red (optional).
Defaults to null.
Buttons
ICollection<ActionPanelButton>
A collection of buttons to be shown, this is the default content property meaning you would just add ActionPanelButton nodes as child elements.
Examples
Thanks to the magic of XAML, we can simplify the definition of the destructive button a bit if we want, it's up to you.
Allows you to write an Interaction to Rock when the command is executed. For example, you could write an interaction in response to the user tapping a button. By default, only a single Interaction will be written no matter how many times the command is executed. Normally this is probably what you want. If for some reason you want to allow multiple Interactions to be generated, set the IsMultipleAllowed
property to true.
This command takes a parameter object of type InteractionParameters
that contains the following details.
In order for your parameters to be considered valid, you must provide at least one of ChannelId
or ChannelGuid
; and you must provide at least one of ComponentId
or ComponentName
. Also, note that some event sources will provide defaults for some of the properties in the table below or may even override a value you provide.
ChannelId
int?
The identifier of the channel where this interaction will be recorded. Must already exist. Defaults to null.
ChannelGuid
Guid?
The unique identifier of the channel where this interaction will be recorded. Must already exist. Defaults to null.
ComponentId
int?
Specifies a specific component identifier where this interaction will be recorded. If used, the component must already exist. Defaults to null.
ComponentName
string
Specifies a component name for where this interaction will be recorded. If you use this property to pick the component then the system will look for a matching component and if not found create one. Defaults to null.
ComponentEntityId
int?
If the channel is configured to have an Entity associated with the components then this would provide the Id of the Entity if it gets created from the ComponentName property. Defaults to null.
Data
string
Custom data that should be stored with the interaction. There is no specific format requirements, as long as the data is a string. Defaults to null.
EntityId
int?
Associates the interaction with the specified entity. The entity type will be taken from the channel configuration. Defaults to null.
Operation
string
The type of operation that identifies this interaction. There is no specific list of strings that you must use, but a few suggestions are View
and Watch
. Defaults to null.
Summary
string
The text that describes this event in a user friendly manner. Defaults to null.
RelatedEntityTypeId
int?
Sets the EntityTypeId of the related entity that should be associated with this Interaction. Defaults to null.
RelatedEntityId
int?
Sets the EntityId of the related entity that should be associated with this Interaction. Defaults to null.
ChannelCustom1
string
Sets the first custom interaction string value. Defaults to null.
ChannelCustom2
string
Sets the second interaction string value. Defaults to null.
ChannelCustomIndexed1
string
Sets the first custom indexed interaction string value. Defaults to null.
IsMultipleAllowed
bool
Specifies if multiple interactions can be written for this single command. If set to true then each time the command is executed a new interaction will be written. Otherwise only the first execution will write an interaction. Note: If the page is reloaded then a new parameter object is created and a new interaction could again be written. Defaults to false.
SendMode
InteractionSendMode
Currently accepts two values:
Queued
: Adds the interaction to the internal queue, that posts to the server every so often. This is recommended and is used to maintain high performance.
Immediate
: In some rare cases, you may want to make sure an interaction gets posted to the server as soon as possible. This will cause the interaction to bypass the internal queue and post immediately upon execution. Be cautious using this, as you could flood your server with POST requests.
Defaults to Queued.
Rock Mobile Shell supports the idea of small popup pages. These don't support navigation but can be useful for a simple display of additional content without leaving the current page.
If the CommandParameter
is a string then it will be interpreted as a page GUID with optional query string parameters. This will display a full Rock page inside the popup view.
Alternatively, you can specify a view to use as the content for the popup. This is ideal for showing additional details of items or perhaps a list filter.
Finally, you can specify a ShowPopupParameters
object and supply additional options as seen below.
Anchor
ShowPopupAnchor
Where to anchor the popup, possible values are Center
, Top
, and Bottom
.
Defaults to Center.
Content
View
The view to display inside the popup, if set this will override the PageGuid property.
PageGuid
Guid
The Rock page to be displayed inside the popup.
Parameters
List<Parameter>
A collection of query string parameters that will be passed to the Rock page.
Title
string
The title of the popup.
ShowHeader
bool
Determines if the header should be shown. If disabled then you have complete control of the design. Defaults to True.
Examples
This command is the opposite of the ShowPopup command. If there is an open popup then it will be closed. This command takes no parameters.
The command is used to follow and unfollow specific entities.
Previously, this behavior was only utilized using the Following Icon, but now with this command, you can easily mimic that to create custom follow/unfollow buttons.
When following a person you'll want to use the PersonAlias entity type, not the Person.
Note that this command does not refresh the page. If you have following icons and expect them to be updated from this command, it does not work as such. Consider using SetViewProperty to make visual changes in response to follow and unfollow actions.
EntityId
int
The Id of the entity to follow or unfollow.
EntityTypeId
int
The Id of the entity type to follow or unfollow.
PurposeKey
string
An optional parameter that allows you to set a 'Purpose Key' while following or unfollowing.
NotificationText
string
The text to display on the Toast when an item is successfully followed/unfollowed. Note: Setting this as empty ("") will remove the Toast from ever being displayed, if you wish to do that.
IsFollow
bool
Whether or not the command is used to follow or unfollow, set to false to configure "unfollowing" behavior. Defaults to true.
UseHapticFeedback
bool
If enabled, the command will perform haptic feedback when tapped. Defaults to true.
This command displays a "Toast" style message, often used to show quick and temporary messages, such as "saved" or "updated" and things of the sort.
If the CommandParameter
is a string, it will display using the default styles with the command parameter as the message to display.
Text
string
The text to display in the Toast.
Duration
ToastDuration
Either long (3.5 seconds) or short (2.0 seconds).
FontSize
int
The font size of the toast.
Shows a Cover Sheet.
Closes any open Cover Sheet.
This command is used to update the profile photo of either the CurrentPerson
, or if a PersonGuid
is supplied as the parameter, it will update theirs. Options are shown with the ShowActionPanel command, including uploading an existing photo or capturing a new one.
This command requires Edit permissions on the following API endpoint: POST api/People/UpdatePersonProfilePhoto?personGuid={personGuid}&filename={filename}
There are some additional command parameters that can be used for extended functionality. These are UpdatePersonProfilePhotoCommandParameters
.
PersonGuid
Guid
The Guid of the Person to update the profile photo for.
Image
Image
The image to update the source of when the new profile image is uploaded.
Here's an example for using the Image property:
This command is pretty complex. It does two things... First it generates an Entity Set based on the provided parameters and then performs a Navigation command with an appended query string of the entity set value.
TimeToExpire
int
The amount of time (in minutes) before the entity set expires.
QueryStringParameterKey
string
The key associated with the newly generated Entity Set that will be passed along through the query string. Defaults to EntitySetGuid
.
EntityTypeGuid
Guid
The Guid of the type of entity this entity set is in relation to.
EntityItemGuids
List<string>
A list of the string Guid entity set items. You should only include entities that are of the same type provided by the EntityTypeGuid.
NavigateCommand
CommandReference
The navigation command to execute with the new entity set query string parameter.
The CommandParameter
can be one of the following items:
Animated
Also, be sure to check out the needed to enable following.