質問編集履歴
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
```
|
22
22
|
|
23
23
|
###開発環境
|
24
|
-
xcode:
|
24
|
+
xcode:10.1
|
25
25
|
使用言語:swift
|
26
26
|
|
27
27
|
|
1
追記
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
aws-sdk-ios-samples サインインのままアプリを終了した場合に自動的にサインアウトしたい。
|
body
CHANGED
@@ -6,14 +6,17 @@
|
|
6
6
|
GitHub の aws-sdk-ios-samples/CognitoYourUserPools-Sample/Swif のサンプルを利用しています。
|
7
7
|
(https://github.com/awslabs/aws-sdk-ios-samples/tree/master/CognitoYourUserPools-Sample/Swift/CognitoYourUserPoolsSample)
|
8
8
|
|
9
|
-
|
9
|
+
サインイン中にアプリを終了した場合に自動的にサインアウトされるようにしたいです。
|
10
|
+
どの場所に何を追記すれば良いかを知りたいです。
|
11
|
+
|
10
12
|
よろしくお願いいたします。
|
11
13
|
|
12
14
|
### 発生している問題・エラーメッセージ
|
13
15
|
|
14
16
|
```
|
17
|
+
READMEにはこのように記載されています。
|
15
|
-
|
18
|
+
If you quit the app while signed in and restart it, it will remain signed in.
|
16
|
-
|
19
|
+
サインイン中にアプリを終了したのちに起動すると、サインインしたままになります。
|
17
20
|
|
18
21
|
```
|
19
22
|
|
@@ -21,74 +24,9 @@
|
|
21
24
|
xcode:11.2.1
|
22
25
|
使用言語:swift
|
23
26
|
|
24
|
-
### 発生している問題・エラーメッセージ
|
25
27
|
|
26
|
-
```
|
27
|
-
ビルドタイム、ランタイムには問題ありません。
|
28
|
-
サインインボタンを押しても何も反応しません。
|
29
|
-
```
|
30
28
|
|
31
|
-
###
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
import Foundation
|
37
|
-
import AWSCognitoIdentityProvider
|
38
|
-
|
39
|
-
class SignInViewController: UIViewController {
|
40
|
-
@IBOutlet weak var username: UITextField!
|
41
|
-
@IBOutlet weak var password: UITextField!
|
42
|
-
var passwordAuthenticationCompletion: AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails>?
|
43
|
-
var usernameText: String?
|
44
|
-
|
45
|
-
override func viewWillAppear(_ animated: Bool) {
|
46
|
-
super.viewWillAppear(animated)
|
47
|
-
self.password.text = nil
|
48
|
-
self.username.text = usernameText
|
49
|
-
self.navigationController?.setNavigationBarHidden(true, animated: false)
|
50
|
-
}
|
51
|
-
|
52
|
-
@IBAction func signInPressed(_ sender: AnyObject) {
|
53
|
-
if (self.username.text != nil && self.password.text != nil) {
|
54
|
-
let authDetails = AWSCognitoIdentityPasswordAuthenticationDetails(username: self.username.text!, password: self.password.text! )
|
55
|
-
self.passwordAuthenticationCompletion?.set(result: authDetails)
|
56
|
-
} else {
|
57
|
-
let alertController = UIAlertController(title: "Missing information",
|
58
|
-
message: "Please enter a valid user name and password",
|
59
|
-
preferredStyle: .alert)
|
60
|
-
let retryAction = UIAlertAction(title: "Retry", style: .default, handler: nil)
|
61
|
-
alertController.addAction(retryAction)
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
extension SignInViewController: AWSCognitoIdentityPasswordAuthentication {
|
67
|
-
|
68
|
-
public func getDetails(_ authenticationInput: AWSCognitoIdentityPasswordAuthenticationInput, passwordAuthenticationCompletionSource: AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails>) {
|
69
|
-
self.passwordAuthenticationCompletion = passwordAuthenticationCompletionSource
|
70
|
-
DispatchQueue.main.async {
|
71
|
-
if (self.usernameText == nil) {
|
72
|
-
self.usernameText = authenticationInput.lastKnownUsername
|
73
|
-
}
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
public func didCompleteStepWithError(_ error: Error?) {
|
78
|
-
DispatchQueue.main.async {
|
79
|
-
if let error = error as NSError? {
|
80
|
-
let alertController = UIAlertController(title: error.userInfo["__type"] as? String,
|
81
|
-
message: error.userInfo["message"] as? String,
|
82
|
-
preferredStyle: .alert)
|
83
|
-
let retryAction = UIAlertAction(title: "Retry", style: .default, handler: nil)
|
84
|
-
alertController.addAction(retryAction)
|
85
|
-
|
86
|
-
self.present(alertController, animated: true, completion: nil)
|
87
|
-
} else {
|
88
|
-
self.username.text = nil
|
89
|
-
self.dismiss(animated: true, completion: nil)
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
}
|
94
|
-
```
|
29
|
+
### 関係しそうな箇所
|
30
|
+
AppDelegate.swiftの
|
31
|
+
func applicationWillTerminate(_ application: UIApplication) {
|
32
|
+
以下の部分に記載していけばよいのでしょうか?
|