If you're getting the same error on iOS,
Open your iOS project in Xcode using this command:
open ios/Runner.xcworkspace
In Xcode, go to:
Runner → Signing & Capabilities
Check whether Push Notifications capability is added.
Make sure the capability is enabled for both Debug and Release modes.
In my case, it was only enabled for Debug, and that caused the error.
After enabling it for Release as well, everything started working correctly.
Hope this helps you too!