2">72 166
   FBAEMKit: af2972f39bb0f3f7c45998f435b007833c32ffb2
73 167
   FBSDKCoreKit: 19e2e18b3be578d7a51fed8fdd8c152bef0b9511
74 168
   FBSDKCoreKit_Basics: dd9826ce3c9fd9f8cdf8dbbd0ef0a53e6c0c9e7e
75 169
   FBSDKLoginKit: c395c63a1a6cf4a8a1e6103fd94b8c46329ee81c
170
+  Firebase: f4ac0b02927af9253ae094d23deecf0890da7374
171
+  FirebaseCore: 534544dd98cabcf4bf8598d88ec683b02319a528
172
+  FirebaseCoreInternal: 2cf9202e226e3f78d2bf6d56c472686b935bfb7f
173
+  FirebaseInstallations: 9387bf15abfc69a714f54e54f74a251264fdb79b
174
+  FirebaseMessaging: 1367b28c0c83a63072af4a711328fcc2e6899902
175
+  GoogleDataTransport: 54dee9d48d14580407f8f5fbf2f496e92437a2f2
176
+  GoogleSignIn: 5651ce3a61e56ca864160e79b484cd9ed3f49b7a
177
+  GoogleUtilities: 202e7a9f5128accd11160fb9c19612de1911aa19
178
+  GTMAppAuth: 0ff230db599948a9ad7470ca667337803b3fc4dd
179
+  GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
180
+  nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
181
+  PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
76 182
 
77
-PODFILE CHECKSUM: c9736b063f76e0be20a97ef4e5e07cd2323fa896
183
+PODFILE CHECKSUM: 13a486d397817692d7e7744cf0c6e77b81469655
78 184
 
79 185
 COCOAPODS: 1.12.1

+ 18 - 0
package-lock.json

@@ -15,7 +15,9 @@
15 15
         "@capacitor/ios": "5.5.0",
16 16
         "@capacitor/keyboard": "5.0.6",
17 17
         "@capacitor/preferences": "^5.0.6",
18
+        "@capacitor/push-notifications": "^5.1.0",
18 19
         "@capacitor/status-bar": "5.0.6",
20
+        "@codetrix-studio/capacitor-google-auth": "^3.3.4",
19 21
         "@ionic/vue": "^7.0.0",
20 22
         "@ionic/vue-router": "^7.0.0",
21 23
         "@vimeo/player": "^2.20.1",
@@ -1908,6 +1910,14 @@
1908 1910
         "@capacitor/core": "^5.0.0"
1909 1911
       }
1910 1912
     },
1913
+    "node_modules/@capacitor/push-notifications": {
1914
+      "version": "5.1.0",
1915
+      "resolved": "https://registry.npmjs.org/@capacitor/push-notifications/-/push-notifications-5.1.0.tgz",
1916
+      "integrity": "sha512-Laxi5TQbwTqQFNJZdyyfJJqb+OVZz+0VRtW4uhM+u5TKWuXCYw/yrctXuIpG+VFUptvtPG7ic7+0WcBs+sQ17Q==",
1917
+      "peerDependencies": {
1918
+        "@capacitor/core": "^5.0.0"
1919
+      }
1920
+    },
1911 1921
     "node_modules/@capacitor/status-bar": {
1912 1922
       "version": "5.0.6",
1913 1923
       "resolved": "https://registry.npmjs.org/@capacitor/status-bar/-/status-bar-5.0.6.tgz",
@@ -1916,6 +1926,14 @@
1916 1926
         "@capacitor/core": "^5.0.0"
1917 1927
       }
1918 1928
     },
1929
+    "node_modules/@codetrix-studio/capacitor-google-auth": {
1930
+      "version": "3.3.4",
1931
+      "resolved": "https://registry.npmjs.org/@codetrix-studio/capacitor-google-auth/-/capacitor-google-auth-3.3.4.tgz",
1932
+      "integrity": "sha512-R9kTWK5x2bT+gXV1ia48Xt/rS1RPXrVVPDCeX4mpGFyIyjdx1FmuAkHeFNsSQ4sGDKkjCWnXf6z+ikcKnusz7g==",
1933
+      "peerDependencies": {
1934
+        "@capacitor/core": "^5.0.0"
1935
+      }
1936
+    },
1919 1937
     "node_modules/@colors/colors": {
1920 1938
       "version": "1.5.0",
1921 1939
       "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",

+ 2 - 0
package.json

@@ -19,7 +19,9 @@
19 19
     "@capacitor/ios": "5.5.0",
20 20
     "@capacitor/keyboard": "5.0.6",
21 21
     "@capacitor/preferences": "^5.0.6",
22
+    "@capacitor/push-notifications": "^5.1.0",
22 23
     "@capacitor/status-bar": "5.0.6",
24
+    "@codetrix-studio/capacitor-google-auth": "^3.3.4",
23 25
     "@ionic/vue": "^7.0.0",
24 26
     "@ionic/vue-router": "^7.0.0",
25 27
     "@vimeo/player": "^2.20.1",

+ 9 - 1
src/App.vue

@@ -5,5 +5,13 @@
5 5
 </template>
6 6
 
7 7
 <script setup lang="ts">
8
-import { IonApp, IonRouterOutlet } from '@ionic/vue';
8
+import { IonApp, IonRouterOutlet, onIonViewWillEnter } from '@ionic/vue';
9
+import { defineComponent, onMounted } from 'vue';
10
+
11
+
12
+
13
+onIonViewWillEnter(() => {
14
+  console.log("Init On Mouting")
15
+});
16
+
9 17
 </script>

+ 14 - 0
src/settings.ts

@@ -63,3 +63,17 @@ export const listMats = async  () => {
63 63
   console.log(data)
64 64
   return data.results
65 65
 }
66
+
67
+export const storeAPNToken = async (device_token) => {
68
+  
69
+  const token = await Preferences.get({ key: 'token' });
70
+  console.log("token = ", token)
71
+  const { data } = await axios.post(BASE_URL + "backend/api/device_tokens/",{token: device_token},
72
+  {
73
+    headers: { 
74
+    'Authorization': `Token ${token.value}`
75
+    }
76
+  })
77
+  console.log(data)
78
+  return data
79
+}

+ 36 - 2
src/views/ProfilePage.vue

@@ -7,8 +7,13 @@
7 7
     </ion-header>
8 8
     <ion-content>
9 9
       <div class="example-content">Listen now content</div>
10
-      <ion-button @click='fbLogout' v-if='isLogin'>Facebook Logout</ion-button>
11
-      <ion-button @click='fbLogin' v-else>Facebook Login</ion-button>
10
+      <template v-if="isLogin">
11
+      <ion-button @click='fbLogout'>Logout</ion-button>
12
+      </template>
13
+      <template v-else>
14
+        <ion-button @click='fbLogin'>Facebook Login</ion-button>
15
+        <ion-button @click='ggLogin'>Google Login</ion-button>
16
+      </template>
12 17
     </ion-content>
13 18
   </ion-page>
14 19
 </template>
@@ -16,6 +21,12 @@
16 21
 <script setup lang="ts">
17 22
 import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonButton, onIonViewWillEnter } from '@ionic/vue';
18 23
 import ExploreContainer from '@/components/ExploreContainer.vue';
24
+import { defineComponent, onMounted } from 'vue';
25
+import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
26
+
27
+onMounted(() => {
28
+  GoogleAuth.initialize();
29
+});
19 30
 
20 31
 import {
21 32
   FacebookLogin,
@@ -33,6 +44,15 @@ const FACEBOOK_PERMISSIONS = [
33 44
 
34 45
 const isLogin = ref(false)
35 46
 
47
+const ggLogin = async () => {
48
+  const response = await GoogleAuth.signIn();
49
+  console.log(response);
50
+  console.log(response.accessToken)
51
+  if( response.authentication.accessToken ) {
52
+    isLogin.value = true
53
+  }
54
+}
55
+
36 56
 const fbLogin = async () => {
37 57
   const result = await (<FacebookLoginResponse>(
38 58
     FacebookLogin.login({ permissions: FACEBOOK_PERMISSIONS })
@@ -60,6 +80,7 @@ onIonViewWillEnter(async () => {
60 80
   }else {
61 81
     isLogin.value = false
62 82
   }
83
+  ggCheckLogin()
63 84
 
64 85
 })
65 86
 const getProfile = async () => {
@@ -69,4 +90,17 @@ const getProfile = async () => {
69 90
 
70 91
   console.log(`Facebook user's email is ${result.email}`);
71 92
 }
93
+const ggCheckLogin = async() => {
94
+    GoogleAuth.refresh()
95
+        .then((data) => {
96
+            if (data.accessToken) {
97
+                isLogin.value = true
98
+            }
99
+        })
100
+        .catch((error) => {
101
+            if (error.type === 'userLoggedOut') {
102
+                //this.signin()
103
+            }
104
+        });
105
+}
72 106
 </script>

+ 44 - 1
src/views/Tab1Page.vue

@@ -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>

Sign In - Gogs: Simplico Git Service

Sign In