Accessing B2B APIs and Web APIs in React for Tizen Applications

361 Views Asked by At

I'm trying to create a React App that runs on a Tizen OS-based device. And I need to use the B2B APIs and Web APIs for Printing and getting device information.

All the guides provided have used Web App mode in Tizen Studio but no mention of how to use the libraries in React.

index.html

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

config.xml:

<tizen:privilege name="http://developer.samsung.com/privilege/serialport"/>
<tizen:privilege name="http://developer.samsung.com/privilege/productinfo"/>

Guides have mentioned adding the above in the index.html and config.xml files. But I don't think we can use the library in the React app with the above approach.

How do I get access to these two API Javascript Libraries for React?

1

There are 1 best solutions below

1
15kokos On

Tizen web applications require specific structure including config.xml file including privileges and other settings. I think you need to create Tizen wrapper application around your React application to make it work on Tizen.

I'm not familiar with React, but if you have already React application, I would do it this way:

  1. Create empty Tizen web application
  2. Put sources of your React application into Tizen app template.
    • Modify config.xml file entrypoint to use index.html of your React application
    • Use some js-based redirect, e.g. as suggested in this answer
  3. Build, install and run application using Tizen Studio.

I think that application should be runnable on Tizen at this point.

Then you should be able to easily apply config.xml and index.html you've mentioned in question and use Tizen APIs in your application.