Skip to content

Commit b895a04

Browse files
v1.0.0
1 parent 8086ea4 commit b895a04

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

www/res/plugins/push-notifications.ts

+24-25
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
import { PushNotifications } from '@capacitor/push-notifications';
1+
import { PushNotifications } from "@capacitor/push-notifications";
22

33
const register = async () => {
4+
let STATUS = await PushNotifications.checkPermissions();
5+
console.log(STATUS);
46

5-
let STATUS = await PushNotifications.checkPermissions();
6-
console.log(STATUS);
7+
if (STATUS.receive === "prompt") {
8+
STATUS = await PushNotifications.requestPermissions();
9+
console.log(STATUS);
10+
}
711

8-
if (STATUS.receive === 'prompt') {
9-
STATUS = await PushNotifications.requestPermissions();
10-
console.log(STATUS);
11-
}
12+
if (STATUS.receive !== "granted") {
13+
console.log("not permission");
14+
}
1215

13-
if (STATUS.receive !== 'granted') {
14-
console.log('not permission');
15-
}
16+
await PushNotifications.register();
1617

17-
await PushNotifications.register();
18-
19-
PushNotifications.addListener('registration', (token) => {
20-
console.log(token);
21-
});
18+
PushNotifications.addListener("registration", (token) => {
19+
console.log(token);
20+
});
2221

23-
PushNotifications.addListener('registrationError', (error) => {
24-
console.log(error);
25-
});
22+
PushNotifications.addListener("registrationError", (error) => {
23+
console.log(error);
24+
});
2625

27-
PushNotifications.addListener('pushNotificationReceived', (notification) => {
28-
console.log(notification);
29-
});
26+
PushNotifications.addListener("pushNotificationReceived", (notification) => {
27+
console.log(notification);
28+
});
3029

31-
PushNotifications.addListener('pushNotificationActionPerformed', (action) => {
32-
console.log(action);
33-
});
30+
PushNotifications.addListener("pushNotificationActionPerformed", (action) => {
31+
console.log(action);
32+
});
3433
};
3534

36-
register();
35+
register();

0 commit comments

Comments
 (0)