1
0

Push service release version 4

This commit is contained in:
2020-12-25 01:10:32 +01:00
parent 4c58aa3ed0
commit 02fa209012
7 changed files with 43 additions and 29 deletions

View File

@@ -7,7 +7,7 @@
<parent>
<artifactId>push-service-parent</artifactId>
<groupId>de.77zzcx7.push-service</groupId>
<version>4-SNAPSHOT</version>
<version>4</version>
</parent>
<artifactId>push-service-client-lib</artifactId>
@@ -42,11 +42,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--
Setting the classifier of the spring-boot uber JAR to exec will keep the verbatim JAR file
as actual distributed artifact required for users to include the beans
-->
<classifier>exec</classifier>
<skip>true</skip>
</configuration>
</plugin>
</plugins>

View File

@@ -1,21 +0,0 @@
package de.pushservice.client;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* Not used but required by the spring boot maven plugin during repackage
*/
@SpringBootApplication
public class PushServiceClientApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(PushServiceClientApplication.class);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(PushServiceClientApplication.class);
}
}

View File

@@ -18,6 +18,7 @@ public class PayloadDto {
private String icon;
private int[] vibration;
private long timestamp;
private String tag;
public PayloadDto(String title) {
this.title = title;
@@ -67,4 +68,12 @@ public class PayloadDto {
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
}

View File

@@ -9,6 +9,27 @@ self.addEventListener('push', function(event) {
icon: payload.icon,
vibrate: payload.vibration,
timestamp: payload.timestamp,
tag: payload.tag
})
);
});
self.addEventListener('notificationclick', function(event) {
event.notification.close();
event.waitUntil(clients.matchAll({
type: "window"
}).then(function(clientList) {
for (var i = 0; i < clientList.length; i++) {
var client = clientList[i];
if (client.url.includes(new URL(self.registration.scope).pathname) && 'focus' in client) {
return client.focus();
}
}
if (clients.openWindow) {
return clients.openWindow(new URL(self.registration.scope).pathname);
}
}));
});