agilgur5 / react-native-manga-reader-app

[Alpha] A React Native / Expo app for cross-platform manga reading
https://expo.io/@agilgur5/react-native-manga-reader-app
Other
16 stars 4 forks source link

Use BackgroundFetch and LocalNotifications to notify of new chapters #18

Open agilgur5 opened 5 years ago

agilgur5 commented 5 years ago

There's no server component to this, so we can't do this server-side and send a push notification, have to do it client-side and send local notification. Of course the major downside to this (apart from battery and phone usage) is that if the app is terminated or the phone is restarted, the BackgroundFetch won't start until the app is opened again 😕 On Android, there is a workaround built-in for both these cases, but not for iOS.

Sending Local Notif is easy enough, but BackgroundFetch requires some more reading and a bit of effort to get familiar and set-up.

Related to this would be loading chapters on the front-page / main view and highlighting mangas which have new unread chapters. New Unread Chapter indicates highlight in-app and LocalNotification out-of-app (probably no need to notify if app is still open, user will probably see the new chapter indicator themselves... well not if they quit the app while inside a manga... idk).

agilgur5 commented 5 years ago

So loading chapters in the main view and highlighting mangas with new unread chapters should definitely be in 1.0.0. I find myself using other apps without this feature as otherwise I have to click into each manga to tell if there's an update (or otherwise remember, and I don't even remember what time of week each releases, esp those that aren't weekly).

This should be fairly easy to implement, just call loadChapters on each favorited manga, and then, UI-wise, highlight those with new unread and write how many new unread under the title (probably instead of "Today"/"Yesterday" last updated? though those could be more useful if not caught up? or not... need to think about that a bit more).

The implementation details also made me realize that there's a small issue with local notifs, in that it has to know if it's already notified or not (i.e. don't notify there's a new chapter all day/week for the same manga). In practice, should be able to check if the number of chapters (chapters.length) differs from last time/the persisted number. Might want to check only latest though, as sometimes a sub-chapter like a 0.5 is added some chapters ago and that may or may not be worth notifying about.