The Cloud module exposes APIs that are needed when developing an app for Roku.
The Cloud module has two parts: Cloud
and CloudConfig
.
Cloud
can be included in all You.i Platform apps.
When Cloud
is included in a build for non-Roku target platforms (such as Android or tvOS), isCloudServer
returns false.CloudConfig
should be included only when the YI_CLOUD_SERVER
flag is set, as shown below.In your app.cpp
file, ensure that the ReactNativeViewController
code is as shown below:
#include <YiCloudModule.h>
#if (YI_CLOUD_SERVER)
#include <YiCloudConfigModule.h>
#endif
...
//Initialize PlatformApp::UserInit()
//Adding the module must be done after UserInit()
bool userInitSuccess = PlatformApp::UserInit();
//Add the module
GetReactNativeViewController().AddModule<Cloud>();
#if YI_CLOUD_SERVER
//For Roku Cloud
GetReactNativeViewController().AddModule<CloudConfig>();
#endif
//Perform rest of App::UserInit()
...
//Return value from earlier PlatformApp::UserInit()
return userInitSuccess;
Call the Cloud Module using the Cloud
keyword:
Cloud.setDefaultCloudKeyboardTitle("My default title");
To execute certain code blocks or function calls for the Roku target platform, use the isCloudServer
boolean.
For example:
if (Cloud.isCloudServer)
{
FocusManager.enableFocus(this.list);
FocusManager.setNextFocus(this.list, this.list, "right");
}
NativeEventEmitter.Cloud
starts a clientBackgrounded
event whenever the Roku client starts playback or is inactivated.
Import NativeEventEmitter
as follows:
import {NativeEventEmitter, NativeModules} from 'react-native';
const cloudEventEmitter = new NativeEventEmitter(NativeModules.Cloud);
Boolean that is true if the implementation is a cloud server. Allows a multi-platform app to make a runtime check to execute cloud-specific behavior.
Boolean that is true if the device has lower capabilities.
Due to the wide range of supported Roku hardware, You.i TV recommends that you follow Roku guidance; that is, design for high-end devices and then gracefully degrade the experience for low-end hardware. This can include removing more complex assets from scenes, using smaller image sources, and so on.
String with the external IPv4 address of the Roku client. For details, see Geo Location and Restriction.
Terminates the app and returns to the home screen. For details, see App Exit with Back Button.
Shows the wait spinner immediately without the configured delay of 2 seconds. For details, see Customizing the Wait Screen and Activity Indicator.
Sets the time of spinner delay in milliseconds.
delayMs
is the spinner delay duration in milliseconds.
If hideWaitSpinner()
is called within the duration, the spinner won’t show.
The default value for the spinner delay is 2000 ms.
For details, see Customizing the Wait Screen and Activity Indicator.
Shows the wait spinner with the configured delay (2 secs). The wait spinner can be used in one of following scenarios:
For details, see Customizing the Wait Screen and Activity Indicator.
Makes the wait spinner accessible, so that the Audio Guide automatically makes an announcement when the activity indicator is displayed. For details, see Customizing the Wait Screen and Activity Indicator.
Hides the wait spinner. For details, see Customizing the Wait Screen and Activity Indicator.
Announces the specified text on the client. Note that the Audio Guide must be enabled on the Roku device.
To learn more about creating accessible Roku apps, see Roku Accessibility.
Example: Cloud.announceText("Some text");
Sets the default title of the Roku keyboard, as specified by title
.
Example: Cloud.setDefaultCloudKeyboardTitle("My default title");
Sets the title of the Roku keyboard for a particular view.
Example: Cloud.setCloudKeyboardTitle(findNodeHandle(this.textview2), "Element Title 2!");
Pauses the automatic scene tree export process. Until resumed, changes to the scene tree do not result in automated exports. For details, see Roku Development.
Resumes the automatic scene tree export process. Changes to the scene tree again result in automated exports. For details, see Roku Development](/6.15/rn/plan/roku-considerations/).
Returns true if the automatic scene export process is paused. For details, see Roku Development.
This has been deprecated.
Use exportSubtree()
as a substitute.
Triggers the export of the given subtree to the client. A common use of this method is to update the content data of a list. For details, see Roku Development.
Example: exportSubtree(findNodeHandle(this.listRef), true)
Updates the client’s focus map because focus relationships between scene components have changed. For details, see Focus Map.
Sets the start of a list to be at the specified index, instead of starting from the first list item. For example, if a list has 20 list items and you specify an index of 7, the list starts from list item 7 instead of the first list item. For details, see Roku List Development.
Note React Native apps on Roku Cloud no longer require the Cloud module’s setInitialScrollIndex
method for lists, and it has been deprecated as of You.i Platform version 6.0.
In anticipation of the removal of setInitialScrollIndex
in a future release, we recommend using initialScrollIndex
as you would have on other RN apps, as it now works the same on all RN-supported platforms.
For implementation details, refer to the 6.0 Migration Guide.
This API does the following:
Call this API with the onload()
method, otherwise app behavior may be incorrect.
For details, see Roku List Development.
Request the Roku user account (partial user data of email address). This is an asynchronous network operation. The appropriate callback function is invoked when complete. For details, see In-app Purchases.
Request the Roku ChannelCred
event.
Includes the Roku Partner Unique Customer Identifier and the channel credentials.
This is an asynchronous network operation.
The appropriate callback function is invoked when complete.
For details, see In-app Purchases.
Store the Roku ChannelCred
event.
Includes the Roku client in-app purchase channel credentials.
This is an asynchronous network operation.
The appropriate callback function is invoked when complete.
For details, see In-app Purchases.
In-app purchase request of available products for the channel.
getAvailableProducts
returned data includes information such as product name, product description, product poster URL, free trial type, free trial quantity, purchase date, product type and quantity.
This is an asynchronous network operation.
The appropriate callback function is invoked when complete.
For details, see In-app Purchases.
In-app purchase request of user purchases. This is an asynchronous network operation. The appropriate callback function is invoked when complete. For details, see In-app Purchases.
In-app purchase request to purchase a given product. This is an asynchronous network operation. The appropriate callback function is invoked when complete. For details, see In-app Purchases.
Queues an action to be executed after the next scene export.
This function is deprecated and may be removed in a future release.
Use SendPlatformAnalyticsEvent
instead.
Sends an app beacon of the provided name to the Roku client.
Roku requires all applications to send certain analytics events. These mandatory analytics aren’t related to any application-side business logic. These events must have one of the following types:
Roku does not dictate the name of these events or when they must be sent; this is completely up to the application developer.
CYICloud::GetInterface().SendPlatformAnalyticsEvent(CYICloudInterface::PlatformAnalyticsType::Application, "AppLaunchComplete");
CYICloud::GetInterface().SendPlatformAnalyticsEvent(CYICloudInterface::PlatformAnalyticsType::Authentication, "Roku_Authenticated");
Gets the recently updated playback session information, such as bookmark and audio/cc settings.
Invokes the custom BrightScript command.
The first parameter is a BrightScript command name as a string. The second parameter is an object used by the app to send key-value pairs of arguments. Note that the arguments must be JSON serializable and must only contain one of the following types: string, bool, or array/object containing string and bool. The third parameter is a callback that is called with the result of the custom command.
Allows you to specify which list item will have focus when a user enters a list. The usage examples provided are for ListRef, but usage is similar for List. Possible values:
Description: Move focus to the closest list item. The closest item is computed locally on the client to keep request latency low.
Usage: Cloud.setIncomingFocusStyle(findNodeHandle(this.listRef), "closest")
Description: Move focus to the item that was selected the last time this list had focus. The list item is computed locally on the client to keep request latency low.
Usage: Cloud.setIncomingFocusStyle(findNodeHandle(this.listRef), "previousItem"
)
Description: The You.i Roku Cloud server computes where focus should go inside of the list. This setting gives you focus behavior that exactly matches other platforms, but it results in higher network request latency.
Usage: Cloud.setIncomingFocusStyle(findNodeHandle(this.listRef), "server")
Allows you to specify where focus moves when a user exits a list. The usage examples provided are for ListRef, but usage is similar for List. Possible values:
Description: Move focus to the node closest to the list item, based on the size of the list item. The node is computed locally on the client to keep request latency low.
Usage: Cloud.setOutgoingFocusStyle(findNodeHandle(this.listRef), "closest")
As shown here, closest
moves focus to the node that’s closest to the list item:
Description: Move focus to the node closest to the list, based on the size of the whole list.
The node is computed locally on the client to keep request latency low.
This setting is equivalent to the After Effects composition hint outgoingFocusStyle:focusMap
.
Usage: Cloud.setOutgoingFocusStyle(findNodeHandle(this.listRef), "closestToList")
As shown here, closestToList
moves focus to the node that’s closest to the center of the list:
Description: The You.i Roku Cloud server computes where focus should go when leaving the list. This setting gives you focus behavior that exactly matches other platforms, but it results in higher network request latency.
Usage: Cloud.setOutgoingFocusStyle(findNodeHandle(this.listRef), "server")