質問編集履歴
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,11 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
func locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for inRegion: CLRegion) {
|
10
|
+
|
11
|
+
このプログラムから動いていなく、switch文から動いていない状況です。
|
12
|
+
|
13
|
+
swift Xcode
|
10
14
|
|
11
15
|
|
12
16
|
|
@@ -14,11 +18,11 @@
|
|
14
18
|
|
15
19
|
|
16
20
|
|
17
|
-
|
21
|
+
|
18
22
|
|
19
23
|
ソースコード
|
20
24
|
|
21
|
-
|
25
|
+
```
|
22
26
|
|
23
27
|
import UIKit
|
24
28
|
|
@@ -108,31 +112,31 @@
|
|
108
112
|
|
109
113
|
|
110
114
|
|
111
|
-
|
115
|
+
let uuid:UUID? = UUID(uuidString: "9cdc16d0-f9ea-4eba-8db9-0ec18844a76b")
|
116
|
+
|
117
|
+
|
118
|
+
|
112
|
-
|
119
|
+
//Beacon領域を作成
|
113
|
-
|
114
|
-
|
120
|
+
|
115
|
-
|
121
|
+
beaconRegion = CLBeaconRegion(proximityUUID: uuid!, identifier: "net.noumenon-th")
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
123
|
-
|
127
|
+
// セキュリティ認証のステータスを取得
|
124
|
-
|
125
|
-
|
126
|
-
|
128
|
+
|
129
|
+
|
130
|
+
|
127
|
-
|
131
|
+
let status = CLLocationManager.authorizationStatus()
|
128
|
-
|
129
|
-
|
130
|
-
|
132
|
+
|
133
|
+
|
134
|
+
|
131
|
-
|
135
|
+
// まだ認証が得られていない場合は、認証ダイアログを表示
|
132
|
-
|
133
|
-
|
134
|
-
|
136
|
+
|
137
|
+
|
138
|
+
|
135
|
-
|
139
|
+
if(status == CLAuthorizationStatus.notDetermined) {
|
136
140
|
|
137
141
|
|
138
142
|
|
@@ -160,9 +164,7 @@
|
|
160
164
|
|
161
165
|
|
162
166
|
|
163
|
-
|
167
|
+
//観測を開始させる
|
164
|
-
|
165
|
-
|
166
168
|
|
167
169
|
trackLocationManager.startMonitoring(for: self.beaconRegion)
|
168
170
|
|
@@ -184,7 +186,7 @@
|
|
184
186
|
|
185
187
|
|
186
188
|
|
187
|
-
|
189
|
+
//観測開始に成功したら、領域内にいるかどうかの判定をおこなう。→(didDetermineState)へ
|
188
190
|
|
189
191
|
|
190
192
|
|
@@ -194,13 +196,11 @@
|
|
194
196
|
|
195
197
|
}
|
196
198
|
|
197
|
-
|
199
|
+
//ここまでは動いている。
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
-
|
203
|
+
//領域内にいるかどうかを判定する
|
204
204
|
|
205
205
|
|
206
206
|
|
@@ -210,13 +210,11 @@
|
|
210
210
|
|
211
211
|
|
212
212
|
|
213
|
-
|
214
|
-
|
215
|
-
|
213
|
+
switch (state) {
|
216
|
-
|
217
|
-
|
218
|
-
|
214
|
+
|
215
|
+
|
216
|
+
|
219
|
-
|
217
|
+
case .inside: // すでに領域内にいる場合は(didEnterRegion)は呼ばれない
|
220
218
|
|
221
219
|
|
222
220
|
|
@@ -402,6 +400,8 @@
|
|
402
400
|
|
403
401
|
}
|
404
402
|
|
403
|
+
```
|
404
|
+
|
405
405
|
こちらのプログラムはhttps://qiita.com/nwatabou/items/be08d79341bb5721239fをもとにしました。
|
406
406
|
|
407
407
|
## 試したこと
|