External link sharing for Spotify application not working

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.

I hit this exact issue building my Spotify app last year. You’re dealing with a super common problem with the older Spotify Apps API. Your link format looks right, but there’s a timing bug that trips everyone up.

Wrap your event listener setup in a document ready function or setTimeout - the API needs to fully load before you register observers. Also, test this inside the actual Spotify desktop client, not a browser. The spotify: protocol handlers work differently across platforms.

Check your app manifest too. If you don’t have the right permissions for deep links in manifest.json, Spotify will recognize the link but won’t route it to your handlers properly. That taskbar blinking? Your app’s getting the event but can’t process it.