[英]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.