1
00:00:07,240 --> 00:00:11,710
Hey everybody was going on this is Caleb with Def slopes dot com and in this video we're going to go

2
00:00:11,710 --> 00:00:16,860
ahead and request Siri permissions and go ahead and enable that that we can use.

3
00:00:16,930 --> 00:00:19,260
Siri that's kind of an important piece of this course.

4
00:00:19,270 --> 00:00:24,200
So let's go ahead and let's open our project here and let's get started.

5
00:00:24,340 --> 00:00:30,580
So in order to do this we're going to just start with work out VC as it is and what we need to do to

6
00:00:30,580 --> 00:00:37,130
actually use Siri kit is we need to import a framework from Apple called intense and not like intense

7
00:00:37,270 --> 00:00:41,460
like intense like I intend to do something so go ahead and import.

8
00:00:41,570 --> 00:00:42,740
Intense.

9
00:00:42,880 --> 00:00:49,020
And this library actually is going to give us access to all the cool Siri cat stuff and all we need

10
00:00:49,020 --> 00:00:56,650
to do to request access for Siri is to call upon a class called Ayane preferences and there's a function

11
00:00:56,740 --> 00:01:00,580
inside that called request Siri authorization.

12
00:01:00,580 --> 00:01:08,440
So go ahead and call I and crafts like so preferences and preferences dot and you'll see this has to

13
00:01:08,440 --> 00:01:10,240
do with requesting Siri.

14
00:01:10,260 --> 00:01:17,160
Now you can access the Siri authorization status Siri language code and you can request Siri authorization

15
00:01:17,170 --> 00:01:23,620
so select that and then for the handler go ahead and just press enter and it's going to return and I

16
00:01:23,630 --> 00:01:27,520
end Siri authorization status which is either authorized or not authorized.

17
00:01:27,670 --> 00:01:29,610
So just name it status.

18
00:01:29,800 --> 00:01:35,310
And what we're going to do is we're going to check if the status is authorized will print Siri get authorized.

19
00:01:35,470 --> 00:01:40,030
Otherwise we'll just say unauthorized and it's not the most elegant way that we could do it.

20
00:01:40,030 --> 00:01:43,990
But at this point all we really care about is if it's authorized or not.

21
00:01:44,020 --> 00:01:55,060
So go ahead and type if status equals and Siri authorization status dot authorized.

22
00:01:55,060 --> 00:02:01,250
OK we're going to go ahead and just print out Siri kit auth or arised.

23
00:02:01,510 --> 00:02:06,460
And this is just for our knowledge we're just going to print it out to just show when the authorization

24
00:02:06,460 --> 00:02:08,020
actually happens.

25
00:02:08,110 --> 00:02:15,450
But if it's not authorized we're going to present or print rather Syrie kit on authorized.

26
00:02:15,720 --> 00:02:16,280
OK.

27
00:02:16,570 --> 00:02:22,760
So very cool at this point we have successfully requested Siri authorization.

28
00:02:22,840 --> 00:02:24,290
So that's awesome.

29
00:02:24,370 --> 00:02:26,060
But there's one thing we need to do now.

30
00:02:26,080 --> 00:02:27,460
If you know anything about Iowa.

31
00:02:27,520 --> 00:02:33,030
You know that when we request certain services from our device we have to give a usage description.

32
00:02:33,030 --> 00:02:39,340
It's the same for requesting location requesting you know the user's microphone or the camera.

33
00:02:39,340 --> 00:02:41,480
We have to tell them why we're trying to use it.

34
00:02:41,480 --> 00:02:49,420
So to do so go into info up the list click the plus button right here on a supported interface orientations

35
00:02:49,450 --> 00:02:57,190
and go ahead and type privacy dash Siri usage and you'll see there is a Siri usage description.

36
00:02:57,190 --> 00:02:59,120
Now the reason we're using this.

37
00:02:59,500 --> 00:03:10,700
We're going to say we want to use your voice to start a workout session.

38
00:03:11,380 --> 00:03:15,910
Press enter and that's why we're using Siri to start a workout session.

39
00:03:15,910 --> 00:03:18,060
So that is finished.

40
00:03:18,160 --> 00:03:25,420
We have used iron preferences to request Siri authorization and that is called When the view loads.

41
00:03:25,480 --> 00:03:26,130
OK.

42
00:03:26,350 --> 00:03:27,820
Now that's pretty cool.

43
00:03:27,970 --> 00:03:31,930
And that is how we're just going to use it for now so I don't know about you but I want to build and

44
00:03:31,930 --> 00:03:32,230
run it.

45
00:03:32,260 --> 00:03:35,960
I want to see if we can successfully authorize our Siri.

46
00:03:36,070 --> 00:03:37,880
So click build and run.

47
00:03:37,890 --> 00:03:43,420
It's going to pull open the simulator here in just one moment and we'll be able to see if what we did

48
00:03:43,420 --> 00:03:44,480
was successful.

49
00:03:46,320 --> 00:03:51,420
So it's going to do its thing it's going to think we're going to check and when it pops open we get

50
00:03:51,420 --> 00:03:52,840
a crash.

51
00:03:52,860 --> 00:03:54,210
Why is that interesting.

52
00:03:54,210 --> 00:03:56,370
So let's see what the problem is.

53
00:03:56,550 --> 00:04:03,600
Terminating app due to uncaught exception an internal inconsistency exception use of the class I preferences

54
00:04:03,600 --> 00:04:10,260
from an app requires the entitlement camarade Apple doc developer what Siri did you enable the Syria

55
00:04:10,260 --> 00:04:13,080
capability in your X code project.

56
00:04:13,080 --> 00:04:13,870
We didn't.

57
00:04:13,950 --> 00:04:17,760
So that's another important thing we need to think about that you may not have realized you can't just

58
00:04:17,760 --> 00:04:18,810
do it in code.

59
00:04:18,870 --> 00:04:25,520
We need to go into our project go to capabilities and turn on Siri check it out.

60
00:04:25,680 --> 00:04:26,760
I'm going to go ahead and turn it on.

61
00:04:26,760 --> 00:04:32,210
It's going to automatically do its thing and it's going to add the Siri feature into your app ID.

62
00:04:32,280 --> 00:04:33,560
Now we have a leg day.

63
00:04:33,600 --> 00:04:36,300
Entitlements file and Siri is a part of it.

64
00:04:36,300 --> 00:04:40,250
So now we actually have that proper entitlement from the apple developer site.

65
00:04:40,320 --> 00:04:42,620
So build and run one more time.

66
00:04:42,630 --> 00:04:45,540
And now we should have that problem alleviated.

67
00:04:45,540 --> 00:04:52,590
We shouldn't crash for that reason look at this would you like to use leg day with Siri some of your

68
00:04:52,590 --> 00:04:55,250
leg day data will be sent to Apple to process your requests.

69
00:04:55,260 --> 00:04:57,710
We want to use your voice to start a workout session.

70
00:04:57,870 --> 00:05:02,490
Now when I click don't allow it should print out saying Siri kit.

71
00:05:02,510 --> 00:05:04,020
Unauthorized.

72
00:05:04,530 --> 00:05:06,030
And it did look at that.

73
00:05:06,060 --> 00:05:10,170
Now I'm going to build and run it again so that we get that request again.

74
00:05:10,410 --> 00:05:13,860
And let's see what we get to do.

75
00:05:14,150 --> 00:05:19,500
OK so it's still saying unauthorized and I think that's because obviously it saves it because we set

76
00:05:19,500 --> 00:05:21,090
that info up the list.

77
00:05:21,120 --> 00:05:24,290
So let me delete the app and there we go.

78
00:05:24,480 --> 00:05:26,430
Let me rerun it here.

79
00:05:27,090 --> 00:05:31,950
Now that it's deleted we have a fresh copy and it's going to ask me if I want to use leg day with Siri.

80
00:05:31,950 --> 00:05:37,320
So now if I click OK it says Siri could authorize then of course if I build and run it again it would

81
00:05:37,320 --> 00:05:43,560
still be authorized because that is now set and this app is now ready to use Siri I'm not even kidding

82
00:05:43,590 --> 00:05:45,810
it is that easy to use.

83
00:05:45,810 --> 00:05:47,150
So amazing work guys.

84
00:05:47,160 --> 00:05:51,840
In the next video we're going to go ahead and create what's called a Siri kit intense app extension.

85
00:05:51,990 --> 00:05:56,280
And we're going to configure it for use with a workout specifically there are some things we got to

86
00:05:56,280 --> 00:05:59,730
do to make sure it's ready for a workout.

87
00:05:59,820 --> 00:06:02,000
So I hope you're excited it's really awesome stuff.

88
00:06:02,070 --> 00:06:04,010
But we we now have access to Siri.

89
00:06:04,020 --> 00:06:05,220
Thanks to I-and preferences.

90
00:06:05,220 --> 00:06:09,690
So let's head over to the next video and let's create that Siri kit intense app extension.

91
00:06:09,700 --> 00:06:10,170
I'll see you there.
