I had the same exact issue and as the others have done, I've used superglue, being very careful not to put any glue on the spring.
Mine was made more difficult by the fact that the body of the pen was stuck inside and I had to put the glue on the spring top and carefully align it back inside the s pen silo. Thankfully it worked!
So far it's been a week and no detachments, however I can already see that there is a small gap increasing once more between the top and the body. Will have to glue it again more securely before the body gets stuck inside.