質問編集履歴

3

AppDelegateを修正

2017/12/27 08:45

投稿

yamayamak
yamayamak

スコア131

test CHANGED
File without changes
test CHANGED
@@ -172,12 +172,8 @@
172
172
 
173
173
  assert(configureError == nil, "Error configuring Google services: (String(describing: configureError))")
174
174
 
175
-
176
-
177
175
  GIDSignIn.sharedInstance().delegate = self
178
176
 
179
-
180
-
181
177
  return true
182
178
 
183
179
  }

2

AppDelegateを修正

2017/12/27 08:45

投稿

yamayamak
yamayamak

スコア131

test CHANGED
File without changes
test CHANGED
@@ -124,6 +124,8 @@
124
124
 
125
125
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
126
126
 
127
+ return true
128
+
127
129
  }
128
130
 
129
131
 

1

AppDelegateを追記

2017/12/27 08:43

投稿

yamayamak
yamayamak

スコア131

test CHANGED
File without changes
test CHANGED
@@ -104,4 +104,156 @@
104
104
 
105
105
 
106
106
 
107
+ AppDelegateは以下の通りです。
108
+
109
+ ```swift
110
+
111
+ import UIKit
112
+
113
+ import Google
114
+
115
+
116
+
117
+ @UIApplicationMain
118
+
119
+ class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
120
+
121
+ var window: UIWindow?
122
+
123
+
124
+
125
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
126
+
127
+ }
128
+
129
+
130
+
131
+ func applicationWillResignActive(_ application: UIApplication) {
132
+
133
+ }
134
+
135
+
136
+
137
+ func applicationDidEnterBackground(_ application: UIApplication) {
138
+
139
+ }
140
+
141
+
142
+
143
+ func applicationWillEnterForeground(_ application: UIApplication) {
144
+
145
+ }
146
+
147
+
148
+
149
+ func applicationDidBecomeActive(_ application: UIApplication) {
150
+
151
+ }
152
+
153
+
154
+
155
+ func applicationWillTerminate(_ application: UIApplication) {
156
+
157
+ }
158
+
159
+
160
+
161
+ private func application(application: UIApplication,
162
+
163
+ didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
164
+
165
+ // Initialize sign-in
166
+
167
+ var configureError: NSError?
168
+
169
+ GGLContext.sharedInstance().configureWithError(&configureError)
170
+
171
+ assert(configureError == nil, "Error configuring Google services: (String(describing: configureError))")
172
+
173
+
174
+
175
+ GIDSignIn.sharedInstance().delegate = self
176
+
177
+
178
+
179
+ return true
180
+
181
+ }
182
+
183
+
184
+
185
+ @available(iOS 9.0, *)
186
+
187
+ func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any])
188
+
189
+ -> Bool {
190
+
191
+ return GIDSignIn.sharedInstance().handle(url,
192
+
193
+ sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
194
+
195
+ annotation: [:])
196
+
197
+ }
198
+
199
+
200
+
201
+ //for iOS 8, check availability
202
+
203
+ @available(iOS, introduced: 8.0, deprecated: 9.0)
204
+
205
+ func application(application: UIApplication,openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
206
+
207
+ return GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: sourceApplication!, annotation: annotation)
208
+
209
+ }
210
+
211
+
212
+
213
+ func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
214
+
215
+ if (error == nil) {
216
+
217
+ // Perform any operations on signed in user here.
218
+
219
+ let userId = user.userID // For client-side use only!
220
+
221
+ let idToken = user.authentication.idToken // Safe to send to the server
222
+
223
+ let fullName = user.profile.name
224
+
225
+ let givenName = user.profile.givenName
226
+
227
+ let familyName = user.profile.familyName
228
+
229
+ let email = user.profile.email
230
+
231
+ // ...
232
+
233
+ } else {
234
+
235
+ print("(error.localizedDescription)")
236
+
237
+ }
238
+
239
+ }
240
+
241
+
242
+
243
+ func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!,
244
+
245
+ withError error: NSError!) {
246
+
247
+ // Perform any operations when the user disconnects from app here.
248
+
249
+ // ...
250
+
251
+ }
252
+
253
+ }
254
+
255
+ ```
256
+
257
+
258
+
107
259
  よろしくお願いします。