We want to navigate to player screen on notification click. Is there any solution?
I've added the URI trackplayer://notification.click, it will be triggered when the notification is clicked. Read about how to handle it in linking.
There are two conditions you should know:
// This event will be fired
Linking.addEventListener('url', (data) => console.log(data.url));
// You have to retrieve the URL manually
Linking.getInitialURL().then(url => console.log(url));
Here's an example that handles both conditions:
class App extends Component {
componentDidMount() {
Linking.getInitialURL().then((url) => this.handleUrl({url: url}));
Linking.addEventListener('url', this.handleUrl);
}
componentWillUnmount() {
Linking.removeEventListener('url', this.handleUrl);
}
handleUrl = (data) => {
if (data.url === 'trackplayer://notification.click') {
// Do something
}
};
}
Is it just for android? It doesn't work in IOS ..
yeah, looking at the sources it seems this is only implemented for Android.
Most helpful comment
I've added the URI
trackplayer://notification.click, it will be triggered when the notification is clicked. Read about how to handle it in linking.