|
|
@@ -79,10 +79,13 @@ import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonIcon, onIonVie
|
|
79
|
79
|
import ExploreContainer from '@/components/ExploreContainer.vue';
|
|
80
|
80
|
import { CapacitorHttp } from '@capacitor/core';
|
|
81
|
81
|
import { ref } from 'vue';
|
|
82
|
|
-import { TOKEN, getProducts, setToken, getObject, getToken, getTrainers, listMats } from '@/settings';
|
|
|
82
|
+import { TOKEN, getProducts, setToken, getObject, getToken, getTrainers, listMats, storeAPNToken } from '@/settings';
|
|
83
|
83
|
//import VueCoreVideoPlayer from 'vue-core-video-player'
|
|
84
|
84
|
import { vueVimeoPlayer } from 'vue-vimeo-player'
|
|
85
|
85
|
|
|
|
86
|
+import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
|
|
|
87
|
+
|
|
|
88
|
+import { PushNotifications } from '@capacitor/push-notifications';
|
|
86
|
89
|
|
|
87
|
90
|
import Player from '@vimeo/player';
|
|
88
|
91
|
|
|
|
@@ -127,6 +130,9 @@ const mats = ref()
|
|
127
|
130
|
mats.value = await listMats()
|
|
128
|
131
|
console.log(" trainers => ", trainers)
|
|
129
|
132
|
|
|
|
133
|
+ GoogleAuth.initialize();
|
|
|
134
|
+ registerNotifications()
|
|
|
135
|
+ addListeners()
|
|
130
|
136
|
})
|
|
131
|
137
|
|
|
132
|
138
|
onIonViewWillLeave(() => {
|
|
|
@@ -145,4 +151,41 @@ const mats = ref()
|
|
145
|
151
|
const response: HttpResponse = await CapacitorHttp.get(options);
|
|
146
|
152
|
console.log(response)
|
|
147
|
153
|
}
|
|
|
154
|
+const addListeners = async () => {
|
|
|
155
|
+ await PushNotifications.addListener('registration', token => {
|
|
|
156
|
+ console.info('Registration token: ', token.value);
|
|
|
157
|
+ storeAPNToken(token.value)
|
|
|
158
|
+ });
|
|
|
159
|
+
|
|
|
160
|
+ await PushNotifications.addListener('registrationError', err => {
|
|
|
161
|
+ console.error('Registration error: ', err.error);
|
|
|
162
|
+ });
|
|
|
163
|
+
|
|
|
164
|
+ await PushNotifications.addListener('pushNotificationReceived', notification => {
|
|
|
165
|
+ console.log('Push notification received: ', notification);
|
|
|
166
|
+ });
|
|
|
167
|
+
|
|
|
168
|
+ await PushNotifications.addListener('pushNotificationActionPerformed', notification => {
|
|
|
169
|
+ console.log('Push notification action performed', notification.actionId, notification.inputValue);
|
|
|
170
|
+ });
|
|
|
171
|
+}
|
|
|
172
|
+
|
|
|
173
|
+const registerNotifications = async () => {
|
|
|
174
|
+ let permStatus = await PushNotifications.checkPermissions();
|
|
|
175
|
+
|
|
|
176
|
+ if (permStatus.receive === 'prompt') {
|
|
|
177
|
+ permStatus = await PushNotifications.requestPermissions();
|
|
|
178
|
+ }
|
|
|
179
|
+
|
|
|
180
|
+ if (permStatus.receive !== 'granted') {
|
|
|
181
|
+ throw new Error('User denied permissions!');
|
|
|
182
|
+ }
|
|
|
183
|
+
|
|
|
184
|
+ await PushNotifications.register();
|
|
|
185
|
+}
|
|
|
186
|
+
|
|
|
187
|
+const getDeliveredNotifications = async () => {
|
|
|
188
|
+ const notificationList = await PushNotifications.getDeliveredNotifications();
|
|
|
189
|
+ console.log('delivered notifications', notificationList);
|
|
|
190
|
+}
|
|
148
|
191
|
</script>
|