Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

During Development Tizen object isn't available on Tv #1719

Open
youssefali424 opened this issue Sep 22, 2024 · 5 comments
Open

During Development Tizen object isn't available on Tv #1719

youssefali424 opened this issue Sep 22, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@youssefali424
Copy link

Describe the bug
The tizen object was always undefined during development, After researching why this happens it appear that the tizen object is only provided to index.html in the tizen project, during development public/index.html is used to allow refreshing when files are updated, but this leads to tizen object being undefined in public/index.html and only available in index.html

To Reproduce
Steps to reproduce the behavior:

  1. Create a tizen using latest version (prerelease or latest)
  2. Add the use of tizen object through javascript
  3. run npx rnv run -p tizen
  4. tizen object isn't defined

Expected behavior
Through development we can access tizen object

Desktop (please complete the following information):

  • OS: windows 11 pro
  • Node Version 10.8.0
  • RNV Version 1.3.0.rc-0
@youssefali424 youssefali424 added the bug Something isn't working label Sep 22, 2024
@Marius456 Marius456 added this to the 1.4 milestone Sep 23, 2024
@pauliusguzas
Copy link
Collaborator

@youssefali424 thanks for reporting, this is planned to be looked at in the next 2 weeks

@Marius456 Marius456 self-assigned this Oct 1, 2024
@Marius456
Copy link
Contributor

Hello @youssefali424,
After looking around I found that tizen API is not accessible in hosted app mode due to tizen security policies.
If you want to use the tizen API, you can rnv build package version of the app and install it directly on the tv.
If you need any help, feel free to reach out.

@youssefali424
Copy link
Author

@Marius456 yes that is the issue here, i was trying to figure a way to use a single html file in development using iframe instead of redirecting to new html, as Tizen API is only available in index.html for security reasons
If you have any hints in this part it will be appreciated

@Marius456 Marius456 modified the milestones: 1.4, 1.5 Oct 7, 2024
@Marius456
Copy link
Contributor

Hello @youssefali424,
Like you said you can use iframe to pass tizen object data in index.html:

<html>
    <head>
        <!-- <meta http-equiv="refresh" content="0;url={{DEV_SERVER}}" /> -->
    </head>
    <body>
            <iframe
                id="frameTizen"
                src="{{DEV_SERVER}}?somedata=tizenMemory"
            ></iframe>
            <script>
                var zxc = document.getElementById('frameTizen');
                zxc.src = '{{DEV_SERVER}}?somedata=' + tizen.systeminfo.getTotalMemory();
            </script>
    </body>
</html>

And use it src/app/index.tsx:

    const [tizenMemory, setTizenMemoryState] = useState('');
const params = location.href.split('?')[1].split('&');
        const data = {};
        let tizenTotalMemory = '';
        for (const x in params) {
            data[params[x].split('=')[0]] = params[x].split('=')[1];
            tizenTotalMemory = params[x].split('=')[0];
        }
        setTizenMemoryState(data[tizenTotalMemory]);

@youssefali424
Copy link
Author

I do understand that, but this will affect production code, i mean you cant do that with the production code as it wont be in iframe
The ideal way is to provide tizen object to the iframe currently this is blocked by cors
I am trying to find a way as this should be safe as long it is used only during development, so that there is no difference between development and production

@Marius456 Marius456 removed this from the 1.5 milestone Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants