Invalid entitlements error when adding push notifications

I’m trying to add push notifications to my chat app following this tutorial:

I’ve toggled Push Notifications to On in “Capabilities”:

  • Xcode Hide white status bar ios 10
  • When should we use “embedded binaries” rather than “Linked Frameworks” in Xcode?
  • iOS: UITableView cells with multiple lines?
  • iOS app doesn't ask for location permission
  • Support different orientation for only one view iOS 6
  • Parsing HTML into NSAttributedText - how to set font?
  • enter image description here

    My provisioning profile is set up for push notifications:

    enter image description here

    I downloaded it, and double clicked it to install.

    For Code Signing, in Target -> Code Signing:

    enter image description here

    And Project -> Code Signing:

    enter image description here

    Entitlements file:

    enter image description here

    When I ran the project it succeeded, then said “The executable was signed with invalid entitlements”. Full error The entitlements specified in your application’s Code Signing Entitlements file are invalid, not permitted, or do not match those specified in your provisioning profile. (0xE8008016).

    Thanks for reading.. Any help on this will be hugely appreciated!

    EDIT: Additional Information

    Using Xcode 8.2.1

    • In my App ID in the developers portal, Game Center, In-App Purchases, and Push Notifications are enabled. It’s my understanding that Game Center and IAP are enabled by default.
    • I’ve tried turning GC and IAP On, and then Off again. Restart Xcode, clean, build. No luck
    • I’ve tried turning GC and IAP On, then regenerating my provisioning profiles, installing them, cleaning and building. No luck.
    • My Bundle ID matches everywhere.

    4 Solutions Collect From Internet About “Invalid entitlements error when adding push notifications”

    Delete any unknown entries in entitlements file, which are not added by you.

    Example: you can delete keychainAccessGroup entry from your entitlements file, if that is not added by you intentionally.

    Have a look at your test target, the Team identifier should be same for both Test and Main target.

    As your given information your app has enabled services for Game Centre, In-App Purchase and Notification.

    and according to your entitlements settings that your app in Xcode doesn’t have Game Centre as enabled.
    Check you entitlements setting once and try again, after enabling Game Centre there shouldn’t be any problem.

    enable in app purchase Capabilities in xcode because your app has enabled services for in app purchase
    and please select the provision profile and developer at Code Signing: instead of “iOS Developer and Automatic”

    From your project settings, go to general then check the checkbox Automatically manage signing then select your team from below field! that’s it!

    You can refer the below screen shot,

    enter image description here