Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOB-10608] indicator-is-showing-one-unread-message-when-inbox #622

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ There are two ways to fix this:
sdk.dir=/path/to/Android/SDK # EG: sdk.dir=/Users/My.Name/Library/Android/sdk
```

## Error: `bundler: failed to load command: pod`
Run `bundle install` in the _example app directory_. You can also try running
it in _ios_ in the _example app directory_.

## Other
If things are not working and you are stumped as to why, try running the
following in the _example app directory_:
Expand Down
2 changes: 0 additions & 2 deletions example/src/components/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { Iterable } from '@iterable/react-native-sdk';

import { Route } from '../../constants/routes';
import { useIterableApp } from '../../hooks/useIterableApp';
Expand All @@ -10,7 +9,6 @@ import type { RootStackParamList } from '../../types';
const Stack = createNativeStackNavigator<RootStackParamList>();

export const App = () => {
console.log('Iterable.version', Iterable.getVersionFromPackageJson());
const { isLoggedIn } = useIterableApp();

return (
Expand Down
23 changes: 0 additions & 23 deletions example/src/components/App/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { useState, useEffect } from 'react';

import { Iterable } from '@iterable/react-native-sdk';

import { colors, Route } from '../../constants';
import type { MainScreenParamList } from '../../types';
Expand All @@ -17,27 +14,10 @@ const Tab = createBottomTabNavigator<MainScreenParamList>();
export const Main = () => {
const {
isInboxTab,
isLoggedIn,
loginInProgress,
returnToInboxTrigger,
setIsInboxTab,
setReturnToInboxTrigger,
userId,
} = useIterableApp();
const [unreadMessageCount, setUnreadMessageCount] = useState<number>(0);

useEffect(() => {
if (loginInProgress) return;
if (isLoggedIn) {
Iterable.inAppManager
.getMessages()
.then((messages) => setUnreadMessageCount(messages.length))
.catch((error) => console.error('Failed to get messages:', error));
} else {
// Reset unread message count when user logs out
setUnreadMessageCount(0);
}
}, [isLoggedIn, loginInProgress, userId]);

return (
<>
Expand All @@ -55,9 +35,6 @@ export const Main = () => {
<Tab.Screen
name={Route.Inbox}
component={Inbox}
options={
unreadMessageCount ? { tabBarBadge: unreadMessageCount } : {}
}
listeners={() => ({
tabPress: () => {
if (isInboxTab) {
Expand Down
Loading