I’m trying to create sharable links for my Spotify app that work on social media platforms like Facebook and Twitter. The links point to specific content within my app.
My current link format is spotify:app:myapp:section:42 and I’m using basic HTML anchor tags:
<a href="spotify:app:myapp:section:42">click here</a>
I’ve set up event listeners to catch when links are clicked:
api = getSpotifyApi(1);
appModels = api.require('sp://import/scripts/api/models');
appModels.application.observe(appModels.EVENT.ARGUMENTSCHANGED, function () {
console.log(['ARGS_CHANGED', appModels.application.arguments]);
});
appModels.application.observe(appModels.EVENT.LINKSCHANGED, function () {
console.log(['LINKS_CHANGED', appModels.application.arguments]);
});
appModels.application.observe(appModels.EVENT.ACTIVATE, function () {
console.log(['APP_ACTIVATE', appModels.application.arguments]);
});
appModels.application.observe(appModels.EVENT.DEACTIVATE, function () {
console.log(['APP_DEACTIVATE', appModels.application.arguments]);
});
appModels.application.observe(appModels.EVENT.CHANGE, function () {
console.log(['APP_CHANGE', appModels.application.arguments]);
});
The issue is that none of these events fire when I click the links. I can tell Spotify recognizes the link because the app icon blinks in the taskbar, but my event handlers never execute. Even when I paste the full URL into Spotify’s search bar, nothing happens. The only events that work are the activate and deactivate ones when I manually switch between apps.