This repository has been archived by the owner on Jul 28, 2022. It is now read-only.
v6.0.0-rc.2
Pre-release
Pre-release
This is a pre-release for the next version of @bam.tech/react-native-batch. There are several breaking changes (indicated with [BREAKING]) so please read along. The documentation hosted on GitHub has not been updated as this is still a pre-release. The following changelog may evolve with new breaking changes until the stable version.
See rc.0 changelog and rc.1 changelog too.
- [iOS] [Inbox] Fixed a crash when a notification's source was unknown
- [BREAKING] [Inbox] Rewrote inbox API to expose every native SDK Inbox methods such as
markNotificationAsRead
. You can now implement an infinite loading list of notifications with this API.
Before:
import { BatchInbox } from '@bam.tech/react-native-batch';
BatchInbox.fetchNotifications().then(console.log);
After:
const fetcher = await BatchInbox.getFetcher();
await fetcher.fetchNewNotifications().then(({ notifications }) => console.log(notifications));
await fetcher.destroy();
But you can also do things like:
// in real life, you would use some useState/useReducer, and don't forget to call fetcher.destroy() when the component unmounts to free up memory
const fetcher = await BatchInbox.getFetcher({
maxPageSize: 1,
fetchLimit: 5,
user: { identifier: 'test', authenticationKey: 'secretGeneratedOnBackend' },
});
const allNotifications = [];
const { notifications: initialNotifications, endReached } = fetcher.fetchNewNotifications();
allNotifications.push(initialNotifications);
if (!endReached) {
const { notifications: nextPage } = await fetcher.fetchNextPage();
allNotifications.push(nextPage);
}
if (allNotifications.length) {
await fetcher.markNotificationAsRead(allNotifications[0].identifier);
}
await fetcher.destroy();