Files
oppo_push_server/通讯与服务类消息说明.md
2025-12-29 15:20:51 +08:00

137 lines
3.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 通讯与服务类消息发送说明
## 概述
本文档说明如何使用本后台服务发送**通讯与服务(原私信)类消息**。
根据 [OPPO推送服务官方文档](https://open.oppomobile.com/documentation/page/info?id=13189),通讯与服务类消息需要特殊的参数配置。
## 关键配置参数
### 1. 频道IDchannel_id
- **值**: `previte_message`
- **位置**: `src/main/resources/application.properties`
- **配置项**: `oppo.push.channel.id.im=previte_message`
### 2. 频道名称channel_name
- **值**: `消息推送`
- **位置**: `src/main/resources/application.properties`
- **配置项**: `oppo.push.channel.name.im=消息推送`
## 代码实现
`OppoPushService.java` 中,发送消息时会自动设置以下参数:
```java
// 通讯与服务(原私信)类消息特殊参数
notification.put("channel_id", config.getChannelIdIm()); // previte_message
notification.put("channel_name", config.getChannelNameIm()); // 消息推送
// extra参数可选
Map<String, Object> extra = new HashMap<>();
extra.put("message_type", "chat"); // 标识为私信类消息
notification.put("extra", extra);
```
## 消息体结构
发送通讯与服务类消息时,完整的消息体结构如下:
```json
{
"target_type": 1,
"target_value": "设备的registration_id",
"notification": {
"title": "消息标题",
"content": "消息内容",
"click_action_type": 1,
"click_action_type_value": "",
"channel_id": "previte_message",
"channel_name": "消息推送",
"extra": {
"message_type": "chat"
}
}
}
```
## 测试步骤
### 1. 确保配置正确
检查 `application.properties` 文件:
```properties
oppo.push.channel.id.im=previte_message
oppo.push.channel.name.im=消息推送
```
### 2. 启动服务
```bash
mvn spring-boot:run
```
### 3. 发送测试消息
使用 curl 命令:
```bash
curl -X POST http://localhost:8080/api/push/send \
-H "Content-Type: application/json" \
-d '{
"targetValue": "您的registration_id",
"title": "测试私信",
"content": "这是一条通讯与服务类消息",
"messageType": "1"
}'
```
### 4. 验证结果
- 检查API返回`success` 应为 `true`
- 检查设备消息应出现在OPPO手机的"消息推送"频道中
- 检查日志:查看控制台输出的详细日志
## 注意事项
1. **频道ID必须正确**`channel_id` 必须设置为 `previte_message`,否则消息不会被识别为普通通知
2. **频道名称**`channel_name` 设置为 `消息推送`这是OPPO系统识别的标准名称
3. **设备端配置**确保移动应用已正确集成OPPO推送SDK并且应用已获得通知权限
4. **registration_id**必须使用真实的设备registration_id不能随意填写
5. **消息分类**:通过设置 `channel_id``previte_message`消息会被OPPO系统自动分类为"通讯与服务"类消息
## 常见问题
### Q1: 消息发送成功但设备收不到?
**A**: 检查以下几点:
- 设备是否在线
- 应用是否已获得通知权限
- registration_id是否正确
- 应用是否已正确集成OPPO推送SDK
### Q2: 消息收到了但不是通讯与服务类?
**A**: 检查:
- `channel_id` 是否正确设置为 `previte_message`
- 查看日志确认消息体中的参数是否正确
### Q3: 如何确认消息类型?
**A**:
- 在OPPO手机上通讯与服务类消息会显示在"消息推送"频道中
- 可以通过OPPO开放平台的推送统计查看消息分类
## 相关文档
- [OPPO推送服务文档 - 通讯与服务类消息](https://open.oppomobile.com/documentation/page/info?id=13189)
- [OPPO开放平台](https://open.oppomobile.com)
## 技术支持
如有问题,请:
1. 查看控制台日志获取详细错误信息
2. 检查OPPO开放平台的推送统计
3. 参考OPPO官方文档