Files
push_server/test_strong_reminder_push.sh
2025-12-31 10:42:38 +08:00

82 lines
2.3 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推送 - 强提醒测试脚本(不使用通讯与服务类消息权限)
# 尝试通过其他参数实现强提醒效果
if [ -z "$1" ]; then
echo "使用方法: $0 <device_token>"
exit 1
fi
DEVICE_TOKEN=$1
# OPPO推送配置
APP_KEY="bb0819c889ae40cd8bde5a8ad4e670fe"
APP_SERVER_SECRET="2d8b4e922d60453d987f0d09de6eb4a6"
API_URL="https://api.push.oppomobile.com"
echo "=========================================="
echo "OPPO推送 - 强提醒测试(不使用通讯与服务权限)"
echo "=========================================="
# 1. 获取 auth_token
TIMESTAMP=$(date +%s)000
SIGN_STRING="${APP_KEY}${TIMESTAMP}${APP_SERVER_SECRET}"
SIGN=$(echo -n "$SIGN_STRING" | sha256sum | awk '{print $1}')
AUTH_RESPONSE=$(curl -s -X POST "${API_URL}/server/v1/auth" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "app_key=${APP_KEY}&timestamp=${TIMESTAMP}&sign=${SIGN}")
AUTH_TOKEN=$(echo "$AUTH_RESPONSE" | grep -o '"auth_token":"[^"]*' | cut -d'"' -f4)
if [ -z "$AUTH_TOKEN" ]; then
echo "错误: 无法获取 auth_token"
exit 1
fi
echo "✓ 获取 auth_token 成功"
echo ""
# 2. 发送消息(尝试使用 notify_level 等参数,但不使用 channel_id
MESSAGE_JSON=$(cat <<EOF
{
"target_type": 1,
"target_value": "$DEVICE_TOKEN",
"notification": {
"title": "知你",
"content": "我是api - 强提醒测试",
"notify_level": 2,
"category": "IM",
"offLine": true,
"offLineTtl": 86400,
"showTimeType": 0,
"networkType": 0,
"style": 1,
"clickActionType": 0
}
}
EOF
)
echo "发送消息(不使用 channel_id..."
PUSH_RESPONSE=$(curl -s -X POST "${API_URL}/server/v1/message/notification/unicast" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "message=$(echo "$MESSAGE_JSON" | python -c "import sys, json, urllib.parse; print(urllib.parse.quote(json.dumps(json.load(sys.stdin))))" 2>/dev/null || echo "$MESSAGE_JSON")&auth_token=${AUTH_TOKEN}")
echo "响应:"
echo "$PUSH_RESPONSE" | python -m json.tool 2>/dev/null || echo "$PUSH_RESPONSE"
if echo "$PUSH_RESPONSE" | grep -q '"code":0'; then
echo ""
echo "✓ 推送成功!"
echo "注意:如果仍然没有强提醒,建议在应用端配置高优先级通知渠道"
else
echo ""
echo "✗ 推送失败"
fi
echo ""
echo "=========================================="