What is the best way to ask a user for permissions?

When I go on websites like a blog, they almost all do the terrible mistake of showing me this immediately when I enter the site:

"Example.com wants to: Show notifications (Allow) (Block)"

And I think we can all agree that this method only gets blocked, which is terrible for user experience because now you will need to tell the user how to give the site the permission on each browser.

One good approach I came across was the site fading in a custom box on the top, only if you've on the site for long enough, asking if you would like to be notified of new articles. But is that really the best approach

So, what is the best way to ask the user for a permission, like "show notifications"?