简体   繁体   English

是否有使用 React 开发三星电视(Tizen)应用程序的正确方法?

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

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.我需要为三星电视开发一个应用程序,我知道它可以用 Tizen Studio 开发,但我想使用 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当我构建 React 应用程序并在电视上启动它时它工作正常,但是我需要访问通过加载的三星产品 API

<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.我尝试下载所有 webapis.js 代码并将其加载到 React 应用程序中,但我得到'webapis' is not defined错误。

Is there are a proper way to load webapis.js file in React application, so I could access Samsung Product API methods?有没有在 React 应用程序中加载 webapis.js 文件的正确方法,所以我可以访问三星产品 API 方法?

Webapis are attached to the window object in your app. Webapis 附加到应用程序中的 window object。 You should not try to bring webapis.js to your app package.您不应该尝试将 webapis.js 带入您的应用 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.如果您在浏览器中开发,您可以编写自己的包装器 function 来处理缺少 try-catch 块的方法。

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.以上可以是您的应用程序正在使用的某种服务,并且您引用 function 来访问您需要的内容。

Also, make sure you have correct privileges that allow you to access these APIs.此外,请确保您具有允许您访问这些 API 的正确权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 React 应用程序获取 tizen tv 和 webos tv 信息 - Get tizen tv and webos tv info with react app Tizen Web 应用程序 - 嵌入<video>里面<iframe>可在模拟器中运行,但不能在实际电视上运行 - Tizen web app - Embedding <video> inside <iframe> works in emulator, but not on the actual TV 在React应用程序中更新此Redux存储状态的正确方法是什么 - What is the proper way of updating this Redux store state in React app 在使用“create-react-app”制作的反应应用程序中使用“react-leaflet”库的正确方法是什么? - What's the proper way to work with 'react-leaflet' library in a react app made with 'create-react-app'? 如何在 Tizen 中构建 create-react-app? - How do I build a create-react-app in Tizen? 如何通过在线开发来开发React应用 - How to develop react app via online development 是否可以在vps上开发一个create-react-app? - Is it possible to develop a create-react-app on a vps? 在React组件中使用botframework-webchat的正确方法(使用create-react-app)? - Proper way to use botframework-webchat in React component (using create-react-app)? 如何在 Apache Web 服务器上开发 React App - How to Develop React App on Apache Webserver 在React中调用道具的正确方法 - Proper way to Call Props in React
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM