Reader: Can't enable in-app notifications on some posts
Expected behavior
I expected to be able to enable in-app notifications on any posts in the Reader.
Actual behavior
When I try to enable in-app notifications on some posts, the toggle immediately toggles off. I noticed it happening on a blog (internal p2) where I already follow all posts and comments via email.
The app logs show the following:
2022-07-01 12:57:21:712 🔵 Tracked: reader_toggle_comment_notifications <blog_id: 208157483, default_tab_experiment: dashboard, notifications_enabled: 1, source: reader_post_details_comments, subscription_count: 96>
2022-07-01 12:57:22:037 Error updating notification settings for followed conversation: Optional((extension in WordPressKit):__C.ReaderPostServiceRemote.ResponseError.decodingFailed)
2022-07-01 12:57:22:038 Reader Comments: error toggling notification status: Optional((extension in WordPressKit):__C.ReaderPostServiceRemote.ResponseError.decodingFailed))
Steps to reproduce the behavior
- Follow all posts and comments on a blog (this can be adjusted in the following settings in https://wordpress.com/following/manage)
- Find a post from that blog in the Reader.
- At the bottom of the post detail, tap the bell icon.
- In the bottom sheet, toggle on "Enable in-app notifications".
- Notice the setting immediately toggles off. When you close the bottom sheet, a notice appears with the error "Could not enable notifications"
Tested on iPhone 12 Mini, iOS 15.5, Jetpack app 20.0.1
This issue likely isn't relevant anymore. The bell icon is removed. Similar functionality exists through "Subscribe" button and following the toast's enable button works fine. Pinged @dvdchr just to be safe.
EDIT: I misunderstood the issue before. The bug remains and needs a fix.
The culprit is the remoteReceivesNotifications we receive as response in ReaderPostServiceRemote. It returns false even though the notifications are enabled from the Web. This causes the remoteReceivesNotifications == receiveNotifications comparison to fail as the local value is true
Fixed in https://github.com/wordpress-mobile/WordPress-iOS/pull/24135. This button should not be visible for P2s with the global "Email me new comments" enabled.