4

After switching to xcode 8 beta my push notifications have stopped working.

My code signing identity for release is set to distribution. I am registering the device, receiving the token and successfully uploading it to my server without any problem. But the status of the push messages is failed.

Just wondering if i need to make any changes or if it will not work with a beta version of xcode.

alionthego
  • 8,508
  • 9
  • 52
  • 125

3 Answers3

12

In the targets, under Capabilities and Push Notifications I needed to add the push notification entitlement to my entitlements file. This was done just by clicking the button that appeared here with the error message.

alionthego
  • 8,508
  • 9
  • 52
  • 125
  • Hello, I m trying to make push notification work on ios 10, i have succefully implement the local one, and i m able to register has you said (token and all) but when i trigger the push notification from my server, i got a "A connected socket to APNS wasn't available." did you face this issue? thx – Bastien Jun 29 '16 at 08:48
  • hi. i did not face that issue. my problem was the missing entitlements file. I would suggest double checking your certificates and profile. you only need the profile that is auto-generated by xcode and starts with XC. also, if your using testflight, make sure you are using the production certificate on your server. your error may mean you are using the wrong certificate. not sure if that is your issue though. – alionthego Jun 29 '16 at 09:51
  • It seems in beta3 remote notifications stopped working completely – Alexey Jul 19 '16 at 10:11
  • 2
    For me issue was when I registered for the first time I retrieved the token. But when I unregister the token and then try to re-register token, token delegate method is not called. Now if I switch off and switch on the device, its working fine. – Rupesh Aug 17 '16 at 08:56
  • 1
    I have the same thing as @Rupesh – kokluch Sep 19 '16 at 12:46
  • @kokluch and Rupesh, me too – Alon Amir Sep 19 '16 at 23:38
5

For me issue was when I registered for the first time I retrieved the token. But when I unregister the token and then try to re-register token, token delegate method is not called.

Now if I switch off and switch on the device, its working fine.

Rupesh
  • 2,061
  • 5
  • 22
  • 36
  • Exactly the same happens over here, even after using the new `UserNotifications.framework` calls. – Alon Amir Sep 19 '16 at 23:28
  • Same problem here, too. Anyone having a solution for this? – Kai Sep 21 '16 at 11:23
  • Just found the solution: don't call unregister. See Apple Docs https://developer.apple.com/reference/uikit/uiapplication/1623093-unregisterforremotenotifications?language=objc – Kai Sep 21 '16 at 15:20
  • 2
    @kai: Its not the solution, i think it is workaround for time being – Rupesh Sep 21 '16 at 16:37
  • I am seeing on a new test device that my notifs only work properly on the first debug. Each subsequent Run causes the console to spit out that a completely unknown token was encountered. So odd. – drew.. Oct 16 '16 at 17:36
  • @Rupesh according to Apple docs you really should call the unregister in rare cases: "You should call this method in rare circumstances only, such as when a new version of the app removes support for all types of remote notifications. Users can temporarily prevent apps from receiving remote notifications through the Notifications section of the Settings app. Apps unregistered through this method can always re-register." For me this is the solution and still is. – Kai Aug 09 '17 at 07:08
1

In my project push notifications correctly worked on iOS 9 and did't work on iOS 10. There is notification model in my project that allows to enable/disable push notifications from initial help screen and settings screen. And state of this model was based on UIUserNotificationSettings that can be received from the system (registerUserNotificationSettings: and currentUserNotificationSettings).

States: 1. UNDEFINED - currentUserNotificationSettings is equal to nil or categories count is equal to 0 2. APLIED - currentUserNotificationSettings are equal to those that were requested by registerUserNotificationSettings: 3. DENIED - currentUserNotificationSettings are not equal...

As I said, on iOS 9 this model works well but in iOS 10 it's state never becomes UNDEFINED because categories count of currentUserNotificationSettings is not equal to zero even if app was reinstalled.

So model's state becomes DENIED on start of the application and it doesn't call registerUserNotificationSettings: at all (it assumes that user has denied push notifications).

maxibystro
  • 25
  • 1
  • 7