This topic describes how to implement a personal preview for the Smart Hub Preview feature. A personal preview shows preview content personalized for the user.
Personal preview content is defined by a JSON file managed by a background service application running on the TV.
To implement a personal preview, you need to develop a foreground application and a background service application. The foreground application performs the main application tasks, such as showing content, while the background application serves information to show in the preview. Personalized preview content is implemented by sharing data between the foreground and background applications. For example, the foreground application can share user-entered information with the background service, which queries for personalized recommendations.
The personal preview generation process is shown in the following figure.
Launching the foreground application also launches the background service application.
The JSON data is set by the background service application.
The preview is generated and shown based on the JSON data.
The user clicks a preview tile.
The tile’s corresponding JSON action_data value is sent to the application.
The foreground application parses the action_data value and shows the detail page.
Prerequisites
To enable your application to use the personal preview functionality, you must modify the foreground application's "config.xml" file:
Define the JSON source as a background application:
To add the service application to the foreground application, add the following code inside the <widget> element.
The id attribute of the <tizen:service> element is in the format [application ID].[service name] auto-restart="false", and the src attribute of the <tizen:content> element is the path to the service application code.
ImportantBasically, service application is automatically launched by system every 10 mins regular basis. If foreground application launches service application, system will not launch service application.
Configuring Personal Preview Data
The structure and parameters of the preview content JSON file are the same as for public preview, except that the expires and expires_only properties are not supported.
You can provide the JSON data as a variable, a local file, or a file at a remote URL. If you want to retrieve JSON data using HTTP requests, you must implement them using NodeJS.
The following example provides the JSON data as a variable:
In the onRequest() callback, implement the background application logic, such as HTTP networking, generating preview data, and communication with the foreground application:
Use the setPreviewData() method of the Preview API to set the JSON data for the preview.
Use the Messageport API to share data between the foreground application and the background service application.
module.exports.onRequest = function() {
console.log("Request Callback");
var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl();
if (reqAppControl && reqAppControl.appControl.operation == "http://tizen.org/appcontrol/operation/pick") {
var data = reqAppControl.appControl.data;
if (data[0].value[0] == 'ForegroundApp') {
webapis.preview.setPreviewData(
JSON.stringify(previewData),
function() {
// Terminate service after setting preview data
tizen.application.getCurrentApplication().exit();
},
function(e) {
console.log('setPreviewData failed : ' + e.message);
}
);
}
}
}
Note :
In the success callback for the setPreviewData() method, you must terminate the background service application using the getCurrentApplication().exit() method.
The Samsung Apps TV policy defines that, if the background service application is not terminated in this way, it is automatically terminated after 5 minutes. In addition, next setPreviewData() method should be called at least 10mins later.
Define the onExit() callback.
This callback is invoked when the background service application is terminated.
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.