Why "add Push notification feature to your app id" warning even after push-notification showing enabled in App ID?

I am using Xcode8, swift 3, iOS 10

In Targets -> capabilities showing "add the Push notification feature to your app id".

I check my APP ID and it is showing pushnotfication enabled in both development and distribution.

With same APP IS and certificate I am getting notification in iOS9 but in iOS 10 i am getting error

Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo={NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}  

and also showing red mark (issue)


Solution 1:

I restarted XCode and it was gone :-)

Solution 2:

Close Xcode -> reopen -> clean -> build -> run.

Fixed the issue for me. Xcode 9.0.

Solution 3:

Sadly I quit xcode then installed the .mobileprovision (double clicking it) then restarted xcode and the warning was gone...Followed the other answer here by SteMa

Solution 4:

This happened to me. For some reason xCode signed me out. The fix: Tap Xcode (top bar) -> select Preferences -> select your Apple Id -> Sign-in. Hope this helps someone!