diff --git a/config/honor.properties b/config/honor.properties index 972cfe1..7c61c14 100644 --- a/config/honor.properties +++ b/config/honor.properties @@ -1,6 +1,11 @@ -honor.appSecret=a4e5e6a0c8a5d8424aba5a8f0aae3d0c -honor.appId=100221325 +# 荣耀推送服务配置 +# 包名: com.xunpaisoft.social +# APP ID: 104475849 (用于发送消息) +# Client ID: d9fbf0f049834fb992df547819f8b160 (用于获取 token) +# Client Secret: 37MeGLszVlQrNNcQ2JMZxhXTHq1E0FQy (用于获取 token) +honor.appId=104475849 +honor.clientId=d9fbf0f049834fb992df547819f8b160 +honor.clientSecret=37MeGLszVlQrNNcQ2JMZxhXTHq1E0FQy -#应用入口Activity类全路径,一定要根据你们的实际情况修改 -#样例:com.example.test.MainActivity -honor.badgeClass=cn.wildfire.chat.app.main.SplashActivity \ No newline at end of file +# 应用入口Activity类全路径 +honor.badgeClass=com.xunpaisoft.social.im.main.MainActivity \ No newline at end of file diff --git a/config/vivo.properties b/config/vivo.properties index 1cd166c..3f58e1c 100644 --- a/config/vivo.properties +++ b/config/vivo.properties @@ -1,3 +1,6 @@ -vivo.appSecret=d0f24e5b-e92b-4b95-8d45-927bec3ba512 -vivo.appId=12918 -vivo.appKey=c42feb05-de6c-427d-af55-4f902d9e0a75 \ No newline at end of file +# Vivo推送服务配置 +# 包名: com.xunpaisoft.social +# AppID: 105830948 +vivo.appId=105830948 +vivo.appKey=30dc4748b5bf287a74b5ce67ab5b182d +vivo.appSecret=963e208c-496c-4112-b975-7def907b0179 \ No newline at end of file diff --git a/push.log b/push.log index 730f310..26edf4c 100644 --- a/push.log +++ b/push.log @@ -13,23 +13,23 @@ SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorSta =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.6.RELEASE) -2025-12-31 09:59:06.314 INFO 24833 --- [ main] cn.wildfirechat.push.PushApplication : Starting PushApplication v0.1.2 on VM-4-13-centos with PID 24833 (/home/renjianbo/push/push_server-master/target/push-0.1.2.jar started by renjianbo in /home/renjianbo/push/push_server) -2025-12-31 09:59:06.321 INFO 24833 --- [ main] cn.wildfirechat.push.PushApplication : No active profile set, falling back to default profiles: default -2025-12-31 09:59:06.433 INFO 24833 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2a3046da: startup date [Wed Dec 31 09:59:06 CST 2025]; root of context hierarchy -2025-12-31 09:59:09.464 INFO 24833 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) -2025-12-31 09:59:09.508 INFO 24833 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] -2025-12-31 09:59:09.508 INFO 24833 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34 -2025-12-31 09:59:09.574 INFO 24833 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib] -2025-12-31 09:59:09.729 INFO 24833 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext -2025-12-31 09:59:09.729 INFO 24833 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3300 ms -2025-12-31 09:59:09.836 INFO 24833 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/] -2025-12-31 09:59:09.841 INFO 24833 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] -2025-12-31 09:59:09.841 INFO 24833 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] -2025-12-31 09:59:09.841 INFO 24833 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] -2025-12-31 09:59:09.841 INFO 24833 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] -2025-12-31 09:59:10.031 INFO 24833 --- [ main] c.w.push.android.oppo.OppoPush : OppoPush init start, appKey: bb0819c889ae40cd8bde5a8ad4e670fe, appSecret: 9b5a0e6d56..., appServerSecret: 2d8b4e922d... -2025-12-31 09:59:10.917 INFO 24833 --- [ main] c.w.push.android.oppo.OppoPush : OppoPush init success, using secret: appServerSecret -2025-12-31 09:59:11.313 ERROR 24833 --- [ main] cn.wildfirechat.push.ios.ApnsServer : ApnsServer init failed +2025-12-31 16:18:32.548 INFO 31163 --- [ main] cn.wildfirechat.push.PushApplication : Starting PushApplication v0.1.2 on VM-4-13-centos with PID 31163 (/home/renjianbo/push/push_server-master/target/push-0.1.2.jar started by renjianbo in /home/renjianbo/push/push_server) +2025-12-31 16:18:32.567 INFO 31163 --- [ main] cn.wildfirechat.push.PushApplication : No active profile set, falling back to default profiles: default +2025-12-31 16:18:32.700 INFO 31163 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3ada9e37: startup date [Wed Dec 31 16:18:32 CST 2025]; root of context hierarchy +2025-12-31 16:18:35.574 INFO 31163 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) +2025-12-31 16:18:35.660 INFO 31163 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] +2025-12-31 16:18:35.660 INFO 31163 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34 +2025-12-31 16:18:35.719 INFO 31163 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib] +2025-12-31 16:18:35.958 INFO 31163 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext +2025-12-31 16:18:35.959 INFO 31163 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3263 ms +2025-12-31 16:18:36.110 INFO 31163 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/] +2025-12-31 16:18:36.116 INFO 31163 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] +2025-12-31 16:18:36.116 INFO 31163 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] +2025-12-31 16:18:36.117 INFO 31163 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] +2025-12-31 16:18:36.117 INFO 31163 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] +2025-12-31 16:18:36.331 INFO 31163 --- [ main] c.w.push.android.oppo.OppoPush : OppoPush init start, appKey: bb0819c889ae40cd8bde5a8ad4e670fe, appSecret: 9b5a0e6d56..., appServerSecret: 2d8b4e922d... +2025-12-31 16:18:37.143 INFO 31163 --- [ main] c.w.push.android.oppo.OppoPush : OppoPush init success, using secret: appServerSecret +2025-12-31 16:18:37.511 ERROR 31163 --- [ main] cn.wildfirechat.push.ios.ApnsServer : ApnsServer init failed java.security.InvalidKeyException: java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException : null at com.turo.pushy.apns.auth.ApnsSigningKey.loadFromInputStream(ApnsSigningKey.java:165) at com.turo.pushy.apns.auth.ApnsSigningKey.loadFromPkcs8File(ApnsSigningKey.java:107) @@ -105,27 +105,22 @@ Caused by: java.security.InvalidKeyException: IOException : null at sun.security.ec.ECKeyFactory.implGeneratePrivate(ECKeyFactory.java:237) at sun.security.ec.ECKeyFactory.engineGeneratePrivate(ECKeyFactory.java:165) ... 63 more -2025-12-31 09:59:11.489 INFO 24833 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] -2025-12-31 09:59:11.858 INFO 24833 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2a3046da: startup date [Wed Dec 31 09:59:06 CST 2025]; root of context hierarchy -2025-12-31 09:59:12.017 INFO 24833 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/android/push],methods=[POST],produces=[application/json;charset=UTF-8]}" onto public java.lang.Object cn.wildfirechat.push.PushController.androidPush(cn.wildfirechat.push.PushMessage) -2025-12-31 09:59:12.019 INFO 24833 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/ios/push],methods=[POST],produces=[application/json;charset=UTF-8]}" onto public java.lang.Object cn.wildfirechat.push.PushController.iOSPush(cn.wildfirechat.push.PushMessage) -2025-12-31 09:59:12.019 INFO 24833 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/harmony/push],methods=[POST],produces=[application/json;charset=UTF-8]}" onto public java.lang.Object cn.wildfirechat.push.PushController.hmPush(cn.wildfirechat.push.PushMessage) -2025-12-31 09:59:12.024 INFO 24833 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) -2025-12-31 09:59:12.024 INFO 24833 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest) -2025-12-31 09:59:12.103 INFO 24833 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] -2025-12-31 09:59:12.104 INFO 24833 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] -2025-12-31 09:59:12.605 INFO 24833 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup -2025-12-31 09:59:12.669 INFO 24833 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' -2025-12-31 09:59:12.677 INFO 24833 --- [ main] cn.wildfirechat.push.PushApplication : Started PushApplication in 7.306 seconds (JVM running for 8.144) -2025-12-31 09:59:22.368 INFO 24833 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started -2025-12-31 09:59:22.389 INFO 24833 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 21 ms -2025-12-31 09:59:22.520 INFO 24833 --- [nio-8080-exec-1] c.w.push.android.AndroidPushServiceImpl : Android push {"sender":"test_user","senderName":"测试用户","convType":0,"target":"test_target","targetName":"测试目标","line":0,"cntType":1,"serverTime":1767146362000,"pushMessageType":0,"pushType":5,"pushContent":"这是一条测试推送消息 - 2025-12-31 09:59:22","unReceivedMsg":1,"mentionedType":0,"packageName":"com.xunpaisoft.social","deviceToken":"OPPO_CN_95ac9afc103d70bb26441ec0cbb06b97","isHiddenDetail":false,"language":"zh","messageId":1767146362,"callStartUid":0,"republish":false,"existBadgeNumber":0} -2025-12-31 09:59:22.626 INFO 24833 --- [pool-2-thread-1] c.w.push.android.oppo.OppoPush : Server response: MessageId: 32150237-1-1-6954837a1acc0c0174ca3d27 ErrorCode: ReturnCode{code=0, message='Success'} Reason: OK -2025-12-31 10:01:28.214 INFO 24833 --- [nio-8080-exec-2] c.w.push.android.AndroidPushServiceImpl : Android push {"sender":"test_user","senderName":"测试用户","convType":0,"target":"test_target","targetName":"测试目标","line":0,"cntType":1,"serverTime":1767146488000,"pushMessageType":0,"pushType":5,"pushContent":"这是一条测试推送消息 - 2025-12-31 10:01:28","unReceivedMsg":1,"mentionedType":0,"packageName":"com.xunpaisoft.social","deviceToken":"OPPO_CN_95ac9afc103d70bb26441ec0cbb06b97","isHiddenDetail":false,"language":"zh","messageId":1767146488,"callStartUid":0,"republish":false,"existBadgeNumber":0} -2025-12-31 10:01:28.409 INFO 24833 --- [pool-2-thread-2] c.w.push.android.oppo.OppoPush : Server response: MessageId: 32150237-1-1-695483f82b1dd801763a31a4 ErrorCode: ReturnCode{code=0, message='Success'} Reason: OK -2025-12-31 10:03:30.832 INFO 24833 --- [nio-8080-exec-4] c.w.push.android.AndroidPushServiceImpl : Android push {"sender":"test_user","senderName":"测试用户","convType":0,"target":"test_target","targetName":"测试目标","line":0,"cntType":1,"serverTime":1767146610000,"pushMessageType":0,"pushType":5,"pushContent":"这是一条测试推送消息 - 2025-12-31 10:03:30","unReceivedMsg":1,"mentionedType":0,"packageName":"com.xunpaisoft.social","deviceToken":"OPPO_CN_95ac9afc103d70bb26441ec0cbb06b97","isHiddenDetail":false,"language":"zh","messageId":1767146610,"callStartUid":0,"republish":false,"existBadgeNumber":0} -2025-12-31 10:03:30.961 INFO 24833 --- [pool-2-thread-2] c.w.push.android.oppo.OppoPush : Server response: MessageId: 32150237-1-1-6954847239320c018f12aacb ErrorCode: ReturnCode{code=0, message='Success'} Reason: OK -2025-12-31 10:07:06.868 INFO 24833 --- [nio-8080-exec-6] c.w.push.android.AndroidPushServiceImpl : Android push {"sender":"api_user","senderName":"知你","convType":0,"target":"test_target","targetName":"测试目标","line":0,"cntType":1,"serverTime":1767146826000,"pushMessageType":0,"pushType":5,"pushContent":"我是api","unReceivedMsg":1,"mentionedType":0,"packageName":"com.xunpaisoft.social","deviceToken":"OPPO_CN_95ac9afc103d70bb26441ec0cbb06b97","isHiddenDetail":false,"language":"zh","messageId":1767146826,"callStartUid":0,"republish":false,"existBadgeNumber":0} -2025-12-31 10:07:07.002 INFO 24833 --- [pool-2-thread-2] c.w.push.android.oppo.OppoPush : Server response: MessageId: 32150237-1-1-6954854a35f9ec01757142d9 ErrorCode: ReturnCode{code=0, message='Success'} Reason: OK -2025-12-31 10:07:55.122 INFO 24833 --- [nio-8080-exec-8] c.w.push.android.AndroidPushServiceImpl : Android push {"sender":"api_user","senderName":"知你","convType":0,"target":"test_target","targetName":"测试目标","line":0,"cntType":1,"serverTime":1767146875000,"pushMessageType":0,"pushType":5,"pushContent":"我是api","unReceivedMsg":1,"mentionedType":0,"packageName":"com.xunpaisoft.social","deviceToken":"OPPO_CN_95ac9afc103d70bb26441ec0cbb06b97","isHiddenDetail":false,"language":"zh","messageId":1767146875,"callStartUid":0,"republish":false,"existBadgeNumber":0} -2025-12-31 10:07:55.249 INFO 24833 --- [pool-2-thread-2] c.w.push.android.oppo.OppoPush : Server response: MessageId: 32150237-1-1-6954857b816b510175dc87a7 ErrorCode: ReturnCode{code=0, message='Success'} Reason: OK +2025-12-31 16:18:37.687 INFO 31163 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] +2025-12-31 16:18:38.094 INFO 31163 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3ada9e37: startup date [Wed Dec 31 16:18:32 CST 2025]; root of context hierarchy +2025-12-31 16:18:38.274 INFO 31163 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/android/push],methods=[POST],produces=[application/json;charset=UTF-8]}" onto public java.lang.Object cn.wildfirechat.push.PushController.androidPush(cn.wildfirechat.push.PushMessage) +2025-12-31 16:18:38.276 INFO 31163 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/ios/push],methods=[POST],produces=[application/json;charset=UTF-8]}" onto public java.lang.Object cn.wildfirechat.push.PushController.iOSPush(cn.wildfirechat.push.PushMessage) +2025-12-31 16:18:38.276 INFO 31163 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/harmony/push],methods=[POST],produces=[application/json;charset=UTF-8]}" onto public java.lang.Object cn.wildfirechat.push.PushController.hmPush(cn.wildfirechat.push.PushMessage) +2025-12-31 16:18:38.280 INFO 31163 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) +2025-12-31 16:18:38.280 INFO 31163 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest) +2025-12-31 16:18:38.338 INFO 31163 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] +2025-12-31 16:18:38.338 INFO 31163 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] +2025-12-31 16:18:38.814 INFO 31163 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup +2025-12-31 16:18:38.864 INFO 31163 --- [ main] ConditionEvaluationReportLoggingListener : + +Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. +2025-12-31 16:18:38.867 ERROR 31163 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : + +*******2025-12-31 16:19:19.465 INFO 29953 --- [ Thread-5] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@567d299b: startup date [Wed Dec 31 16:18:07 CST 2025]; root of context hierarchy +2025-12-31 16:19:19.467 INFO 29953 --- [ Thread-5] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown +31163 --- [ main] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3ada9e37: startup date [Wed Dec 31 16:18:32 CST 2025]; root of context hierarchy +2025-12-31 16:18:38.874 INFO 31163 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown diff --git a/test_honor_push.sh b/test_honor_push.sh new file mode 100755 index 0000000..fa763bb --- /dev/null +++ b/test_honor_push.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# 荣耀推送测试脚本 (使用8080端口) +# 使用方法: ./test_honor_push.sh +# device_token: 荣耀手机的push token,需要从荣耀手机应用中获取 + +if [ -z "$1" ]; then + echo "==========================================" + echo "荣耀推送测试脚本 (端口: 8080)" + echo "==========================================" + echo "" + echo "使用方法: $0 " + echo "" + echo "device_token: 荣耀手机的push token" + echo " (需要从荣耀手机应用中获取)" + echo "" + echo "示例: $0 your_honor_push_token" + echo "" + echo "如果没有device_token,请:" + echo "1. 在荣耀手机上安装应用 (包名: com.xunpaisoft.social)" + echo "2. 启动应用并查看日志获取push token" + echo "3. 或者从荣耀推送平台查看设备列表" + exit 1 +fi + +DEVICE_TOKEN=$1 +SERVER_URL="http://localhost:8080/android/push" + +echo "==========================================" +echo "正在测试荣耀推送..." +echo "==========================================" +echo "设备Token: $DEVICE_TOKEN" +echo "服务器地址: $SERVER_URL" +echo "包名: com.xunpaisoft.social" +echo "" + +# 构建推送消息JSON +# pushType=8 表示 荣耀推送类型 (AndroidPushType.ANDROID_PUSH_TYPE_HONOR = 8) +TIMESTAMP=$(date +%s) +MESSAGE_ID=$TIMESTAMP + +RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST "$SERVER_URL" \ + -H "Content-Type: application/json;charset=UTF-8" \ + -d "{ + \"pushType\": 8, + \"pushMessageType\": 0, + \"packageName\": \"com.xunpaisoft.social\", + \"deviceToken\": \"$DEVICE_TOKEN\", + \"pushContent\": \"这是一条测试推送消息 - $(date '+%Y-%m-%d %H:%M:%S')\", + \"sender\": \"test_user\", + \"senderName\": \"测试用户\", + \"target\": \"test_target\", + \"targetName\": \"测试目标\", + \"convType\": 0, + \"line\": 0, + \"cntType\": 1, + \"serverTime\": ${TIMESTAMP}000, + \"unReceivedMsg\": 1, + \"mentionedType\": 0, + \"isHiddenDetail\": false, + \"language\": \"zh\", + \"messageId\": $MESSAGE_ID, + \"republish\": false, + \"existBadgeNumber\": 0 + }") + +HTTP_CODE=$(echo "$RESPONSE" | grep "HTTP_CODE:" | cut -d: -f2) +BODY=$(echo "$RESPONSE" | sed '/HTTP_CODE:/d') + +echo "----------------------------------------" +echo "服务器响应:" +echo "----------------------------------------" +echo "$BODY" | python -m json.tool 2>/dev/null || echo "$BODY" +echo "" +echo "HTTP状态码: $HTTP_CODE" +echo "" + +if [ "$HTTP_CODE" = "200" ]; then + echo "✓ 推送请求已发送成功!" + echo "" + echo "请检查:" + echo "1. 荣耀手机是否收到推送通知" + echo "2. 查看服务器日志了解详细推送结果" +else + echo "✗ 推送请求失败 (HTTP $HTTP_CODE)" + echo "" + echo "请检查:" + echo "1. 服务器是否正常运行在8080端口" + echo "2. device_token 是否正确" + echo "3. 查看服务器日志: tail -f push.log 或查看控制台输出" +fi + +echo "" +echo "==========================================" + diff --git a/test_vivo_push.sh b/test_vivo_push.sh new file mode 100755 index 0000000..3f693c0 --- /dev/null +++ b/test_vivo_push.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# Vivo推送测试脚本 (使用8080端口) +# 使用方法: ./test_vivo_push.sh +# reg_id: Vivo手机的registration_id,格式为 v2-xxx + +if [ -z "$1" ]; then + echo "==========================================" + echo "Vivo推送测试脚本 (端口: 8080)" + echo "==========================================" + echo "" + echo "使用方法: $0 " + echo "" + echo "reg_id: Vivo手机的registration_id" + echo " (格式: v2-xxx,需要从Vivo手机应用中获取)" + echo "" + echo "示例: $0 v2-CRujhn6Z8OU26yX4_EeUtGmiR6nJ21CXJmoFRMstHinrLqU9vH3u8g4OQQ" + echo "" + echo "如果没有reg_id,请:" + echo "1. 在Vivo手机上安装应用 (包名: com.xunpaisoft.social)" + echo "2. 启动应用并查看日志获取reg_id" + echo "3. 或者从Vivo推送平台查看设备列表" + exit 1 +fi + +REG_ID=$1 +SERVER_URL="http://localhost:8080/android/push" + +echo "==========================================" +echo "正在测试Vivo推送..." +echo "==========================================" +echo "设备RegId: $REG_ID" +echo "服务器地址: $SERVER_URL" +echo "包名: com.xunpaisoft.social" +echo "" + +# 构建推送消息JSON +# pushType=4 表示 Vivo 推送类型 (AndroidPushType.ANDROID_PUSH_TYPE_VIVO = 4) +TIMESTAMP=$(date +%s) +MESSAGE_ID=$TIMESTAMP + +RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST "$SERVER_URL" \ + -H "Content-Type: application/json;charset=UTF-8" \ + -d "{ + \"pushType\": 4, + \"pushMessageType\": 0, + \"packageName\": \"com.xunpaisoft.social\", + \"deviceToken\": \"$REG_ID\", + \"pushContent\": \"这是一条测试推送消息 - $(date '+%Y-%m-%d %H:%M:%S')\", + \"sender\": \"test_user\", + \"senderName\": \"测试用户\", + \"target\": \"test_target\", + \"targetName\": \"测试目标\", + \"convType\": 0, + \"line\": 0, + \"cntType\": 1, + \"serverTime\": ${TIMESTAMP}000, + \"unReceivedMsg\": 1, + \"mentionedType\": 0, + \"isHiddenDetail\": false, + \"language\": \"zh\", + \"messageId\": $MESSAGE_ID, + \"republish\": false, + \"existBadgeNumber\": 0 + }") + +HTTP_CODE=$(echo "$RESPONSE" | grep "HTTP_CODE:" | cut -d: -f2) +BODY=$(echo "$RESPONSE" | sed '/HTTP_CODE:/d') + +echo "----------------------------------------" +echo "服务器响应:" +echo "----------------------------------------" +echo "$BODY" | python -m json.tool 2>/dev/null || echo "$BODY" +echo "" +echo "HTTP状态码: $HTTP_CODE" +echo "" + +if [ "$HTTP_CODE" = "200" ]; then + echo "✓ 推送请求已发送成功!" + echo "" + echo "请检查:" + echo "1. Vivo手机是否收到推送通知" + echo "2. 查看服务器日志了解详细推送结果" +else + echo "✗ 推送请求失败 (HTTP $HTTP_CODE)" + echo "" + echo "请检查:" + echo "1. 服务器是否正常运行在8080端口" + echo "2. reg_id 是否正确" + echo "3. 查看服务器日志: tail -f push.log 或查看控制台输出" +fi + +echo "" +echo "==========================================" +