Check the Capabilities tab on your target and make sure to add the Push Notifications entitlement to your entitlements file that shows a checkmark (under Push Notifications). Moreover, it can help to remove “Push Notifications” on Capabilities and adding the capability again (https://i.stack.imgur.com/PrziM.png).
– Log in to the Apple Developer Portal.
– Navigate to Certificates, IDs & Profiles > Identifiers > App IDs and click the App ID associated with your app.
– On the screen for your App ID, check Capabilities > Push Notifications.
– Click Save and respond to the Modify App Capabilities dialog box that appears.
– To create the certificate. follow Apple’s Create a certificate signing request instructions. In the Apple Developer Portal, navigate back to your App ID afterward.
– Click Capabilities > Push Notifications > ACTIVATE THIS.
– Click Continue.
– Click Download to download and use the updated certificate.