Skip to content

Commit 7fde4e7

Browse files
committed
feat: implement retry policy and JWT error handling in IterableAppProvider
1 parent cfe1de2 commit 7fde4e7

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

example/src/hooks/useIterableApp.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
IterableConfig,
1515
IterableInAppShowResponse,
1616
IterableLogLevel,
17+
IterableRetryBackoff,
1718
} from '@iterable/react-native-sdk';
1819

1920
import { Route } from '../constants/routes';
@@ -96,7 +97,9 @@ export const IterableAppProvider: FunctionComponent<
9697
const [apiKey, setApiKey] = useState<string | undefined>(
9798
process.env.ITBL_API_KEY
9899
);
99-
const [userId, setUserId] = useState<string | null>(process.env.ITBL_ID ?? null);
100+
const [userId, setUserId] = useState<string | null>(
101+
process.env.ITBL_ID ?? null
102+
);
100103
const [loginInProgress, setLoginInProgress] = useState<boolean>(false);
101104

102105
const getUserId = useCallback(() => userId ?? process.env.ITBL_ID, [userId]);
@@ -124,6 +127,16 @@ export const IterableAppProvider: FunctionComponent<
124127

125128
config.inAppDisplayInterval = 1.0; // Min gap between in-apps. No need to set this in production.
126129

130+
config.retryPolicy = {
131+
maxRetry: 5,
132+
retryInterval: 10,
133+
retryBackoff: IterableRetryBackoff.LINEAR,
134+
};
135+
136+
config.onJWTError = (authFailure) => {
137+
console.error('Error fetching JWT:', authFailure);
138+
};
139+
127140
config.urlHandler = (url: string) => {
128141
const routeNames = [Route.Commerce, Route.Inbox, Route.User];
129142
for (const route of routeNames) {

0 commit comments

Comments
 (0)