Files
push_server/OPPO_PUSH_README.md
2025-12-31 10:00:35 +08:00

122 lines
2.9 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推送服务配置说明
## 配置信息
已配置的OPPO推送参数
- **包名**: com.xunpaisoft.social
- **AppId**: 32150237
- **AppKey**: bb0819c889ae40cd8bde5a8ad4e670fe
- **AppSecret**: 9b5a0e6d560e406dbb70fbb4e0e38098
- **AppServerSecret**: 2d8b4e922d60453d987f0d09de6eb4a6
配置文件位置: `config/oppo.properties`
## 启动服务
### 1. 编译项目
```bash
cd /home/renjianbo/push/push_server
mvn clean package
```
### 2. 运行服务
编译成功后,在 `target` 目录找到 `push-xxxx.jar`,然后执行:
```bash
# 确保 config 目录在 jar 包同级目录
java -jar target/push-*.jar
```
或者后台运行:
```bash
nohup java -jar target/push-*.jar > push.log 2>&1 &
```
服务启动后,默认监听端口:**8085**
## 测试推送
### 方法1: 使用测试脚本
```bash
cd /home/renjianbo/push/push_server
./test_oppo_push.sh <device_token>
```
其中 `device_token` 是 OPPO 手机的 registration_id需要从 OPPO 手机应用中获取。
### 方法2: 使用 curl 命令
```bash
curl -X POST http://localhost:8085/android/push \
-H "Content-Type: application/json;charset=UTF-8" \
-d '{
"pushType": 5,
"pushMessageType": 0,
"packageName": "com.xunpaisoft.social",
"deviceToken": "YOUR_DEVICE_TOKEN",
"pushContent": "这是一条测试推送消息",
"sender": "test_user",
"senderName": "测试用户",
"target": "test_target",
"targetName": "测试目标",
"convType": 0,
"line": 0,
"cntType": 1,
"serverTime": 1234567890000,
"unReceivedMsg": 1,
"mentionedType": 0,
"isHiddenDetail": false,
"language": "zh",
"messageId": 1234567890,
"republish": false,
"existBadgeNumber": 0
}'
```
**注意**: 将 `YOUR_DEVICE_TOKEN` 替换为实际的 OPPO 设备 registration_id。
## 获取 Device Token
OPPO 手机的 registration_iddevice_token需要从以下方式获取
1. **从 OPPO 手机应用中获取**: 应用启动后OPPO Push SDK 会返回 registration_id
2. **查看应用日志**: 在应用日志中查找 registration_id
3. **从 OPPO 推送平台获取**: 登录 OPPO 开放平台,在推送统计中可以看到设备的 registration_id
## 验证推送
1. 确保 OPPO 手机已安装应用(包名: com.xunpaisoft.social
2. 确保应用已获取推送权限
3. 确保手机网络正常
4. 发送测试推送后,检查手机是否收到通知
5. 查看服务器日志: `tail -f push.log` 或查看控制台输出
## 常见问题
1. **推送失败**:
- 检查 device_token 是否正确
- 检查包名是否匹配com.xunpaisoft.social
- 检查服务器日志中的错误信息
2. **服务启动失败**:
- 检查端口 8085 是否被占用
- 检查 config 目录是否存在且配置文件正确
3. **配置不生效**:
- 确保 config 目录在 jar 包同级目录
- 检查配置文件格式是否正确
## 日志查看
服务日志文件: `push.log`
查看实时日志:
```bash
tail -f push.log
```