Anusha V
Anusha V

Reputation: 116

Cloud kit subscriptions are not working with production environment in test flight build

Cloud kit subscriptions (Push notifications) with development environment are working fine but when i try with production environment using test flight are not working

Upvotes: 2

Views: 398

Answers (2)

Thunk
Thunk

Reputation: 4177

Although this answer is pretty late, I'm posting in case others still find their way here. I encountered this same issue. CloudKit subscription notifications were working fine in the dev environment and appeared to completely stop when I distributed the app via TestFlight.

After some debugging, I found that application:didReceiveRemoteNotification was actually firing as expected. The problem was, I had cached the serverChangeToken in the user defaults. That serverChangeToken was the Development environment's change token. When I switched to prod (via TestFlight), that token was no longer valid... it was way in the future from Prod's perspective. So my fetchNotificationChangesOperation with that change token was finding no results newer than the token.

The fix for me, since this app is still in development, is to check which environment I'm in, and save separate Dev and Prod change tokens in the user defaults.

My scenario will only affect development devices; any user that installs directly from the store will only ever see Prod's version of the change token.

Upvotes: 2

Anusha V
Anusha V

Reputation: 116

Through TestFlight build, Cloud kit subscriptions are not working with production environment. Once app is released to Appstore, subscriptions are working

Upvotes: 2

Related Questions