Files
push_server/test_oppo_push.sh
2025-12-31 10:00:35 +08:00

59 lines
1.6 KiB
Bash
Executable File
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.
#!/bin/bash
# OPPO推送测试脚本
# 使用方法: ./test_oppo_push.sh <device_token>
# device_token: OPPO手机的registration_id需要从OPPO手机应用中获取
if [ -z "$1" ]; then
echo "使用方法: $0 <device_token>"
echo "device_token: OPPO手机的registration_id"
echo ""
echo "示例: $0 1234567890abcdef"
exit 1
fi
DEVICE_TOKEN=$1
SERVER_URL="http://localhost:8080/android/push"
echo "正在测试OPPO推送..."
echo "设备Token: $DEVICE_TOKEN"
echo "服务器地址: $SERVER_URL"
echo ""
# 构建推送消息JSON
# pushType=5 表示 OPPO 推送类型
# packageName 需要与配置的包名一致: com.xunpaisoft.social
curl -X POST "$SERVER_URL" \
-H "Content-Type: application/json;charset=UTF-8" \
-d "{
\"pushType\": 5,
\"pushMessageType\": 0,
\"packageName\": \"com.xunpaisoft.social\",
\"deviceToken\": \"$DEVICE_TOKEN\",
\"pushContent\": \"这是一条测试推送消息\",
\"sender\": \"test_user\",
\"senderName\": \"测试用户\",
\"target\": \"test_target\",
\"targetName\": \"测试目标\",
\"convType\": 0,
\"line\": 0,
\"cntType\": 1,
\"serverTime\": $(date +%s)000,
\"unReceivedMsg\": 1,
\"mentionedType\": 0,
\"isHiddenDetail\": false,
\"language\": \"zh\",
\"messageId\": $(date +%s),
\"republish\": false,
\"existBadgeNumber\": 0
}"
echo ""
echo ""
echo "测试完成请检查OPPO手机是否收到推送消息。"
echo "如果推送失败,请检查:"
echo "1. 服务器是否已启动 (端口 8080)"
echo "2. device_token 是否正确需要从OPPO手机应用中获取"
echo "3. 查看服务器日志: tail -f push.log"