Issue Description:
When using Agora Signaling across two applications — a React web app (agora-rtm-sdk ^1.6.0-205) and a React Native app (agora-react-native-rtm ^2.2.6) — users encountered issues delivering messages to offline recipients, even when setting the storeInHistory option to true. Additionally, error codes were returned during the publish() operation.
Platform/SDK:
- Web: React app using agora-rtm-sdk version ^1.6.0-205
- Mobile: React Native app using agora-react-native-rtm version ^2.2.6
Error Message (optional):
[RTM] publish error {“error”: true, “errorCode”: -*****, “operation”: “publish”, “reason”: {“errorCode”: -*****, “requestId”: 6, ‘requestId_str’: “6”}}
Step by Step Solution:
1. Log in to the Agora Console
Go to the Agora Console.
2. Select Your Project
Choose the project used by both your React and React Native applications (they share the same appId).
3. Enable Signaling Storage
- Navigate to Products & Usage Signaling Storage Settings.
- Enable the Message History (Storage) feature.
- Save your changes.
4. Update Your Code
In your publish method, ensure that storeInHistory is set to true in your PublishOptions.
javascript
await engine.publish(userId, payload, new PublishOptions({
channelType: RtmChannelType.user,
messageType: RtmMessageType.string,
storeInHistory: true
}));
5. Test Sending Messages
- Test message sending when the recipient is offline and verify that messages are delivered once the user comes online.
- Monitor your application logs to ensure no publish errors occur.
6. (Optional) Upgrade the Web SDK
To ensure compatibility between platforms, update your React web app to the latest version of the Agora RTM SDK, as version ^1.6.0-205 is outdated.
bash
npm install agora-rtm-sdk@latest
Root Cause:
The storeInHistory feature requires activation of Signaling Storage within the Agora Console. Without enabling it, the SDK will not store messages for offline delivery. Additionally, using an outdated SDK version may lead to mismatched behavior between platforms.
Prevention/Best Practice:
- Always enable necessary features (like message storage) in the Agora Console before using them in code.
- Keep both web and mobile Agora SDKs updated to the latest release to ensure API parity and optimal compatibility between platforms.
Corresponding Document/Link:
- Agora Signaling: Message History Documentation
- Agora Console Overview