Is there are proper way to develop Samsung TV (Tizen) app with React?

1.8k views Asked by At

I need to develop an application for Samsung TV and I know it can be developed with Tizen Studio but I would like to use React. When I build React application and launch it on TV it works fine, however I need to access Samsung Product APIs that is loaded via

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

I tried downloading all webapis.js code and load it in React application but I get 'webapis' is not defined error.

Is there are a proper way to load webapis.js file in React application, so I could access Samsung Product API methods?

1

There are 1 answers

0
Constantine Krotcov On BEST ANSWER

Webapis are attached to the window object in your app. You should not try to bring webapis.js to your app package. It's would be available to you once running on TV.

If you are developing in the browser you can write your own wrapper function that handles the lack of that method with a try-catch block.

let = getTVFW() => {
    let value;
    try {
        value = window.webapis.productinfo.getFirmware();
        console.log(" Firmware value = " + value);
    } catch (error) {
        console.log(" error code = " + error.code);
        value = 'testvaluefordev';
    }
    return value;
}

The above can be a service of some sort that your app is using and you reference that function to access what you need.

Also, make sure you have correct privileges that allow you to access these APIs.