Read Cal Newport's book Digital Minimalism. The only real long-term solution is to change your relationship with your phone.
It doesn't need to be within reach at all times. You probably barely need it at all, maybe 1% of the time. Just turn it off and leave it home unless you know you'll need it.
I confirm. All Cal Newport's writing (book+blog) really help to understand how our attention is hijacked, and concentrate and make time for what really matters.
As far as I'm concerned I suppressed all distracting apps on my smartphone, I quit social media, keeping only my LinkedIn account for my job, and I curate carefully my digital intake.