If I'm not mistaken, Flarum already has a feature like this, although, instead of the number representing notifications, it represents the new threads needed to load.
You should consider adding chrome notification support. That would be an amazing feature. Facebook and Gitter both do it.