質問編集履歴

2

誤字の修正

2019/07/07 17:31

投稿

torao_tanabe
torao_tanabe

スコア18

test CHANGED
File without changes
test CHANGED
@@ -6,11 +6,7 @@
6
6
 
7
7
  からJavaScript SDK ライブラリはロードされますか?
8
8
 
9
- 現在、monacaデバッガー上で
9
+ 現在
10
-
11
-
12
-
13
- 701SOTypeError: Cannot read property 'GoogleAuthProvider' of undefined
14
10
 
15
11
 
16
12
 

1

詳細を記載

2019/07/07 17:31

投稿

torao_tanabe
torao_tanabe

スコア18

test CHANGED
File without changes
test CHANGED
@@ -5,3 +5,255 @@
5
5
  <script src="https://firebase~~~"></script>
6
6
 
7
7
  からJavaScript SDK ライブラリはロードされますか?
8
+
9
+ 現在、monacaデバッガー上で
10
+
11
+
12
+
13
+ 701SOTypeError: Cannot read property 'GoogleAuthProvider' of undefined
14
+
15
+
16
+
17
+ monacaの(onsen UI V2 Vue Tabberテンプレート)を使い、
18
+
19
+
20
+
21
+
22
+
23
+ index.html.ejs内でCDN(コンテンツ配信ネットワーク)から Firebase JavaScript SDK ライブラリのロード<script>を以下のように書き
24
+
25
+ ```html
26
+
27
+ <!DOCTYPE html>
28
+
29
+ <html>
30
+
31
+ <head>
32
+
33
+ <!-- This file is the template for "www/index.html". Modify it to fit your needs -->
34
+
35
+ <meta charset="utf-8" />
36
+
37
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
38
+
39
+ <meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
40
+
41
+
42
+
43
+
44
+
45
+ <!-- The following EJS lines include the necessary CSS and JS
46
+
47
+ from Monaca (cordova.js/ loader.js) in production mode -->
48
+
49
+ <% for (var dep in htmlWebpackPlugin.options.externalJS) { %>
50
+
51
+ <script type="text/javascript" src="<%= htmlWebpackPlugin.options.externalJS[dep] %>"></script><% } %>
52
+
53
+
54
+
55
+ <% for (var dep in htmlWebpackPlugin.options.externalCSS) { %>
56
+
57
+ <link rel="stylesheet" type="text/css" href="<%= htmlWebpackPlugin.options.externalCSS[dep] %>"><% } %>
58
+
59
+
60
+
61
+
62
+
63
+ </head>
64
+
65
+ <body>
66
+
67
+ <div id="app"></div>
68
+
69
+ <script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-app.js"></script>
70
+
71
+ </body>
72
+
73
+ </html>
74
+
75
+
76
+
77
+ ```
78
+
79
+ firebaseの設定も終えて、
80
+
81
+
82
+
83
+ main.jsでfirebaseのconfigの設定を以下のようにして
84
+
85
+ ```js
86
+
87
+ import ons from 'onsenui';
88
+
89
+ import Vue from 'vue';
90
+
91
+ import VueOnsen from 'vue-onsenui';
92
+
93
+
94
+
95
+ // Onsen UI Styling and Icons
96
+
97
+ require('onsenui/css-components-src/src/onsen-css-components.css');
98
+
99
+ require('onsenui/css/onsenui.css');
100
+
101
+
102
+
103
+ import App from './App.vue';
104
+
105
+ import Login from './Login.vue';
106
+
107
+
108
+
109
+
110
+
111
+ if (ons.platform.isIPhoneX()) {
112
+
113
+ document.documentElement.setAttribute('onsflag-iphonex-portrait', '');
114
+
115
+ document.documentElement.setAttribute('onsflag-iphonex-landscape', '');
116
+
117
+ }
118
+
119
+
120
+
121
+ Vue.use(VueOnsen);
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+ // Your web app's Firebase configuration
130
+
131
+ var onDeviceReady = function() {
132
+
133
+ console.log('::onDeiveReady');
134
+
135
+ var firebaseConfig = {
136
+
137
+ apiKey: "xxxxxxxxxxxxxxxxxxxxxxxx",
138
+
139
+ authDomain: "xxxxxxxxxxxxxxxxxxxxxxxxx",
140
+
141
+ databaseURL: "xxxxxxxxxxxxxxxxxxxxxxxxxx",
142
+
143
+ projectId: "xxxxxxxxxxxxxxxxxx",
144
+
145
+ storageBucket: "xxxxxxxxxxxxxxxxx",
146
+
147
+ messagingSenderId: "xxxxxxxxxxxxxx",
148
+
149
+ appId: "xxxxxxxxxxxxxxxxxxxx"
150
+
151
+ };
152
+
153
+ // Initialize Firebase
154
+
155
+ firebase.initializeApp(firebaseConfig);
156
+
157
+
158
+
159
+ new Vue({
160
+
161
+ el: '#app',
162
+
163
+ template: '<app></app>',
164
+
165
+ components: { App }
166
+
167
+ });
168
+
169
+
170
+
171
+ }
172
+
173
+ document.addEventListener(window.cordova ?"deviceready" : "DOMContentLoaded", onDeviceReady, false);
174
+
175
+
176
+
177
+ ```
178
+
179
+
180
+
181
+ 以下のLogin.vueでfirebaseのGoogle認証を以下のように使おうと思ったのですが、monacaデバッガーで
182
+
183
+ TypeError: Cannot read property 'GoogleAuthProvider' of undefined や
184
+
185
+ TypeError: firebase.auth is not a function www/vendors~app.bundle.js:26のエラーが出ます
186
+
187
+
188
+
189
+ ```vue
190
+
191
+ <template>
192
+
193
+ <div id="login">
194
+
195
+ <h1>{{ msg }}</h1>
196
+
197
+ <button @click="googleLogin">Googleアカウントでログイン</button>
198
+
199
+ </div>
200
+
201
+ </template>
202
+
203
+
204
+
205
+ <script>
206
+
207
+
208
+
209
+ export default {
210
+
211
+ name: "login",
212
+
213
+ data(){
214
+
215
+ return{
216
+
217
+ msg: "ログイン"
218
+
219
+ };
220
+
221
+ },
222
+
223
+ methods: {
224
+
225
+ googleLogin: function(){
226
+
227
+
228
+
229
+ //var provider = new firebase.auth.GoogleAuthProvider();
230
+
231
+
232
+
233
+ firebase.auth().signInWithRedirect(new firebase.auth.GoogleAuthProvider());
234
+
235
+ }
236
+
237
+
238
+
239
+ }
240
+
241
+
242
+
243
+ };
244
+
245
+ </script>
246
+
247
+ ```
248
+
249
+
250
+
251
+ firebase自体が読み込めてないのでしょうか?
252
+
253
+ それで、そもそもmonacaデバッカー自体がライブラリを使えないのではと疑問になり質問させて頂きました。
254
+
255
+ まだこの環境で開発するとは確定していないので、monacaデバッガーの使いやすさを考えて決めようと思っています。普通にmonacaデバッガーでfirebase周りが動くならコード等が悪いと分かるのでありがたいです。
256
+
257
+ いちおmonacaのデバッガービルドをして実機で動かしてみたのですが、Googleアカウントでログインボタンは機能しませんでした。
258
+
259
+ もし、コードが間違っていたり環境構築で足りない所があったら教えていただけると幸いです。