Skip to content

Commit 15ae5cb

Browse files
Staging to Main for Messaging 7.3.0 release (#562)
* Merge pull request #556 from adobe/staging (#559) Co-authored-by: Kevin Lind <40409666+kevinlind@users.noreply.github.com> * fix new arch issue * Upgrade Sample App to expo54, react native to 0.81 (#552) * upgrade to expo54, react native to 0.81 * upgrade dependencies * upgrade node version for circleci * upgrade node version for circleci * upgrade xcode version for circleci * fix dependencies for UTs * fix dependencies for UTs * merge staging stages * fix UTs * fix UTs * fix UTs * add evaluateJavascript method (#550) * add evaluateJavascript method * fix UTs * address PR comments * address PR comments * update docs * bump messaging to 7.3.0 (#561) * update documentation (#563) --------- Co-authored-by: Kevin Lind <40409666+kevinlind@users.noreply.github.com>
1 parent 9e1fa8c commit 15ae5cb

19 files changed

Lines changed: 2480 additions & 2423 deletions

File tree

.circleci/config.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ version: 2.1
33

44
orbs:
55
macos: circleci/macos@2.4.1
6+
node: circleci/node@7.1.0
67
rn: react-native-community/react-native@7.4.0
78

89
jobs:
910
unit-test:
1011
docker:
11-
- image: cimg/node:18.20
12+
- image: cimg/node:22.12
1213

1314
steps:
1415
- checkout
@@ -68,7 +69,7 @@ jobs:
6869

6970
build-sample-app-ios:
7071
macos:
71-
xcode: 15.2.0
72+
xcode: 16.2.0
7273
resource_class: m2pro.medium
7374

7475
steps:
@@ -82,6 +83,9 @@ jobs:
8283
name: Set Xcode Path
8384
command: sudo xcode-select -s /Applications/Xcode.app
8485

86+
- node/install:
87+
node-version: '22.12.0'
88+
8589
- run:
8690
name: Install Node.js and Yarn Dependencies
8791
command: yarn install

apps/AEPSampleAppNewArchEnabled/app.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@
3434
"expo-build-properties",
3535
{
3636
"ios": {
37-
"newArchEnabled": true,
37+
"newArchEnabled": true,
3838
"useFrameworks": "static"
3939
},
4040
"android": {
4141
"newArchEnabled": true
4242
}
4343
}
4444
],
45-
"expo-font"
45+
"expo-font",
46+
"expo-web-browser"
4647
],
4748
"experiments": {
4849
"typedRoutes": true

apps/AEPSampleAppNewArchEnabled/app/MessagingView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ const setMessagingDelegate = () => {
4949
msg.handleJavascriptMessage('myInappCallback', (content: string) => {
5050
console.log('Received webview content in onShow:', content);
5151
});
52+
msg.evaluateJavascript("(function() {console.log('my test'); return 'some result';})();", (result: string) => {
53+
console.log('Result:', result);
54+
});
5255
},
5356
shouldShowMessage: () => true,
5457
shouldSaveMessage: () => true,

apps/AEPSampleAppNewArchEnabled/package.json

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,39 @@
2727
"@adobe/react-native-aepplaces": "^7.0.0",
2828
"@adobe/react-native-aeptarget": "^7.0.0",
2929
"@adobe/react-native-aepuserprofile": "^7.0.0",
30-
"@expo/vector-icons": "^14.0.2",
31-
"@react-navigation/bottom-tabs": "7.3.12",
32-
"@react-navigation/core": "7.9.1",
33-
"@react-navigation/drawer": "7.3.11",
34-
"@react-navigation/native": "7.1.8",
35-
"@react-navigation/routers": "7.3.7",
36-
"@react-navigation/stack": "7.3.1",
37-
"expo": "~52.0.46",
38-
"expo-build-properties": "~0.13.2",
39-
"expo-constants": "~17.0.8",
40-
"expo-font": "~13.0.4",
41-
"expo-linking": "~7.0.5",
42-
"expo-router": "~4.0.21",
43-
"expo-splash-screen": "~0.29.24",
44-
"expo-status-bar": "~2.0.1",
45-
"expo-system-ui": "~4.0.9",
46-
"expo-web-browser": "~14.0.2",
47-
"react": "18.3.1",
48-
"react-dom": "18.3.1",
49-
"react-native": "0.76.9",
50-
"react-native-gesture-handler": "~2.20.2",
51-
"react-native-reanimated": "~3.16.1",
52-
"react-native-safe-area-context": "4.12.0",
53-
"react-native-screens": "~4.8.0",
54-
"react-native-web": "~0.19.10",
55-
"react-native-webview": "13.12.5",
30+
"@expo/vector-icons": "^15.0.3",
31+
"@react-navigation/drawer": "^7.7.10",
32+
"expo": "^54.0.0",
33+
"expo-build-properties": "~1.0.10",
34+
"expo-constants": "~18.0.12",
35+
"expo-font": "~14.0.10",
36+
"expo-linking": "~8.0.10",
37+
"expo-router": "~6.0.20",
38+
"expo-splash-screen": "~31.0.12",
39+
"expo-status-bar": "~3.0.9",
40+
"expo-system-ui": "~6.0.9",
41+
"expo-web-browser": "~15.0.10",
42+
"react": "19.1.0",
43+
"react-dom": "19.1.0",
44+
"react-native": "0.81.5",
45+
"react-native-gesture-handler": "~2.28.0",
46+
"react-native-reanimated": "~4.1.1",
47+
"react-native-safe-area-context": "~5.6.0",
48+
"react-native-screens": "~4.16.0",
49+
"react-native-web": "^0.21.0",
50+
"react-native-webview": "13.15.0",
51+
"react-native-worklets": "0.5.1",
5652
"recyclerlistview": "^4.2.1"
5753
},
5854
"devDependencies": {
5955
"@babel/core": "^7.20.0",
6056
"@types/jest": "^29.5.12",
61-
"@types/react": "~18.3.12",
57+
"@types/react": "~19.1.10",
6258
"@types/react-test-renderer": "^18.0.7",
6359
"jest": "^29.2.1",
64-
"jest-expo": "~52.0.6",
60+
"jest-expo": "~54.0.16",
6561
"react-test-renderer": "18.2.0",
66-
"typescript": "~5.3.3"
62+
"typescript": "~5.9.2"
6763
},
6864
"expo": {
6965
"install": {

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
2+
presets: ['module:@react-native/babel-preset'],
33
};

jest.config.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
module.exports = {
22
maxConcurrency: 10,
3-
preset: './apps/AEPSampleAppNewArchEnabled/node_modules/react-native/jest-preset.js',
3+
testEnvironment: 'node',
44
transform: {
5-
'^.+\\.(js)$': '<rootDir>/node_modules/babel-jest',
6-
'\\.(ts|tsx)$': 'ts-jest'
5+
'^.+\\.(js|jsx)$': 'babel-jest',
6+
'^.+\\.(ts|tsx)$': 'ts-jest'
77
},
8+
transformIgnorePatterns: [
9+
'node_modules/(?!(react-native|@react-native|@react-navigation)/)',
10+
],
811
setupFiles: ['./tests/jest/setup.ts'],
912
testMatch: ['**/packages/**/__tests__/*.ts'],
1013
modulePaths: ['node_modules', './apps/AEPSampleAppNewArchEnabled/node_modules'],
1114
testPathIgnorePatterns: ['./packages/template'],
1215
moduleDirectories: ['node_modules', './apps/AEPSampleAppNewArchEnabled/node_modules'],
13-
moduleFileExtensions: ['ts', 'tsx', 'js'],
16+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
17+
moduleNameMapper: {
18+
'^react-native$': '<rootDir>/apps/AEPSampleAppNewArchEnabled/node_modules/react-native'
19+
},
1420
};

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@
3434
"sampleappnewarchenabled:android:run": "cd apps/AEPSampleAppNewArchEnabled && npx expo run:android"
3535
},
3636
"devDependencies": {
37-
"@babel/core": "^7.17.5",
38-
"@babel/generator": "^7.17.3",
39-
"@babel/preset-env": "7.16.11",
40-
"@babel/preset-typescript": "^7.16.7",
41-
"@types/jest": "^27.5.2",
37+
"@babel/core": "^7.25.0",
38+
"@babel/generator": "^7.25.0",
39+
"@babel/preset-env": "^7.25.0",
40+
"@babel/preset-flow": "^7.25.0",
41+
"@babel/preset-typescript": "^7.25.0",
42+
"@react-native/babel-preset": "^0.81.0",
43+
"@types/jest": "^29.5.12",
4244
"@types/react": "^18.0.5",
4345
"@types/react-native": "^0.66.16",
4446
"babel-jest": "^29.7.0",
4547
"babel-plugin-module-resolver": "^4.1.0",
46-
"babel-preset-react-native": "5.0.2",
4748
"jest": "^29.7.0",
4849
"jest-environment-jsdom": "^29.7.0",
4950
"lerna": "^8.2.2",
50-
"metro-react-native-babel-preset": "^0.70.1",
5151
"ts-jest": "^29.1.1",
5252
"tslib": "^2.3.1",
5353
"@types/node": "^22.9.0",
54-
"typescript": "^4.5.5"
54+
"typescript": "^5.0.0"
5555
},
5656
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
5757
}

packages/messaging/__tests__/MessagingTests.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ describe('Messaging', () => {
9898
expect(spy).toHaveBeenCalledWith(id, handlerName);
9999
});
100100

101+
it('evaluateJavascript is called', async () => {
102+
const spy = jest.spyOn(NativeModules.AEPMessaging, 'evaluateJavascript');
103+
let id = 'id';
104+
let autoTrack = true;
105+
let message = new Message({id, autoTrack});
106+
let javascriptString = 'javascriptString';
107+
let callback = jest.fn();
108+
await message.evaluateJavascript(javascriptString, callback);
109+
expect(spy).toHaveBeenCalledWith(id, javascriptString);
110+
});
111+
101112
it('should call updatePropositionsForSurfaces', async () => {
102113
const spy = jest.spyOn(NativeModules.AEPMessaging, 'updatePropositionsForSurfaces');
103114
await Messaging.updatePropositionsForSurfaces([

packages/messaging/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
class RCTAEPMessagingConstants {
1515
static final String MESSAGE_ID_KEY = "messageId";
1616
static final String HANDLER_NAME_KEY = "handlerName";
17+
static final String JAVASCRIPT_STRING_KEY = "javascriptString";
1718
static final String CONTENT_KEY = "content";
19+
static final String RESULT_KEY = "result";
1820
static final String ON_JAVASCRIPT_MESSAGE_EVENT = "onJavascriptMessage";
21+
static final String ON_JAVASCRIPT_RESULT_EVENT = "onJavascriptResult";
1922
}

packages/messaging/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,25 @@ public void handleJavascriptMessage(final String messageId, final String handler
258258
});
259259
}
260260

261+
@ReactMethod
262+
public void evaluateJavascript(final String messageId, final String javascriptString) {
263+
Presentable<?> presentable = presentableCache.get(messageId);
264+
if (presentable == null || !(presentable.getPresentation() instanceof InAppMessage)) {
265+
Log.w(TAG, "evaluateJavascript: No presentable found for messageId: " + messageId);
266+
return;
267+
}
268+
269+
Presentable<InAppMessage> inAppMessagePresentable = (Presentable<InAppMessage>) presentable;
270+
InAppMessageEventHandler eventHandler = inAppMessagePresentable.getPresentation().getEventHandler();
271+
eventHandler.evaluateJavascript(javascriptString, result -> {
272+
Map<String, String> params = new HashMap<>();
273+
params.put(RCTAEPMessagingConstants.MESSAGE_ID_KEY, messageId);
274+
params.put(RCTAEPMessagingConstants.JAVASCRIPT_STRING_KEY, javascriptString);
275+
params.put(RCTAEPMessagingConstants.RESULT_KEY, result);
276+
emitEvent(RCTAEPMessagingConstants.ON_JAVASCRIPT_RESULT_EVENT, params);
277+
});
278+
}
279+
261280
// Messaging Delegate functions
262281
@Override
263282
public void onShow(final Presentable<?> presentable) {
@@ -335,11 +354,12 @@ public void onContentLoaded(final Presentable<?> presentable, PresentationConten
335354

336355
// Messaging Delegate Callback
337356
@ReactMethod(isBlockingSynchronousMethod = true)
338-
public void setMessageSettings(final boolean shouldShowMessage,
357+
public boolean setMessageSettings(final boolean shouldShowMessage,
339358
final boolean shouldSaveMessage) {
340359
this.shouldShowMessage = shouldShowMessage;
341360
this.shouldSaveMessage = shouldSaveMessage;
342361
latch.countDown();
362+
return true;
343363
}
344364

345365
/**

0 commit comments

Comments
 (0)