Skip to content

Commit

Permalink
Merge branch 'master' into atoledano-line-selector
Browse files Browse the repository at this point in the history
  • Loading branch information
atabel authored Feb 13, 2025
2 parents 73ab77b + 88bdc81 commit 1cde541
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## v.3.49.0 - 2025-02-03

- `refreshNavBar`: new method to refresh navigation bar with the response of
Visual Modules API

## v.3.48.3 - 2025-01-28

- `validateDatamobRequirements`: fix return types.
Expand Down
43 changes: 41 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ downloadBase64({
expandedTitle</kbd><br/> <kbd>App version >= 14.8: Additional properties and
deprecations</kbd><br/> <kbd>Partial support in B2P App version <=24.10:
title</kbd><br/> <kbd>Partial support in B2P App version >=24.11: right
actions</kbd><br/> <kbd>Full support in B2P App version >=24.12: title</kbd>
actions</kbd><br/>
Customize WebView NavigationBar properties. You can set one or more properties
in a single call
Expand Down Expand Up @@ -552,6 +552,8 @@ nativeMessage({
### logEvent
<kbd>Available in B2P App version >=24.10</kbd>
Log an event to firebase
```ts
Expand Down Expand Up @@ -610,6 +612,8 @@ logEvent(yourEvent, {sanitize: false});
### setScreenName
<kbd>Available in B2P App version >=24.10</kbd>
Log the current screen name (or page name) to firebase
```ts
Expand All @@ -618,6 +622,8 @@ setScreenName: (screenName: string, params?: {[key: string]: any}) => Promise<vo
### setUserProperty
<kbd>Available in B2P App version >=24.10</kbd>
Set a user property to firebase
```ts
Expand Down Expand Up @@ -706,7 +712,7 @@ internalNavigation: (feature: string) => Promise<void>;
### dismiss
<kbd>App version >=11.5</kbd>
<kbd>App version >=11.5</kbd> <kbd>Available in B2P App version >=24.10</kbd>
Dismiss the current webview and optionally navigate to another url
Expand Down Expand Up @@ -1583,6 +1589,39 @@ isQualtricsInterceptAvailableForUser: ({interceptId: string}) => Promise<{isAvai
}
```
### refreshNavBar
Method that allows WebView to refresh the navigation bars that are retrieved by
Visual Modules API
```ts
refreshNavBar: ({
moduleId?: string,
productId?: string
}) => Promise<void>;
```
where
- `moduleId` is an optional parameter
- If it is not included, it means the app will refresh top and bottom bar
- If it is included, it should be the same values used for Visual Modules
API and the app will request to refresh only the indicated bar
- `productId` is an optional parameter
- If it is not included, visual modules is requested as it is today, just
with the userID as query param plus the `moduleId`
- If it is included, visual modules will be requested for the current
userID and for the `productId`
#### Example
```ts
refreshNavBar({
moduleId: 'bottombar',
productId: 'ID_00fe00a87b2',
});
```
## Error handling
If an uncontrolled error occurs, promise will be rejected with an error object:
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export {
updatePhoneNumbers,
} from './src/contacts';

export {highlightNavigationTab} from './src/navigation-tabs';
export {highlightNavigationTab, refreshNavBar} from './src/navigation-tabs';

export {
logEvent,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tef-novum/webview-bridge",
"version": "3.48.3",
"version": "3.49.0",
"description": "JavaScript library to access to native functionality. Requires a webview with a postMessage bridge.",
"main": "./dist/webview-bridge-cjs.js",
"module": "./dist/webview-bridge.mjs",
Expand Down
50 changes: 50 additions & 0 deletions src/__tests__/navigation-tabs-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {refreshNavBar} from '../navigation-tabs';
import {
createFakeAndroidPostMessage,
removeFakeAndroidPostMessage,
} from './fake-post-message';

const MODULE_ID = 'bottombar';
const PRODUCT_ID = 'myProductId';

afterEach(() => {
removeFakeAndroidPostMessage();
});

test('refresh navigation bars without params', (done) => {
createFakeAndroidPostMessage({
checkMessage: (message) => {
expect(message.type).toBe('REFRESH_NAV_BAR');
},
getResponse: (message) => ({
type: message.type,
id: message.id,
}),
});

refreshNavBar({}).then((res) => {
expect(res).toBeUndefined();
done();
});
});

test('refresh navigation bars with params', (done) => {
createFakeAndroidPostMessage({
checkMessage: (message) => {
expect(message.type).toBe('REFRESH_NAV_BAR');
expect(message.payload).toEqual({
moduleId: MODULE_ID,
productId: PRODUCT_ID,
});
},
getResponse: (message) => ({
type: message.type,
id: message.id,
}),
});

refreshNavBar({moduleId: MODULE_ID, productId: PRODUCT_ID}).then((res) => {
expect(res).toBeUndefined();
done();
});
});
18 changes: 18 additions & 0 deletions src/navigation-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,21 @@ export const highlightNavigationTab = ({
count,
},
});

/**
* Request the app to refresh the navigation bars
*/
export const refreshNavBar = ({
moduleId,
productId,
}: {
moduleId?: string; // module id used in Visual Modules API
productId?: string; // identifier of the product as it is in Subscribed Products API
}): Promise<void> =>
postMessageToNativeApp({
type: 'REFRESH_NAV_BAR',
payload: {
moduleId,
productId,
},
});
5 changes: 5 additions & 0 deletions src/post-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ export type ResponsesFromNativeApp = {
id: string;
payload: {isAvailable: boolean};
};
REFRESH_NAV_BAR: {
type: 'REFRESH_NAV_BAR';
id: string;
payload: void;
};
};

export type NativeAppResponsePayload<
Expand Down

0 comments on commit 1cde541

Please sign in to comment.