I tried with this and it dont works
global $bp;
$hmag_inbox_count = messages_get_unread_count();
echo ‘<span class=”mobile-menu-builder–links mobile-menu-builder–link-2 “>’.$hmag_inbox_count.'</span>’;
messages_get_unread_count() needs a user_id, so something like message_get_unread_count( get_current_user_id() )
should return the unread count for the user.
i did not much knowledge about it. please suggest accurate answer .