NinetyHH
NinetyHH

Reputation: 1464

React-Native: Injecting javascript dynamically in webview on runtime

I am currently working on a project where I need to load the user in a webview, in the same time I'm injecting a javascript code to check if tokens expired. Everything works till here, I am getting a message back from the webview that we need to refresh but I cannot figure out how I can inject javascript on runtime in the webview. I am using at the moment this module: https://github.com/alinz/react-native-webview-bridge.

Is there a way how to make this flow working? So like this the tokens will not expire if the user is using the application.

Upvotes: 5

Views: 2086

Answers (1)

whitebrow
whitebrow

Reputation: 2005

Can't you just insert a new script element into the page's body?

Perhaps something like the answer to this question: Adding <script> element to the DOM and have the javascript run?

Upvotes: 1

Related Questions