add oppo vivo fcm push
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
target
|
||||
.idea
|
||||
push.iml
|
||||
|
||||
1
config/fcm.properties
Normal file
1
config/fcm.properties
Normal file
@@ -0,0 +1 @@
|
||||
fcm.credentialsPath=fcm/wildfirechat-4753c-firebase-adminsdk-1s9fh-bc026cc369.json
|
||||
2
config/oppo.properties
Normal file
2
config/oppo.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
oppo.AppKey=16c6afe503b24259928e082ef01a6bf2
|
||||
oppo.AppSecret=2114e4067de4424fbfc0638e311ce88c
|
||||
3
config/vivo.properties
Normal file
3
config/vivo.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
vivo.appSecret=d0f24e5b-e92b-4b95-8d45-927bec3ba512
|
||||
vivo.appId=12918
|
||||
vivo.appKey=c42feb05-de6c-427d-af55-4f902d9e0a75
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "wildfirechat-4753c",
|
||||
"private_key_id": "bc026cc369dbceee7ea84cfafa25e9d617c37a55",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADxyBgkqzziG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC8FleZOk5Yd8Z7\nd+LJ0vfSTZWXLHxXZcp53vnX3yLlO20X/mAvgELvZJEHHCDTYhb67+O+EJUCrGWv\nXrdqTJf31sO/IxB1pdFZVomsT+04WUZaEUTFD7kdRKHVn89HIAZRqxh3tv9gdfuc\nRfh4JE8XC3krCFKz+OSzbq2tO8kEdwOOljT/3tU9BUbQ9uKd5stamTafzBuQ5lQ8\n/0jGcjpcOigpuT3nnpDmIyXKOGhnA2euVFxaRzyoEFoloatG/qhPqGlDUFy8jJLJ\n5TERbFHpJmGxFLu+apYQ8MaM8zIMNxQtq4f+e/M7szpwmtrxJYrodNamImODWr5t\nsrhrXM2NAgMBAAECggEAA71Hh5CCW69a0MpeqWX99hrKqNiXg5fAbfFK+jRza4rz\n28s0YjuZ2RLn0+X4UcRuTmsz+WvF+b7MP2hgKerNzf2MIxAtyjSMd66B7hYE7tex\nwVCLIb8rqrboblMdUyFJXRjacBEWma8uzeufwmF+3NImL2JyCEKDytIeNpv7EGaS\nEPEtOfkyvgSK6FfG7K+Tahgu4BVCLkk41Jz8ZBpdqMuUvDBdF1MLb506XtNSsGrd\nBQstyB3emGxXsWfKEmKlZ5bqs7RC0UCF74YCNZ1iUegghJzF/5sSbQBtEsEaE3LP\n4BJ+nKWdRY0ddNvxrRg72bBqvm6L8KaviXHK4L9jxwKBgQD/OdjRdh8tKYI0tF7i\nqy5bHlGiWcvrmartq0Y4+gPoBaLdCKLoDDoNRp3KYyGJAvnSMb0Run74BOLwGxhP\nEGFQrUYUqDEaqyfMBfB6MA3LLmoWi8DFL0yPLeavQEesSnf6k5ZyeBWMw+MfBtIR\nqYssEtt70XWQKD8OAsRjCtSlzwKBgQC8qF6yapbEwJjL1rWjJDBvHxKRnMNehbVp\nl6oKjXa9j9Eu3BqiuCnkBNxHn9KVLE3DZLwGBypgzqenw1EVqkwhBY2j6miEsXpq\n6eixwjK8RGPF611AkVSITssHVqJX279MYac6Qqs6LGBt+5RlZU+LgS5XjZdY7A/7\ny8jXUU6J4wKBgFvJYPlLYsDqKaJsr6cS6vPn/nHFm3maZQdeTj3VZCxAQqb9ISEU\nrJfzqnGLnxbYFCIMszM5/8mQcFDrXZ2phWXvOsHZDvfJT+GmzSoUOBG3Gn4LOoNv\nlDf1yP2Dv4LtsSJTi4qVNyLNm9Ofr1Kcx6lNCtQHqyDx6GNQiXIZBgqvAoGAQOJ3\nj01xhUHoS1MRLYbo0Y8SR9pupze9aQ+sf+yfhhrMix1QW96TKcUyLcAeIQgXxrgC\nouAcByeMKfrXDGiBvmm2iUW5pMmVnOfODDUKVg3/cra8X9ScCjVvRprZQvZlGNQN\nO9BqK5vPnoQESctKTGSll58vCnpGFQfFj6h7JpkCgYEA1xX7JZuaQCo4121wr+3T\nwfa0M8875ApO+c/Rii6y40YIfdwvbHadAIJHmFgM3V+R7ps3K+aBwBFUdT8rSsek\nMctsBYGvZyU7Or2zkTY3+GO2ZCx1Sg0IpUmWULKkbqaRQgHuW4SGyxJYNUCNKo8U\n69+k0zzdIxX0TUiqk4enbOA=\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "firebase-adminsdk-1s9fh@wildfirechat-4753c.iam.gserviceaccount.com",
|
||||
"client_id": "114736707742305810886",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-1s9fh%40wildfirechat-4753c.iam.gserviceaccount.com"
|
||||
}
|
||||
351
pom.xml
351
pom.xml
@@ -1,144 +1,212 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<artifactId>push</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<packaging>jar</packaging>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<artifactId>push</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>push</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<name>push</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.10.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.0.6.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.xiaomi.push</groupId>
|
||||
<artifactId>mipush-sdk-server</artifactId>
|
||||
<version>2.2.18</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/libs/MiPush_SDK_Server_2_2_19.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiaomi.push</groupId>
|
||||
<artifactId>mipush-sdk-server</artifactId>
|
||||
<version>2.2.18</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/libs/MiPush_SDK_Server_2_2_19.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.meizu.flyme</groupId>
|
||||
<artifactId>push-server-sdk</artifactId>
|
||||
<version>1.2.7.20180307_release</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.oppo.push</groupId>
|
||||
<artifactId>opush-server</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/libs/opush-server-sdk-1.0.4.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.meizu.flyme</groupId>
|
||||
<artifactId>push-server-sdk</artifactId>
|
||||
<version>1.2.7.20180307_release</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
<!--vivo push-->
|
||||
<dependency>
|
||||
<groupId>com.vivo.push.sdk</groupId>
|
||||
<artifactId>vPush-server-sdk</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/libs/vPush-server-sdk-1.0.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>uk.org.lidalia</groupId>
|
||||
<artifactId>slf4j-test</artifactId>
|
||||
<version>1.0.0-jdk6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.commons.codec</groupId>-->
|
||||
<!-- <artifactId>commons-codec</artifactId>-->
|
||||
<!-- <version>1.9</version>-->
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>${project.basedir}/src/main/libs/commons-codec-1.9.jar-->
|
||||
<!-- </systemPath>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.commons.logging</groupId>-->
|
||||
<!-- <artifactId>commons-logging</artifactId>-->
|
||||
<!-- <version>1.2</version>-->
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>${project.basedir}/src/main/libs/commons-logging-1.2.jar-->
|
||||
<!-- </systemPath>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba.fastjson</groupId>-->
|
||||
<!-- <artifactId>fastjson</artifactId>-->
|
||||
<!-- <version>1.2.28</version>-->
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>${project.basedir}/src/main/libs/fastjson-1.2.28.jar-->
|
||||
<!-- </systemPath>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.http</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/libs/httpclient-4.5.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.http</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.4.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/libs/httpcore-4.4.1.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!--vivo push end-->
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>[2.9.10.3,)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>[2.9.10.3,)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>[2.9.10.3,)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>uk.org.lidalia</groupId>
|
||||
<artifactId>slf4j-test</artifactId>
|
||||
<version>1.0.0-jdk6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.turo</groupId>
|
||||
<artifactId>pushy</artifactId>
|
||||
<version>0.13.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.9.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.9.8</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.turo</groupId>
|
||||
<artifactId>pushy</artifactId>
|
||||
<version>0.13.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.turo</groupId>
|
||||
@@ -146,7 +214,20 @@
|
||||
<version>0.13.10</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.google.firebase</groupId>
|
||||
<artifactId>firebase-admin</artifactId>
|
||||
<version>7.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>30.0-jre</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.netty</groupId>-->
|
||||
<!-- <artifactId>netty-tcnative-boringssl-static</artifactId>-->
|
||||
<!-- <version>2.0.25.Final</version>-->
|
||||
@@ -154,17 +235,23 @@
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/libs</directory>
|
||||
<targetPath>BOOT-INF/lib/</targetPath>
|
||||
<includes>
|
||||
<include>**/*.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
111
push.iml
111
push.iml
@@ -1,111 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.0.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.0.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.0.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.34" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.34" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.34" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.13.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.0.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.0.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.0.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.0.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.0.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.0.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.9.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:2.15.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.7.11" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.7.11" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.0.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.5.1" level="project" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="Maven: com.xiaomi.push:mipush-sdk-server:2.2.18">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/src/main/libs/MiPush_SDK_Server_2_2_19.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="library" name="Maven: com.meizu.flyme:push-server-sdk:1.2.7.20180307_release" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.1.28" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.7.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: uk.org.lidalia:slf4j-test:1.0.0-jdk6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: uk.org.lidalia:lidalia-lang:1.0.0-jdk6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.google.guava:guava:14.0.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: uk.org.lidalia:lidalia-slf4j-ext:1.0.0-jdk6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: joda-time:joda-time:2.9.9" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:2.0.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-all:1.9.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.turo:pushy:0.13.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec-http2:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec-http:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-handler-proxy:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec-socks:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver-dns:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec-dns:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.eatthepath:fast-uuid:0.1" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,8 +1,11 @@
|
||||
package cn.wildfirechat.push.android;
|
||||
|
||||
import cn.wildfirechat.push.PushMessage;
|
||||
import cn.wildfirechat.push.android.fcm.FCMPush;
|
||||
import cn.wildfirechat.push.android.hms.HMSPush;
|
||||
import cn.wildfirechat.push.android.meizu.MeiZuPush;
|
||||
import cn.wildfirechat.push.android.oppo.OppoPush;
|
||||
import cn.wildfirechat.push.android.vivo.VivoPush;
|
||||
import cn.wildfirechat.push.android.xiaomi.XiaomiPush;
|
||||
import com.google.gson.Gson;
|
||||
import org.slf4j.Logger;
|
||||
@@ -22,6 +25,14 @@ public class AndroidPushServiceImpl implements AndroidPushService {
|
||||
@Autowired
|
||||
private XiaomiPush xiaomiPush;
|
||||
|
||||
@Autowired
|
||||
private VivoPush vivoPush;
|
||||
|
||||
@Autowired
|
||||
private OppoPush oppoPush;
|
||||
|
||||
@Autowired
|
||||
private FCMPush fcmPush;
|
||||
|
||||
@Override
|
||||
public Object push(PushMessage pushMessage) {
|
||||
@@ -36,6 +47,15 @@ public class AndroidPushServiceImpl implements AndroidPushService {
|
||||
case AndroidPushType.ANDROID_PUSH_TYPE_MEIZU:
|
||||
meiZuPush.push(pushMessage);
|
||||
break;
|
||||
case AndroidPushType.ANDROID_PUSH_TYPE_VIVO:
|
||||
vivoPush.push(pushMessage);
|
||||
break;
|
||||
case AndroidPushType.ANDROID_PUSH_TYPE_OPPO:
|
||||
oppoPush.push(pushMessage);
|
||||
break;
|
||||
case AndroidPushType.ANDROID_PUSH_TYPE_FCM:
|
||||
fcmPush.push(pushMessage);
|
||||
break;
|
||||
default:
|
||||
LOG.info("unknown push type");
|
||||
break;
|
||||
|
||||
@@ -4,4 +4,7 @@ public interface AndroidPushType {
|
||||
int ANDROID_PUSH_TYPE_XIAOMI = 1;
|
||||
int ANDROID_PUSH_TYPE_HUAWEI = 2;
|
||||
int ANDROID_PUSH_TYPE_MEIZU = 3;
|
||||
int ANDROID_PUSH_TYPE_VIVO = 4;
|
||||
int ANDROID_PUSH_TYPE_OPPO = 5;
|
||||
int ANDROID_PUSH_TYPE_FCM = 6;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.wildfirechat.push.android.fcm;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix="fcm")
|
||||
@PropertySource(value = "file:config/fcm.properties")
|
||||
public class FCMConfig {
|
||||
private String credentialsPath;
|
||||
|
||||
public String getCredentialsPath() {
|
||||
return credentialsPath;
|
||||
}
|
||||
|
||||
public void setCredentialsPath(String credentialsPath) {
|
||||
this.credentialsPath = credentialsPath;
|
||||
}
|
||||
}
|
||||
53
src/main/java/cn/wildfirechat/push/android/fcm/FCMPush.java
Normal file
53
src/main/java/cn/wildfirechat/push/android/fcm/FCMPush.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package cn.wildfirechat.push.android.fcm;
|
||||
|
||||
import cn.wildfirechat.push.PushMessage;
|
||||
import cn.wildfirechat.push.PushMessageType;
|
||||
import com.google.auth.oauth2.GoogleCredentials;
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.FirebaseOptions;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import com.google.firebase.messaging.FirebaseMessagingException;
|
||||
import com.google.firebase.messaging.Message;
|
||||
import com.google.firebase.messaging.Notification;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
@Component
|
||||
public class FCMPush {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FCMPush.class);
|
||||
@Autowired
|
||||
private FCMConfig mConfig;
|
||||
|
||||
@PostConstruct
|
||||
private void init() throws Exception {
|
||||
FileInputStream refreshToken = new FileInputStream(mConfig.getCredentialsPath());
|
||||
FirebaseOptions options = FirebaseOptions.builder()
|
||||
.setCredentials(GoogleCredentials.fromStream(refreshToken))
|
||||
.setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
|
||||
.build();
|
||||
FirebaseApp.initializeApp(options);
|
||||
}
|
||||
|
||||
|
||||
public void push(PushMessage pushMessage) {
|
||||
Notification.Builder builder = Notification.builder().setTitle(pushMessage.senderName).setBody(pushMessage.pushContent);
|
||||
Message message = Message.builder()
|
||||
.setNotification(builder.build())
|
||||
.setToken(pushMessage.deviceToken)
|
||||
.build();
|
||||
|
||||
try {
|
||||
// Send a message to the device corresponding to the provided
|
||||
// registration token.
|
||||
String response = FirebaseMessaging.getInstance().send(message);
|
||||
// Response is a message ID string.
|
||||
System.out.println("Successfully sent message: " + response);
|
||||
} catch (FirebaseMessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.wildfirechat.push.android.oppo;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "oppo")
|
||||
@PropertySource(value = "file:config/oppo.properties")
|
||||
public class OppoConfig {
|
||||
private String appSecret;
|
||||
private String appKey;
|
||||
|
||||
public String getAppSecret() {
|
||||
return appSecret;
|
||||
}
|
||||
|
||||
public void setAppSecret(String appSecret) {
|
||||
this.appSecret = appSecret;
|
||||
}
|
||||
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
}
|
||||
147
src/main/java/cn/wildfirechat/push/android/oppo/OppoPush.java
Normal file
147
src/main/java/cn/wildfirechat/push/android/oppo/OppoPush.java
Normal file
@@ -0,0 +1,147 @@
|
||||
package cn.wildfirechat.push.android.oppo;
|
||||
|
||||
import cn.wildfirechat.push.PushMessage;
|
||||
import cn.wildfirechat.push.PushMessageType;
|
||||
import com.oppo.push.server.Notification;
|
||||
import com.oppo.push.server.Result;
|
||||
import com.oppo.push.server.Sender;
|
||||
import com.oppo.push.server.Target;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Component
|
||||
public class OppoPush {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(OppoPush.class);
|
||||
|
||||
@Autowired
|
||||
OppoConfig mConfig;
|
||||
|
||||
private Sender mSender;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
try {
|
||||
mSender = new Sender(mConfig.getAppKey(), mConfig.getAppSecret());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void push(PushMessage pushMessage) {
|
||||
if (mSender == null) {
|
||||
LOG.error("Oppo push message can't sent, because not initial correctly");
|
||||
}
|
||||
Result result = null;
|
||||
try {
|
||||
Notification notification = getNotification(pushMessage); //创建通知栏消息体
|
||||
|
||||
Target target = Target.build(pushMessage.deviceToken); //创建发送对象
|
||||
|
||||
result = mSender.unicastNotification(notification, target); //发送单推消息
|
||||
|
||||
result.getStatusCode(); // 获取http请求状态码
|
||||
|
||||
result.getReturnCode(); // 获取平台返回码
|
||||
|
||||
result.getMessageId(); // 获取平台返回的messageId
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOG.error("sendSingle error " + e.getMessage());
|
||||
}
|
||||
if (result != null) {
|
||||
LOG.info("Server response: MessageId: " + result.getMessageId()
|
||||
+ " ErrorCode: " + result.getReturnCode()
|
||||
+ " Reason: " + result.getReason());
|
||||
}
|
||||
}
|
||||
|
||||
private Notification getNotification(PushMessage pushMessage) {
|
||||
if (pushMessage.isHiddenDetail) {
|
||||
pushMessage.pushContent = "您收到一条新消息";
|
||||
}
|
||||
Notification notification = new Notification();
|
||||
|
||||
|
||||
/**
|
||||
* 以下参数必填项
|
||||
*/
|
||||
String title;
|
||||
if (pushMessage.pushMessageType == PushMessageType.PUSH_MESSAGE_TYPE_FRIEND_REQUEST) {
|
||||
if (StringUtils.isEmpty(pushMessage.senderName)) {
|
||||
title = "好友请求";
|
||||
} else {
|
||||
title = pushMessage.senderName + " 请求加您为好友";
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.isEmpty(pushMessage.senderName)) {
|
||||
title = "消息";
|
||||
} else {
|
||||
title = pushMessage.senderName;
|
||||
}
|
||||
}
|
||||
|
||||
notification.setTitle(title);
|
||||
notification.setContent(pushMessage.pushContent);
|
||||
|
||||
/**
|
||||
* 以下参数非必填项, 如果需要使用可以参考OPPO push服务端api文档进行设置
|
||||
*/
|
||||
//通知栏样式 1. 标准样式 2. 长文本样式 3. 大图样式 【非必填,默认1-标准样式】
|
||||
notification.setStyle(1);
|
||||
|
||||
// App开发者自定义消息Id,OPPO推送平台根据此ID做去重处理,对于广播推送相同appMessageId只会保存一次,对于单推相同appMessageId只会推送一次
|
||||
//notification.setAppMessageId(UUID.randomUUID().toString());
|
||||
|
||||
// 应用接收消息到达回执的回调URL,字数限制200以内,中英文均以一个计算
|
||||
//notification.setCallBackUrl("http://www.test.com");
|
||||
|
||||
// App开发者自定义回执参数,字数限制50以内,中英文均以一个计算
|
||||
//notification.setCallBackParameter("");
|
||||
|
||||
// 点击动作类型0,启动应用;1,打开应用内页(activity的intent action);2,打开网页;4,打开应用内页(activity);【非必填,默认值为0】;5,Intent scheme URL
|
||||
//notification.setClickActionType(4);
|
||||
|
||||
// 应用内页地址【click_action_type为1或4时必填,长度500】
|
||||
//notification.setClickActionActivity("com.coloros.push.demo.component.InternalActivity");
|
||||
|
||||
// 网页地址【click_action_type为2必填,长度500】
|
||||
//notification.setClickActionUrl("http://www.test.com");
|
||||
|
||||
// 动作参数,打开应用内页或网页时传递给应用或网页【JSON格式,非必填】,字符数不能超过4K,示例:{"key1":"value1","key2":"value2"}
|
||||
//notification.setActionParameters("{\"key1\":\"value1\",\"key2\":\"value2\"}");
|
||||
|
||||
// 展示类型 (0, “即时”),(1, “定时”)
|
||||
notification.setShowTimeType(0);
|
||||
|
||||
// 定时展示开始时间(根据time_zone转换成当地时间),时间的毫秒数
|
||||
//notification.setShowStartTime(System.currentTimeMillis() + 1000 * 60 * 3);
|
||||
|
||||
// 定时展示结束时间(根据time_zone转换成当地时间),时间的毫秒数
|
||||
//notification.setShowEndTime(System.currentTimeMillis() + 1000 * 60 * 5);
|
||||
|
||||
// 是否进离线消息,【非必填,默认为True】
|
||||
//notification.setOffLine(true);
|
||||
|
||||
// 离线消息的存活时间(time_to_live) (单位:秒), 【off_line值为true时,必填,最长3天】
|
||||
if (pushMessage.pushMessageType != PushMessageType.PUSH_MESSAGE_TYPE_NORMAL) {
|
||||
notification.setOffLineTtl(60); // 单位秒
|
||||
} else {
|
||||
notification.setOffLineTtl(10 * 60);
|
||||
}
|
||||
|
||||
// 时区,默认值:(GMT+08:00)北京,香港,新加坡
|
||||
//notification.setTimeZone("GMT+08:00");
|
||||
|
||||
// 0:不限联网方式, 1:仅wifi推送
|
||||
notification.setNetworkType(0);
|
||||
|
||||
return notification;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.wildfirechat.push.android.vivo;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "vivo")
|
||||
@PropertySource(value = "file:config/vivo.properties")
|
||||
public class VivoConfig {
|
||||
private String appSecret;
|
||||
private int appId;
|
||||
private String appKey;
|
||||
|
||||
public String getAppSecret() {
|
||||
return appSecret;
|
||||
}
|
||||
|
||||
public void setAppSecret(String appSecret) {
|
||||
this.appSecret = appSecret;
|
||||
}
|
||||
|
||||
public int getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(int appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.wildfirechat.push.android.vivo;
|
||||
|
||||
import cn.wildfirechat.push.PushMessage;
|
||||
import cn.wildfirechat.push.PushMessageType;
|
||||
import com.vivo.push.sdk.notofication.Message;
|
||||
import com.vivo.push.sdk.notofication.Result;
|
||||
import com.vivo.push.sdk.server.Sender;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class VivoPush {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(VivoPush.class);
|
||||
private long tokenExpiredTime;
|
||||
|
||||
@Autowired
|
||||
VivoConfig mConfig;
|
||||
|
||||
private String authToken;
|
||||
|
||||
private void refreshToken() {
|
||||
Sender sender = null;//注册登录开发平台网站获取到的appSecret
|
||||
try {
|
||||
sender = new Sender(mConfig.getAppSecret());
|
||||
Result result = sender.getToken(mConfig.getAppId(), mConfig.getAppKey());//注册登录开发平台网站获取到的appId和appKey
|
||||
authToken = result.getAuthToken();
|
||||
tokenExpiredTime = System.currentTimeMillis() + 12 * 60 * 60 * 1000;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOG.error("getToken error" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void push(PushMessage pushMessage) {
|
||||
if (tokenExpiredTime <= System.currentTimeMillis()) {
|
||||
refreshToken();
|
||||
}
|
||||
|
||||
Result resultMessage = null;
|
||||
try {
|
||||
if (pushMessage.isHiddenDetail) {
|
||||
pushMessage.pushContent = "您收到一条新消息";
|
||||
}
|
||||
String title;
|
||||
if (pushMessage.pushMessageType == PushMessageType.PUSH_MESSAGE_TYPE_FRIEND_REQUEST) {
|
||||
if (StringUtils.isEmpty(pushMessage.senderName)) {
|
||||
title = "好友请求";
|
||||
} else {
|
||||
title = pushMessage.senderName + " 请求加您为好友";
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.isEmpty(pushMessage.senderName)) {
|
||||
title = "消息";
|
||||
} else {
|
||||
title = pushMessage.senderName;
|
||||
}
|
||||
}
|
||||
Sender senderMessage = new Sender(mConfig.getAppSecret(), authToken);
|
||||
Message.Builder builder = new Message.Builder()
|
||||
.regId(pushMessage.getDeviceToken())//该测试手机设备订阅推送后生成的regId
|
||||
.notifyType(3)
|
||||
.title(title)
|
||||
.content(pushMessage.pushContent)
|
||||
.timeToLive(1000)
|
||||
.skipType(1)
|
||||
.networkType(-1)
|
||||
.requestId(System.currentTimeMillis() + "");
|
||||
if (pushMessage.pushMessageType != PushMessageType.PUSH_MESSAGE_TYPE_NORMAL) {
|
||||
builder.timeToLive(60); // 单位秒
|
||||
} else {
|
||||
builder.timeToLive(10 * 60);
|
||||
}
|
||||
resultMessage = senderMessage.sendSingle(builder.build());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOG.error("sendSingle error " + e.getMessage());
|
||||
}
|
||||
if (resultMessage != null) {
|
||||
|
||||
LOG.info("Server response: MessageId: " + resultMessage.getTaskId()
|
||||
+ " ErrorCode: " + resultMessage.getResult()
|
||||
+ " Reason: " + resultMessage.getDesc());
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
src/main/libs/httpclient-4.5.jar
Normal file
BIN
src/main/libs/httpclient-4.5.jar
Normal file
Binary file not shown.
BIN
src/main/libs/httpcore-4.4.1.jar
Normal file
BIN
src/main/libs/httpcore-4.4.1.jar
Normal file
Binary file not shown.
BIN
src/main/libs/opush-server-sdk-1.0.4.jar
Normal file
BIN
src/main/libs/opush-server-sdk-1.0.4.jar
Normal file
Binary file not shown.
BIN
src/main/libs/vPush-server-sdk-1.0.jar
Executable file
BIN
src/main/libs/vPush-server-sdk-1.0.jar
Executable file
Binary file not shown.
Reference in New Issue
Block a user