1
00:00:07,180 --> 00:00:13,480
Hello hello my code pals my friends my amigos in this video we're going to go ahead and create a Siri

2
00:00:13,480 --> 00:00:15,330
kit intense app extension.

3
00:00:15,550 --> 00:00:19,870
And we're also going to configure it so that it's good to go with a workout style app.

4
00:00:19,870 --> 00:00:25,330
So let's go ahead and let's pull over on our project here and what we need to do first is to create

5
00:00:25,360 --> 00:00:30,460
that intense app extension and so to do that what we're going to do is go up to the very top of our

6
00:00:30,460 --> 00:00:34,980
app here and click File New and then select target.

7
00:00:35,220 --> 00:00:35,880
OK.

8
00:00:36,310 --> 00:00:41,290
Now there's a bunch of different things you can select here and those are for different topics but we

9
00:00:41,290 --> 00:00:47,920
need to focus on an intense extension K and that's a sirra kit intense extension so go ahead and click

10
00:00:47,920 --> 00:00:55,000
on it and what we need to give it a name and so I'm just going to actually call this intent handler.

11
00:00:55,280 --> 00:00:56,280
OK.

12
00:00:56,320 --> 00:00:59,770
And it's basically going to you know handle whatever happens in our intents.

13
00:00:59,800 --> 00:01:04,870
So its name is intent handler leave all this information the same.

14
00:01:04,870 --> 00:01:12,100
But if this box is ticked include UI extension and ticket we do not want it because this course is not

15
00:01:12,100 --> 00:01:18,130
going to cover the UI extensions for the intent or the contents.

16
00:01:18,130 --> 00:01:22,100
But you can definitely do that if you want to dive into that.

17
00:01:22,180 --> 00:01:24,630
For now though were going to ticket and move on.

18
00:01:24,760 --> 00:01:31,450
So click Finish and its going to go ahead and ask you if you want to activate the content handler scheme

19
00:01:31,600 --> 00:01:32,510
click activate.

20
00:01:32,560 --> 00:01:38,080
Yes because you do want to do that and you'll notice there's another little project over here in our

21
00:01:38,080 --> 00:01:39,320
main project.

22
00:01:39,460 --> 00:01:42,390
If you open it up you'll see there are two different files here.

23
00:01:42,400 --> 00:01:44,490
One says intent.

24
00:01:45,250 --> 00:01:52,060
The other is Infocom pelisse that has its own info up list file and the interesting thing is that when

25
00:01:52,060 --> 00:01:58,510
we create this it assumes that we're making a messaging app and all this example code here is Regards

26
00:01:58,780 --> 00:02:00,850
in regards to a messaging app.

27
00:02:00,850 --> 00:02:04,840
And so I'm actually going to go ahead and just get rid of these comments and we're actually going to

28
00:02:04,840 --> 00:02:09,060
delete everything in here except for the class itself.

29
00:02:09,070 --> 00:02:14,890
So delete all this because these are all specific functions for messaging and also these protocols that

30
00:02:14,890 --> 00:02:16,250
we are extending.

31
00:02:16,470 --> 00:02:22,020
And go ahead and just conform to I-N start work out in 10 handly.

32
00:02:22,320 --> 00:02:25,660
OK this is the delegate that handles the starting of a workout.

33
00:02:25,660 --> 00:02:33,310
And of course we need to handle our intent and that's why we're using the intent handler protocol for

34
00:02:33,370 --> 00:02:34,580
starting a workout.

35
00:02:34,900 --> 00:02:35,890
Now that's great.

36
00:02:35,980 --> 00:02:40,860
But let's go ahead and let's pause for a sec and dive over into our info the populist file.

37
00:02:41,140 --> 00:02:46,300
So go into that and you'll notice this looks pretty standard except down here at the bottom there's

38
00:02:46,360 --> 00:02:52,570
a little dictionary that says an extension pop that open and you'll see there is an N S extension point

39
00:02:52,570 --> 00:02:55,230
identifier and s extension principle class.

40
00:02:55,240 --> 00:02:56,350
Don't do anything with those.

41
00:02:56,350 --> 00:03:01,120
Those are fine by default but we need to dive into the extension attributes.

42
00:03:01,240 --> 00:03:03,010
And there are two arrays in here.

43
00:03:03,040 --> 00:03:09,190
One is called intent supported and one is called intense restricted while locked.

44
00:03:09,190 --> 00:03:16,500
Now they do exactly what you would think intent supported is basically going to be what Syrie kit intense

45
00:03:16,750 --> 00:03:23,000
like start a workout and a workout Pazz Pozza workout add item 2 to do list for quest to ride which

46
00:03:23,020 --> 00:03:29,110
intense are going to be supported regardless of if the device is locked or not and the intense restricted

47
00:03:29,440 --> 00:03:33,350
is going to say okay which ones are going to be restricted while the phone is locked now.

48
00:03:33,370 --> 00:03:38,800
You know sending payments while the phone is locked is probably not a good idea because anyone can pick

49
00:03:38,800 --> 00:03:43,470
up your phone and say hey send me five hundred dollars and it would send them $500 because it's you

50
00:03:43,470 --> 00:03:46,510
know not locked down with security.

51
00:03:46,510 --> 00:03:49,560
So if you open this up there's actually nothing in here.

52
00:03:49,650 --> 00:03:52,900
And so we don't need to put anything in there but it does need to stay.

53
00:03:52,900 --> 00:03:53,940
So just leave it there.

54
00:03:54,130 --> 00:04:00,850
But if you pop open intense supported you'll notice that these are the ones that were related to messaging

55
00:04:00,880 --> 00:04:04,510
from the swift file so we can actually get rid of all of these.

56
00:04:04,570 --> 00:04:08,060
So just select them one by one and delete all three.

57
00:04:08,170 --> 00:04:14,800
Then we're going to just create an item inside by clicking that plus icon and item 0 is an OK name but

58
00:04:14,860 --> 00:04:17,700
we need to go ahead and use the proper intent.

59
00:04:17,710 --> 00:04:19,230
And we want to start a workout.

60
00:04:19,240 --> 00:04:24,620
So we're going to type and start workout and press enter.

61
00:04:24,970 --> 00:04:26,790
And that is the intent that we want to support.

62
00:04:26,790 --> 00:04:32,650
Now if we were going to support pausing workouts we could say I can pause workout and I'm not just doing

63
00:04:32,650 --> 00:04:33,800
this from memory I do.

64
00:04:33,820 --> 00:04:38,360
Well I am but I do know that I got these from Apple's documentation.

65
00:04:38,440 --> 00:04:44,230
If we wanted to support the ending of a workout we could support an end workout.

66
00:04:44,860 --> 00:04:45,410
OK.

67
00:04:45,550 --> 00:04:50,690
Now the interesting thing is that you need to know is let's say that you know speak something to Siri

68
00:04:50,770 --> 00:04:52,180
you say Hey Siri blah blah blah.

69
00:04:52,510 --> 00:04:56,650
And let's say that it's not exactly sure what you meant.

70
00:04:56,650 --> 00:05:00,670
Like maybe you said something that was a bit ambiguous it's not sure if you want to pause or end the

71
00:05:00,670 --> 00:05:03,230
workout like if you say you know stop my workout.

72
00:05:03,490 --> 00:05:08,160
What it's actually going to do is it's going to look through intense supported.

73
00:05:08,260 --> 00:05:14,200
And it's going to choose the top most item with a higher priority than the second and the second with

74
00:05:14,200 --> 00:05:15,580
a higher priority than the third.

75
00:05:15,580 --> 00:05:20,940
So put these in the order that you expect you know you're in tends to come in as.

76
00:05:21,160 --> 00:05:24,750
Now for our app I'm going to actually delete pause and work out.

77
00:05:25,000 --> 00:05:26,460
And we're just going to keep start work out.

78
00:05:26,470 --> 00:05:31,870
But that's good to know that the order actually does impact how Siri might look through and make requests

79
00:05:31,870 --> 00:05:33,140
based on what you say.

80
00:05:33,400 --> 00:05:37,750
Now I forgot this I N stands for intent.

81
00:05:37,750 --> 00:05:41,620
And we actually need to you know explicitly specify that this is an intent.

82
00:05:41,620 --> 00:05:44,940
So it's called I and start work out intent.

83
00:05:45,380 --> 00:05:46,030
OK.

84
00:05:46,420 --> 00:05:52,810
And that is it guys that's that's there our intent handler is here and now we're going to write the

85
00:05:52,810 --> 00:05:56,960
code to help us actually handle what happens when we speak to Siri.

86
00:05:57,100 --> 00:06:02,140
And there is one big function that we really care about since we're starting a workout and check it

87
00:06:02,140 --> 00:06:04,330
out if we type handle.

88
00:06:04,330 --> 00:06:06,990
There's one called handle intent.

89
00:06:07,000 --> 00:06:12,660
I start work out intent and that's the one we just set up in our info that pilots file so select it.

90
00:06:12,670 --> 00:06:19,330
And as you can see when this is called in intent is passed in and there is a completion handler where

91
00:06:19,330 --> 00:06:21,620
we pass the response out.

92
00:06:21,630 --> 00:06:21,950
OK.

93
00:06:21,970 --> 00:06:28,180
And it's escaping so whenever we call this later we can escape that value out or wherever a series picks

94
00:06:28,180 --> 00:06:29,020
it up.

95
00:06:29,020 --> 00:06:36,430
So inside the code here we're going to go ahead and print out a little statement basically saying what

96
00:06:36,610 --> 00:06:38,130
intent we're actually using.

97
00:06:38,130 --> 00:06:40,540
So we're going to just say print.

98
00:06:41,230 --> 00:06:42,100
And here we go.

99
00:06:42,100 --> 00:06:46,230
We're going to print out start work out intent.

100
00:06:46,780 --> 00:06:47,460
OK.

101
00:06:47,860 --> 00:06:53,120
And we're going to put a comma and pass in the intent and this is going to go ahead and print out everything

102
00:06:53,130 --> 00:06:57,490
like if I said start a workout for five minutes it would print out the time it would print out the type

103
00:06:57,490 --> 00:07:03,910
of workout it would print out all the relevant information for that particular workout and that's important

104
00:07:03,910 --> 00:07:07,540
because we need to use that later to display the data on the screen.

105
00:07:07,540 --> 00:07:14,470
Next up we're going to go ahead and essentially create a property that holds the spoken phrase what

106
00:07:14,470 --> 00:07:16,740
it thinks we said you know start a walking workout.

107
00:07:16,740 --> 00:07:17,910
It's going to say walk.

108
00:07:17,950 --> 00:07:23,020
Started running workout is going to say run and that we can actually pull that spoken phrase out of

109
00:07:23,020 --> 00:07:26,940
the intent and I'll show you why we need to use this in just a second.

110
00:07:26,950 --> 00:07:29,870
But for now go ahead and use guard.

111
00:07:29,890 --> 00:07:31,390
Because it is optional type.

112
00:07:31,390 --> 00:07:41,920
Guard let spoken phrase that's going to be equal to intent dot workout name which is optional.

113
00:07:41,950 --> 00:07:43,170
Spoken phrase.

114
00:07:43,240 --> 00:07:43,470
OK.

115
00:07:43,480 --> 00:07:47,630
And that's the phrase that Siri is identifying that we are wanting to perform.

116
00:07:47,680 --> 00:07:49,510
Now we're going to set it as that.

117
00:07:49,510 --> 00:07:55,900
But if there is not or else we're going to call our completion handler and we're going to basically

118
00:07:55,900 --> 00:08:00,250
say hey it's complete but it failed because there was no matching workout.

119
00:08:00,250 --> 00:08:02,100
So go ahead and call completion.

120
00:08:02,230 --> 00:08:08,140
And as you can see it's expecting a parameter of type II and start work out.

121
00:08:08,140 --> 00:08:09,610
Intent response.

122
00:08:09,670 --> 00:08:12,950
So let's give it that eye and start work out in response.

123
00:08:13,210 --> 00:08:16,930
And we're going to go ahead and pass in a code and user activity.

124
00:08:16,930 --> 00:08:19,780
OK we'll talk about user activity in just a second.

125
00:08:19,780 --> 00:08:27,730
So what we're going to do is we're going to go ahead and pass in like I said Dot failure no matching

126
00:08:27,730 --> 00:08:28,330
workout.

127
00:08:28,520 --> 00:08:29,210
OK.

128
00:08:29,230 --> 00:08:36,580
So that basically means if I said you know start a workout for five minutes it's going to say I don't

129
00:08:36,580 --> 00:08:41,220
know what workout you meant there's no matching workout by that name or if I said start a cycle workout

130
00:08:41,240 --> 00:08:45,310
will say there's no work out by that name and user activity.

131
00:08:45,370 --> 00:08:50,160
This is basically an item that contains everything the user is doing at the moment.

132
00:08:50,170 --> 00:08:59,560
And so what we can do this stuff is really cool because it actually is going to fill user activity automatically

133
00:08:59,560 --> 00:09:00,270
for us.

134
00:09:00,280 --> 00:09:01,930
We don't even need to create a property for it.

135
00:09:01,930 --> 00:09:07,510
So I'm actually going to set it to nil because at this point if there is no spoken phrase it doesn't

136
00:09:07,510 --> 00:09:10,590
really matter what we were doing because it's not going to work.

137
00:09:10,960 --> 00:09:15,810
At the end of course since this is an else statement we're going to go ahead and return out of our guard.

138
00:09:15,940 --> 00:09:17,530
So we don't get a crash.

139
00:09:17,590 --> 00:09:23,080
So we now have a spoken phrase property and this is where it's really important.

140
00:09:23,080 --> 00:09:30,940
Now the workout intent can handle cycling it can handle swimming it can handle running walking all kinds

141
00:09:30,940 --> 00:09:31,630
of things.

142
00:09:31,810 --> 00:09:36,370
We want to lock this app down just so that it can handle walking and running just to make it simple

143
00:09:36,370 --> 00:09:46,360
and a way you can do that as by typing if spoken phrase is equal to walk or spoken phrase is equal to

144
00:09:47,230 --> 00:09:48,790
run.

145
00:09:48,790 --> 00:09:54,940
We're going to go ahead and basically call the completion handler saying that we you know this is a

146
00:09:54,940 --> 00:09:55,620
good workout.

147
00:09:55,630 --> 00:09:58,240
Let's open the app and show the data.

148
00:09:58,240 --> 00:10:04,250
So call the completion handler and that's going to be of type and start work out response.

149
00:10:04,270 --> 00:10:09,560
Now let's think about if I say start a cycle work out for 20 minutes and my app is not supposed to support

150
00:10:09,560 --> 00:10:12,840
cycle workouts that's where this block is going to come into play.

151
00:10:13,070 --> 00:10:20,390
So we can type completion and passen and I and start work out intent response with a code like so.

152
00:10:20,840 --> 00:10:23,450
Failure no matching workout right just like we did above.

153
00:10:23,450 --> 00:10:29,690
So if there's no matching spoken phrase we're going to fail because it doesn't match if our phrase doesn't

154
00:10:29,690 --> 00:10:32,970
match the two cases that we really care about.

155
00:10:33,020 --> 00:10:37,970
We're gonna say failure no matching workout and user activity can be nil because it doesn't really matter

156
00:10:38,450 --> 00:10:40,260
what happens at that point.

157
00:10:40,280 --> 00:10:46,120
Now if we get to this point that means we've done it successfully we have successfully you know suggests

158
00:10:46,140 --> 00:10:49,750
that all a workout of type Walker of type run.

159
00:10:49,760 --> 00:10:52,910
So let's go ahead and let's pass in a code here.

160
00:10:52,910 --> 00:10:54,440
Now there's a lot of them.

161
00:10:54,650 --> 00:10:59,630
Failure failure no matching workout failure or ongoing workout failure requiring app launch handle and

162
00:10:59,630 --> 00:11:01,150
app ready unspecified.

163
00:11:01,400 --> 00:11:07,190
The one we want is handle an app meaning we want to handle the intent in our app instead.

164
00:11:07,370 --> 00:11:13,580
So if we pass handle an app it's going to say hey sear or leg day is going to continue with your request

165
00:11:13,580 --> 00:11:17,140
and it'll open up in our day app which is pretty cool.

166
00:11:17,180 --> 00:11:20,020
Now for user activity what we're actually going to do.

167
00:11:20,150 --> 00:11:27,210
I'm actually gonna go ahead and create a property here called user activity and it's going to be whip's

168
00:11:27,210 --> 00:11:34,790
activity and it's going to be of type and s user activity and that's user activity and it's going to

169
00:11:34,790 --> 00:11:38,760
be optional and I'm going to set it to be nil from the get go.

170
00:11:38,900 --> 00:11:41,180
And you know what I'm actually gonna go ahead and copy this.

171
00:11:41,210 --> 00:11:45,530
Instead of saying nil I'm just going to pass in user activity every time because it's either going to

172
00:11:45,530 --> 00:11:48,290
be nil or have a value.

173
00:11:48,500 --> 00:11:55,250
And the cool thing is when we actually do this when we call the intent user activity is going to be

174
00:11:55,250 --> 00:11:56,750
passed of value.

175
00:11:56,870 --> 00:11:59,070
And so that's why we're going to pass it in here.

176
00:11:59,510 --> 00:12:01,840
So that's that's the reason for that.

177
00:12:01,940 --> 00:12:03,400
Now it says that it's never.

178
00:12:03,440 --> 00:12:04,180
Oh OK.

179
00:12:04,190 --> 00:12:07,400
We're going to just change it to a lot because we're never actually we're not.

180
00:12:07,430 --> 00:12:09,490
We are not modifying it.

181
00:12:09,670 --> 00:12:12,600
And so we're going to go ahead and actually set it like so.

182
00:12:12,950 --> 00:12:16,210
So let's think what do we need to do next.

183
00:12:16,220 --> 00:12:18,440
We are handling the intent.

184
00:12:18,470 --> 00:12:20,750
Our intent handler here is done.

185
00:12:20,750 --> 00:12:24,980
We have set it up to focus on the eye and start work out intent.

186
00:12:25,010 --> 00:12:27,160
That's awesome.

187
00:12:27,320 --> 00:12:29,720
I think we should go test this out personally.

188
00:12:29,930 --> 00:12:31,760
But there's one thing we got to do.

189
00:12:32,330 --> 00:12:37,400
It's not going to know to actually call this other target unless we specify it in the app.

190
00:12:37,400 --> 00:12:38,910
Delegate Okay.

191
00:12:39,230 --> 00:12:44,540
So go ahead and open your app delegate here and there is a function that we can call or I guess a delegate

192
00:12:44,540 --> 00:12:48,410
method rather called continue user activity.

193
00:12:48,650 --> 00:12:49,230
OK.

194
00:12:49,490 --> 00:12:58,440
And this is where that user activity is going to be created and then passed into our extension.

195
00:12:58,800 --> 00:12:59,030
OK.

196
00:12:59,030 --> 00:13:01,640
So what we're going to do is below did finish launching.

197
00:13:01,670 --> 00:13:08,550
We're going to call continue user activity and it's right here it's this long one application continue

198
00:13:08,550 --> 00:13:10,860
USIA activity restauration handler.

199
00:13:10,880 --> 00:13:11,330
OK.

200
00:13:11,660 --> 00:13:13,020
That's what we're going to call.

201
00:13:13,160 --> 00:13:17,900
And in order to actually access the intent and all the silicates stuff we're going to go ahead and import

202
00:13:17,930 --> 00:13:19,990
intense like so.

203
00:13:20,420 --> 00:13:24,740
And now we're going to go ahead and actually call guard let intent.

204
00:13:24,980 --> 00:13:28,420
And we're going to set it to be equal to the user activity.

205
00:13:28,750 --> 00:13:29,220
OK.

206
00:13:29,240 --> 00:13:30,020
Because that's from here.

207
00:13:30,020 --> 00:13:31,750
Continue user activity.

208
00:13:31,940 --> 00:13:35,410
We're going to pass that in to interaction.

209
00:13:35,490 --> 00:13:40,290
We're going to get the interaction from that which is of type II and interaction.

210
00:13:40,550 --> 00:13:40,820
OK.

211
00:13:40,820 --> 00:13:45,830
Now it says right here when Siri Kitt launches your app it fills this property with the intent and response

212
00:13:45,830 --> 00:13:51,890
information that you're launching for your app so we can go ahead and call DOT intent and we can actually

213
00:13:51,890 --> 00:13:58,550
get out the exact intent that we wanted which we know is of type and start work out intent.

214
00:13:58,550 --> 00:14:05,390
So we should cast that is that I then start work out intent OK but since this is Gardley we should call

215
00:14:05,450 --> 00:14:09,860
else meaning if that doesn't work we're going to go ahead and print.

216
00:14:10,160 --> 00:14:14,180
And this is just the message for our self saying app delegate.

217
00:14:14,180 --> 00:14:24,080
Start work out intent false meaning it didn't work then we're going to go ahead and return false because

218
00:14:24,080 --> 00:14:28,580
this function is expecting a boolean to be returned back.

219
00:14:28,580 --> 00:14:35,570
So this means that we are we were not able to successfully continue user activity from Siri and now

220
00:14:35,780 --> 00:14:41,120
we have an intent property assuming that it comes in from the user activity which is created using this

221
00:14:41,120 --> 00:14:41,600
intent.

222
00:14:41,630 --> 00:14:47,090
Because remember the user activity is set and if it is successful it's passed in through our completion

223
00:14:47,090 --> 00:14:48,200
handler.

224
00:14:48,200 --> 00:14:50,280
So let's go ahead and down below here.

225
00:14:50,300 --> 00:14:59,060
Now that we have our intent we're going to go ahead and basically print that it was successful app delegate

226
00:14:59,630 --> 00:15:11,000
start work out it is true then we're going to just go ahead and print out the intent and we'll see what

227
00:15:11,000 --> 00:15:11,570
we get.

228
00:15:11,750 --> 00:15:14,890
Then at the end we return true because it was successful.

229
00:15:14,960 --> 00:15:15,870
Very cool.

230
00:15:16,190 --> 00:15:26,360
So now we are able to continue our user activity but we have not yet connected our app and the Siri

231
00:15:26,510 --> 00:15:27,650
related stuff.

232
00:15:27,710 --> 00:15:30,140
We have our intent here and with that.

233
00:15:30,140 --> 00:15:30,560
Check it out.

234
00:15:30,560 --> 00:15:37,640
If I if I type intent dot I can get the gold value which is the amount of time I asked I could get the

235
00:15:37,670 --> 00:15:38,120
work out.

236
00:15:38,120 --> 00:15:41,350
Name you know run or walk or cycle or whatever.

237
00:15:41,600 --> 00:15:46,730
I can pull out all that information but we have not yet set up a way for our workout books to access

238
00:15:46,730 --> 00:15:47,690
that and to get that.

239
00:15:47,690 --> 00:15:52,040
So let's go ahead though we have our intent here.

240
00:15:52,040 --> 00:15:57,890
We have our app delegate set up to continue that information.

241
00:15:58,310 --> 00:15:59,500
Let's go ahead and let's test it.

242
00:15:59,630 --> 00:16:00,770
Let's see what we actually get.

243
00:16:00,770 --> 00:16:07,460
So let's select our leg day scheme let's build it to iPhone 8 and let's see how it works we're going

244
00:16:07,460 --> 00:16:12,610
to just give it a test and we'll say you know start a workout in this app.

245
00:16:13,000 --> 00:16:13,470
Ok cool.

246
00:16:13,490 --> 00:16:18,230
So start a walking workout.

247
00:16:18,560 --> 00:16:21,840
I don't know let's see how it works.

248
00:16:23,350 --> 00:16:27,530
Leg day.

249
00:16:28,070 --> 00:16:28,950
Ok cool.

250
00:16:29,210 --> 00:16:32,840
So that's that's where we set up in our intent handler here.

251
00:16:32,840 --> 00:16:33,380
That was good.

252
00:16:33,380 --> 00:16:37,940
We said start a walk work out and the cool thing you can say walking or walking it understands that

253
00:16:37,940 --> 00:16:38,850
you mean walk.

254
00:16:38,990 --> 00:16:44,820
Now we handled it in the app and we passed the user activity so watch what happens if I open leg day.

255
00:16:44,940 --> 00:16:45,590
Look what we get.

256
00:16:45,630 --> 00:16:46,940
We get a print out here.

257
00:16:47,130 --> 00:16:49,320
Start work out intent is true.

258
00:16:49,590 --> 00:16:53,550
And we have all this information the workout name is walk.

259
00:16:53,550 --> 00:16:55,920
We don't have a location type or a goal unit type.

260
00:16:55,920 --> 00:16:58,160
And the goal value is null.

261
00:16:58,160 --> 00:16:59,940
Now that's because we didn't set a time.

262
00:16:59,940 --> 00:17:05,030
Now check it out if I said start a five minute walking workout.

263
00:17:07,180 --> 00:17:07,690
Leg day

264
00:17:11,690 --> 00:17:17,850
if I open it it says Go value 300 because five minutes is the same thing as 300 seconds.

265
00:17:18,160 --> 00:17:19,570
Wow that's really really cool.

266
00:17:19,570 --> 00:17:21,130
Let's try.

267
00:17:21,340 --> 00:17:25,090
Let's try saying a phrase that it doesn't know.

268
00:17:25,090 --> 00:17:28,820
Start a workout.

269
00:17:30,380 --> 00:17:35,560
Cool call leg day couldn't find a match and work out if we open it up it's going to say no and no it

270
00:17:35,560 --> 00:17:38,080
could not successfully find a workout.

271
00:17:38,080 --> 00:17:39,000
Let's try it again.

272
00:17:39,040 --> 00:17:43,870
Let's just let's try one that is a workout but is not accepted because we can find it to walk or run

273
00:17:44,770 --> 00:17:47,750
start a 23 minute run cycle workout

274
00:17:51,390 --> 00:17:51,900
cycle

275
00:17:54,450 --> 00:18:00,470
started 23 minute cycle workout.

276
00:18:01,310 --> 00:18:02,100
OK.

277
00:18:02,370 --> 00:18:08,070
So even though it is a successful workout that we can actually use it just printed out cycle.

278
00:18:08,220 --> 00:18:14,040
We can't actually use it in our app because we have locked it down to only accepting walk or run.

279
00:18:14,040 --> 00:18:15,290
WOW GUYS IT'S WORKING.

280
00:18:15,290 --> 00:18:16,230
That's really really cool.

281
00:18:16,230 --> 00:18:22,410
So we are handling our intent which is to start a workout or run or or walk.

282
00:18:22,610 --> 00:18:29,400
And so guys this is really cool our app delegate here is creating an instance of user activity and it's

283
00:18:29,400 --> 00:18:33,920
passing it in to our intent that is seriously the coolest stuff.

284
00:18:33,930 --> 00:18:36,440
So yeah guys this is amazing.

285
00:18:36,510 --> 00:18:43,050
We can now successfully handle intense for starting a workout using Syrie kit and use our app delegate

286
00:18:43,050 --> 00:18:45,570
to continue that activity in our application.

287
00:18:45,570 --> 00:18:51,120
So very cool stuff in the next video we're going to actually configure these results the ones that printed

288
00:18:51,120 --> 00:18:58,020
out here the goal value as well as the workout name using a data service we're going to create a singleton.

289
00:18:58,200 --> 00:19:04,140
And this is actually the recommended method by Apple is to create a singleton and then use your intent

290
00:19:04,140 --> 00:19:11,010
handler to pass the intent to your app delegate and then use your app delegate to set an instance of

291
00:19:11,460 --> 00:19:13,100
and start work out intent.

292
00:19:13,290 --> 00:19:17,700
And then you can use that singleton class to access all that data from your workout.

293
00:19:17,740 --> 00:19:22,680
VC OK so we're going to use a singleton class to manage the data that's being passed around so we have

294
00:19:22,680 --> 00:19:27,960
one static instance of data that's available to us throughout the entire lifecycle of the application.

295
00:19:27,960 --> 00:19:32,940
So let's head over to the next video and let's configure those results using a data service.

296
00:19:32,940 --> 00:19:33,790
I'll see you there.
