I'm currently creating a react app that needs to be able to launch any app on an Android device by specifying its package name. I tried using the react-open-app library to no avail, and I don't think i'd be able to use deep links considering I don't want to open a specific activity, but feel free to prove me wrong- Any help would be appreciated. Here is my code:
import OpenApp from "https://cdn.skypack.dev/react-open-app";
class CheckList extends React.Component {
constructor(props) {
super(props);
this.state = {
inputValue: '',
apps: [
],
};
}
addApp() {
if (this.state.inputValue!=='') {
this.setState({
apps: this.state.apps.concat(this.state.inputValue),
inputValue: ''
});
}
}
removeApp(app) {
this.setState({
apps: this.state.apps.filter((apps) => apps !== app)
});
}
updateInputValue(evt) {
this.setState({inputValue: evt.target.value});
}
render() {
const apps = this.state.apps;
const applaunch = apps.map((app) => {
return (
<li key={app}>
<button onClick={() => this.removeApp(app)}>-</button>
<OpenApp android={app}>{app}</OpenApp>
</li>
);
});
return (
<div classname="checklist">
<ul>
{applaunch}
<li>
<button onClick={() => this.addApp()}>+</button>
<input value={this.state.inputValue} onChange={evt => this.updateInputValue(evt)} placeholder="app link"/>
</li>
</ul>
</div>
);
}
}
ReactDOM.render(<CheckList />, document.getElementById("root"));
And the OpenApp tries to open whatever I feed into it as an url, which makes sense since it's meant to use deep links, but means I am, as of now, pretty clueless as to what I should do.
Any ideas for me?
Thanks!