1
00:00:00,330 --> 00:00:01,020
Welcome back.

2
00:00:01,170 --> 00:00:06,210
And this week, we're going to finalize the notification feature and pretty much finalized the application,

3
00:00:06,210 --> 00:00:09,360
even though there is still a lot potentially to do.

4
00:00:09,600 --> 00:00:16,190
So we still have the functionality, for example, to delete a user from the members list or.

5
00:00:16,950 --> 00:00:18,630
Yeah, I mean, there are so many different things.

6
00:00:18,630 --> 00:00:21,420
You can definitely extend the application to your liking.

7
00:00:21,450 --> 00:00:23,540
Now, this is just the beginning.

8
00:00:23,550 --> 00:00:29,100
Of course, if you look at complex and fully fledged project management tools, they have a lot of more

9
00:00:29,100 --> 00:00:35,670
features, but basically all of them or most of them at least build up on things that you have learned

10
00:00:35,670 --> 00:00:36,270
so far.

11
00:00:36,330 --> 00:00:36,770
All right.

12
00:00:36,780 --> 00:00:43,800
So by the time that you have gotten this far, you should be able to add all of those features to your

13
00:00:43,800 --> 00:00:44,450
application.

14
00:00:44,820 --> 00:00:52,620
But for now, the last thing that I want to show you is how to add a notification to display it inside

15
00:00:52,620 --> 00:00:55,490
of the user's phone.

16
00:00:55,830 --> 00:00:57,900
So I'm testing it right now.

17
00:00:58,080 --> 00:01:01,680
I have the application installed on my phone.

18
00:01:01,680 --> 00:01:09,300
So I'm going to create a new board, which I'm going to call notifications test.

19
00:01:10,400 --> 00:01:10,940
Bought.

20
00:01:11,570 --> 00:01:22,100
All right, that is created and then I will assign a member to it, which will be the member who uses

21
00:01:22,100 --> 00:01:23,730
this emulator.

22
00:01:24,020 --> 00:01:26,610
OK, who is logged in into the simulator?

23
00:01:26,960 --> 00:01:27,800
Let me add that.

24
00:01:28,610 --> 00:01:31,510
And we could see a little icon here at the top popped up.

25
00:01:31,940 --> 00:01:32,720
Let's look at it.

26
00:01:33,320 --> 00:01:39,020
And you can see assigned to the board notification test board, you have been assigned to the new board

27
00:01:39,020 --> 00:01:39,740
by Frank.

28
00:01:40,500 --> 00:01:47,410
OK, so Frank is the user that I logged in with on the application or in the application on my phone,

29
00:01:47,870 --> 00:01:51,060
and that's exactly what I'm now getting here.

30
00:01:51,590 --> 00:01:51,950
All right.

31
00:01:51,960 --> 00:01:59,720
So now I can click on this and that Will sent me over to the project manager application, and that

32
00:01:59,720 --> 00:02:00,350
is pretty much it.

33
00:02:00,560 --> 00:02:03,480
So that is the notification that I wanted to show you.

34
00:02:04,250 --> 00:02:06,110
And now let's get into it.

35
00:02:08,139 --> 00:02:13,850
And by the way, if you want to learn more about push notifications using Firebase and Advance Best

36
00:02:13,900 --> 00:02:16,370
clients, then I can recommend this link.

37
00:02:16,660 --> 00:02:19,310
So here are a bunch of explanations for what's going on.

38
00:02:19,330 --> 00:02:24,810
So here, for example, the notification you can see here, small icon is number one.

39
00:02:24,910 --> 00:02:33,790
And this required a set with small icon than name then timestamp, which is now large icon with just

40
00:02:33,790 --> 00:02:36,960
as I can hear the title and text.

41
00:02:37,020 --> 00:02:43,870
OK, so all of that as explained in this article, also the difference between notification and data

42
00:02:43,870 --> 00:02:49,870
messages and then the code as well, even though it is Java code.

43
00:02:49,870 --> 00:02:53,200
But you can really easily apply that to Scotland as well.

44
00:02:53,910 --> 00:02:58,870
OK, so we are going to build some of the stuff that you can see here in this video.

45
00:02:59,170 --> 00:03:03,450
By the way, he uses an advanced rest client in order to trigger the event.

46
00:03:03,460 --> 00:03:07,510
So there are multiple ways, of course, how you could do a notification.

47
00:03:07,750 --> 00:03:10,660
One is from the server side, one is from client side.

48
00:03:10,900 --> 00:03:18,430
And we are not going to do the feature where you actually get triggered a notification if the timer

49
00:03:18,430 --> 00:03:19,060
runs up.

50
00:03:19,090 --> 00:03:21,190
So, for example, we have due dates.

51
00:03:21,190 --> 00:03:21,490
Right.

52
00:03:21,760 --> 00:03:26,590
But those due dates, they currently don't really represent anything in the application.

53
00:03:26,870 --> 00:03:28,000
They are just a date there.

54
00:03:28,370 --> 00:03:33,040
Of course, you could implement the feature where the user gets a notification of the due date is coming.

55
00:03:33,070 --> 00:03:37,000
So let's say a day before the due date or maybe a week before the due date.

56
00:03:37,210 --> 00:03:43,560
But that would require for you to set up this whole functionality in the backend.

57
00:03:43,570 --> 00:03:46,540
So this cannot just be done by the application itself.

58
00:03:46,570 --> 00:03:51,180
OK, so this is why we are going to keep it simple.

59
00:03:51,190 --> 00:03:52,750
We are not looking at the back end.

60
00:03:52,750 --> 00:04:00,130
We are just going to add the feature that once you add a user to a board, that user gets a notification

61
00:04:00,160 --> 00:04:00,910
on his phone.

62
00:04:01,870 --> 00:04:06,880
And I think this is already good enough and this is already going to teach you the important basics

63
00:04:06,880 --> 00:04:07,300
of that.

64
00:04:09,530 --> 00:04:15,140
Of course, when it comes to anything that you learn here, you'll find something in the documentation

65
00:04:15,140 --> 00:04:15,950
about it as well.

66
00:04:15,980 --> 00:04:16,279
All right.

67
00:04:16,279 --> 00:04:18,519
So you can check out the notification there.

68
00:04:18,529 --> 00:04:27,200
Things are explained as well with also the same image that you see here with some explanations and expanded

69
00:04:27,200 --> 00:04:29,420
notification if you ever need to add and so forth.

70
00:04:29,450 --> 00:04:34,850
So if you want to create your very own notifications, there are a lot of settings that you can set

71
00:04:34,850 --> 00:04:35,060
up.

72
00:04:35,370 --> 00:04:37,700
OK, I'm just going to show you one way of doing it.

73
00:04:37,730 --> 00:04:42,410
Of course, there are plenty of ways of doing it and things to consider and also things to consider

74
00:04:42,560 --> 00:04:46,040
when working with different versions of Android and so forth.

75
00:04:47,750 --> 00:04:55,070
All right, but now let's get into coding, so the thing is, we are going to require quite some constants

76
00:04:55,070 --> 00:04:58,350
here, which we will need for the notification.

77
00:04:58,850 --> 00:05:04,190
OK, so I'm just going to post them in here and go over them real quick.

78
00:05:04,200 --> 00:05:06,350
So we will need the basic URL.

79
00:05:06,840 --> 00:05:09,140
This is to have some basic URL.

80
00:05:09,260 --> 00:05:14,210
If you want to send something, then the ACM authorization, which is going to be a string that we call

81
00:05:14,210 --> 00:05:22,010
like that SCMP, which we're just going to call key DEVESON server key to which you need to use your

82
00:05:22,250 --> 00:05:23,690
own server key here.

83
00:05:25,470 --> 00:05:33,720
Then the title, the message, the data and the string for the key to, OK, so we have a bunch of keys

84
00:05:33,720 --> 00:05:36,400
that we need and then we will assign data to that key.

85
00:05:36,420 --> 00:05:42,330
So as you saw earlier, we need a title, we need a message, and then we need to data and who we want

86
00:05:42,330 --> 00:05:43,020
to send it to.

87
00:05:45,390 --> 00:05:51,120
Now, if you might wonder where to get the Afkham server key from, well, you can Google that, by

88
00:05:51,120 --> 00:05:57,840
the way, just Google find your sender key and silver key that you will find that you need to go to

89
00:05:57,840 --> 00:06:02,280
your project settings and they're on their cloud messaging.

90
00:06:02,290 --> 00:06:03,890
You will find your server key.

91
00:06:03,960 --> 00:06:04,350
All right.

92
00:06:04,350 --> 00:06:04,680
So.

93
00:06:05,860 --> 00:06:08,830
Here on the clock, you can get your server.

94
00:06:08,830 --> 00:06:14,650
Q OK, so if you download my code and of course you want to replace this server key.

95
00:06:15,930 --> 00:06:16,830
That you have their.

96
00:06:19,990 --> 00:06:20,590
All right.

97
00:06:22,190 --> 00:06:28,280
The next step that we will need to take is to create an async task inside of our members activity,

98
00:06:28,280 --> 00:06:31,350
because that's where I want to trigger this whole thing, right.

99
00:06:31,370 --> 00:06:36,260
So once we go to the members activity and we add a new member, that members should be notified.

100
00:06:36,680 --> 00:06:38,160
OK, so let's go over there.

101
00:06:38,660 --> 00:06:43,900
Let's go to the activities here and then members activity.

102
00:06:44,120 --> 00:06:49,400
And I'm just going to create an amazing task at the very bottom here and in a class this time so that

103
00:06:49,400 --> 00:06:51,890
I can use it inside of this member's activity.

104
00:06:52,190 --> 00:07:01,070
So private in our class, send notification to user async.

105
00:07:02,150 --> 00:07:05,660
Task, which should be an async task.

106
00:07:06,940 --> 00:07:10,480
Of any void and string.

107
00:07:13,060 --> 00:07:16,030
And then, of course, we need to implement.

108
00:07:17,700 --> 00:07:19,560
Its members, so to sue that.

109
00:07:20,900 --> 00:07:22,460
So here in parliament members.

110
00:07:25,790 --> 00:07:35,570
And hers only to do in background what I'm also going to add is the en pre execute, so on pre execute

111
00:07:35,870 --> 00:07:38,200
and which I'm just going to show the progress dialogue.

112
00:07:38,210 --> 00:07:39,380
Nothing too fancy.

113
00:07:39,710 --> 00:07:43,850
Just before we do that, we want to show the progress dialogue.

114
00:07:43,850 --> 00:07:51,820
And after we do that, so the unposed executed pretty much we want to highlight the progress dialogue.

115
00:07:51,920 --> 00:07:54,020
So unposed execute.

116
00:07:55,980 --> 00:07:58,140
Hide progress, taluk.

117
00:08:01,630 --> 00:08:07,420
All right, if you want to see what kind of Jason log you got there, you can, of course, also use

118
00:08:07,420 --> 00:08:10,380
the log with the result of that post execute.

119
00:08:11,020 --> 00:08:13,000
But now that's implemented in background.

120
00:08:13,240 --> 00:08:17,860
OK, so this is where the magic happens and this is where a lot is going to happen because we need to

121
00:08:17,860 --> 00:08:19,690
take care of a lot of things here.

122
00:08:20,560 --> 00:08:27,670
So first of all, we will need a variable, which will be our result, which will be a string, and

123
00:08:27,670 --> 00:08:29,560
then we will return.

124
00:08:29,560 --> 00:08:30,400
Just result.

125
00:08:31,420 --> 00:08:33,080
At the end, so that's the idea.

126
00:08:33,390 --> 00:08:39,400
OK, but now, of course, result is empty and we need to initialize it well in order to initialize

127
00:08:39,400 --> 00:08:39,470
it.

128
00:08:39,490 --> 00:08:40,919
We need to prepare some more things.

129
00:08:40,960 --> 00:08:50,920
So here we need a connection first, which will be an HTP Eurorail connection, which I'm going to assign

130
00:08:50,920 --> 00:08:51,430
now to.

131
00:08:51,460 --> 00:08:53,140
For now, it's going to be a nullable.

132
00:08:53,500 --> 00:08:55,690
And then what we try to do is.

133
00:08:56,760 --> 00:09:01,560
To set a you URL based on Constance.

134
00:09:02,780 --> 00:09:07,340
That the base euro, OK, so.

135
00:09:08,460 --> 00:09:15,780
Use this concept of the be prepared, which is this basic URL here of consent will oppose consent and

136
00:09:15,780 --> 00:09:16,110
then.

137
00:09:17,540 --> 00:09:23,720
We need to import Eurail today for that, of course, and that's going to be the job on it.

138
00:09:25,980 --> 00:09:28,880
And then we can use our connection up here.

139
00:09:29,790 --> 00:09:36,960
Do hope to zero Soheir connection is going to be your eldard open connection.

140
00:09:38,010 --> 00:09:41,790
As an HTP Earl connection.

141
00:09:43,440 --> 00:09:50,180
All right, then we can assign some settings to this connection, so do we want to do Output's?

142
00:09:50,550 --> 00:09:51,110
Yes.

143
00:09:51,240 --> 00:09:55,520
Do you want to do input as well to input?

144
00:09:55,560 --> 00:09:56,830
Let's set that through as well.

145
00:09:58,420 --> 00:09:58,780
Then.

146
00:10:00,080 --> 00:10:07,040
We can add another sighting to it, which is instant's follow redirects, and I'm going to set that

147
00:10:07,040 --> 00:10:07,610
to false.

148
00:10:08,940 --> 00:10:14,820
So the sets, whether the HTTP redirect should be automatically followed by this instance and the default

149
00:10:14,820 --> 00:10:19,860
values I value comes from the follow redirects, which defaults are true.

150
00:10:20,100 --> 00:10:25,530
So that's why we need to specifically set that to false if we don't want to redirect and then we can

151
00:10:25,530 --> 00:10:29,940
set the request method for this.

152
00:10:31,190 --> 00:10:31,810
Connection.

153
00:10:31,850 --> 00:10:37,420
And I'm just going to say I want to do a post request, so I'm sending information over to the server.

154
00:10:37,940 --> 00:10:43,940
So before we used to get requests to get data, when we worked with Jason and other APIs.

155
00:10:43,940 --> 00:10:49,160
But this time we are actually sending data because we want to send a notification to the server so that

156
00:10:49,160 --> 00:10:55,910
the server then notifies the user's application that it should trigger something or his phone, that

157
00:10:55,910 --> 00:10:57,290
it should trigger a notification.

158
00:10:57,720 --> 00:11:04,010
OK, so we're posting or yeah, we're using this post request to post something and then we need to

159
00:11:04,010 --> 00:11:07,190
set to request properties of that connection.

160
00:11:07,610 --> 00:11:13,970
OK, I'm just going to post those three settings that we need to give it here because they are always

161
00:11:14,240 --> 00:11:15,270
pretty much the same.

162
00:11:15,290 --> 00:11:23,120
So we set to request property to content type and their the value is the application should slash Jason.

163
00:11:23,130 --> 00:11:24,490
So we sent the data is Jason.

164
00:11:24,950 --> 00:11:29,210
Then we say that the char set, the character set should be UTF eight.

165
00:11:29,510 --> 00:11:37,250
So it just tells the server of which type of data the characters will be.

166
00:11:37,700 --> 00:11:38,980
There are multiple different sets.

167
00:11:39,000 --> 00:11:44,260
UTF eight is the most common one and it contains a lot of different characters.

168
00:11:44,510 --> 00:11:53,480
So that's basically the idea here behind this UTF eight then set of property is except with application

169
00:11:53,480 --> 00:11:53,990
JSON.

170
00:11:55,090 --> 00:11:58,550
All right, so we have those three here, and this will allow us to.

171
00:11:59,910 --> 00:12:01,470
Pretty much set post requests.

172
00:12:03,740 --> 00:12:07,250
OK, so these are the default settings, which are pretty much always the same.

173
00:12:07,490 --> 00:12:13,820
Now comes the one that we need to use in order to set the right authorization and everything.

174
00:12:13,850 --> 00:12:21,330
OK, so set request property with constants dot F.C. m underscore authorization.

175
00:12:21,350 --> 00:12:23,090
So what is Afkham authorization?

176
00:12:23,120 --> 00:12:27,710
Well it's the key or this have some key authorization.

177
00:12:27,920 --> 00:12:30,290
But now what is the string that we want to pass to it.

178
00:12:31,740 --> 00:12:34,140
Well, it is our.

179
00:12:35,860 --> 00:12:39,520
Constants that have s.m key.

180
00:12:41,390 --> 00:12:42,500
Is equal to.

181
00:12:45,230 --> 00:12:49,010
Constance, so here again, Constance thought.

182
00:12:50,350 --> 00:12:53,370
I have seen them underscore Savitsky.

183
00:12:54,540 --> 00:12:57,720
OK, so basically we're sending something like.

184
00:13:00,610 --> 00:13:01,460
Have s.m.

185
00:13:02,560 --> 00:13:05,890
He should be the server key that we have here.

186
00:13:07,800 --> 00:13:09,440
So that's the length that we have here.

187
00:13:10,330 --> 00:13:19,810
OK, so we need to pass that as information to the Afkham authorization key, so basically because property

188
00:13:19,810 --> 00:13:21,450
always has a key and a value.

189
00:13:21,820 --> 00:13:22,340
All right.

190
00:13:22,360 --> 00:13:29,170
And the key is the same authorization which we had, which is just the value, the string authorization.

191
00:13:29,620 --> 00:13:34,940
And then the value is a combination of the key and the silver key.

192
00:13:35,350 --> 00:13:36,730
So basically saying.

193
00:13:39,570 --> 00:13:43,440
Key equals and then whatever we have in here.

194
00:13:44,310 --> 00:13:48,120
OK, so this whole party here pretty much set in their.

195
00:13:49,650 --> 00:13:52,110
OK, so this is the information that we're sending over.

196
00:13:54,880 --> 00:14:00,970
Or pretty much setting as our request properties for the connection, so you can see we need to set

197
00:14:00,970 --> 00:14:07,810
up a lot of settings before we can start the actual sending, then another setting that I want to assign

198
00:14:07,810 --> 00:14:09,160
is uses.

199
00:14:10,850 --> 00:14:19,460
Caches, and I'm going to set that to false, so the default comes from default uses cash, which defaults

200
00:14:19,460 --> 00:14:21,770
are true, but I don't want to use any cash here.

201
00:14:23,190 --> 00:14:28,950
So now that we have all of that, we can go ahead and prepare a output stream of data because we're

202
00:14:28,950 --> 00:14:30,150
sending data over, right.

203
00:14:30,570 --> 00:14:40,140
So what we're gonna do is we're going to use AI data output stream and I'm going to call this W.R,

204
00:14:40,140 --> 00:14:41,340
which stands for Writer.

205
00:14:41,340 --> 00:14:43,980
So I'm going to use that here.

206
00:14:43,980 --> 00:14:47,210
Connection dot output stream.

207
00:14:47,220 --> 00:14:51,030
Of course, you can give it a more meaningful name than what I've used here.

208
00:14:51,390 --> 00:14:51,990
So.

209
00:14:53,260 --> 00:14:53,830
About.

210
00:14:55,450 --> 00:14:59,800
Put as one word so you can put it together so that the output stream.

211
00:15:01,870 --> 00:15:02,200
Then.

212
00:15:04,550 --> 00:15:06,680
I will create a chase and request.

213
00:15:09,380 --> 00:15:11,290
Which will be adjacent object.

214
00:15:11,930 --> 00:15:13,970
OK, so I create the new JSON object.

215
00:15:15,350 --> 00:15:17,300
Then I have a data object.

216
00:15:19,030 --> 00:15:20,800
Which will also be adjacent object.

217
00:15:23,550 --> 00:15:32,880
And now I'm going to add information to this data object so you can do that via put, so I will put

218
00:15:32,880 --> 00:15:37,930
something at the position constants dot Afkham underscore key on the score title.

219
00:15:38,400 --> 00:15:40,590
So this is the title piece, so to speak.

220
00:15:40,890 --> 00:15:46,470
So what should be the title that the user sees when he opens up his notification?

221
00:15:46,800 --> 00:15:50,970
Well, I'm just going to say something like assigned to the board.

222
00:15:53,720 --> 00:15:58,460
To the port and then let's just use the board name.

223
00:16:02,840 --> 00:16:05,210
And now you might wonder, why does the name come from?

224
00:16:05,240 --> 00:16:09,050
Well, I want to get that one somebody.

225
00:16:10,160 --> 00:16:13,220
Creates an object of this notification task.

226
00:16:13,300 --> 00:16:16,160
OK, so I want to have the board name, which is going to be a string.

227
00:16:17,530 --> 00:16:19,900
And then I also want to.

228
00:16:20,880 --> 00:16:25,700
Get a token, because I'm going to need the token here as well, which is also going to be a string.

229
00:16:26,160 --> 00:16:30,210
So here, VUL Port name and Wall Token.

230
00:16:33,060 --> 00:16:37,140
OK, so the birth name is used now we use it when we want to.

231
00:16:39,020 --> 00:16:39,250
Right.

232
00:16:39,320 --> 00:16:47,150
The title of the notification, and then I want to also have the message, so.

233
00:16:48,270 --> 00:16:55,650
Put constants that have s.m underscore key message.

234
00:16:57,040 --> 00:17:06,970
And that should be you have been assigned to the new board or maybe just to the port.

235
00:17:07,930 --> 00:17:13,000
By and then they user, all right, so your username will be.

236
00:17:16,349 --> 00:17:18,180
I am assigned.

237
00:17:19,230 --> 00:17:23,369
Members list at the position zero thought name.

238
00:17:24,470 --> 00:17:28,640
So this is the assigner, so to speak, so the creator of the board.

239
00:17:30,050 --> 00:17:31,820
And we've been assigned to.

240
00:17:33,030 --> 00:17:37,800
It by the creator, so assigned to the board, by the creator.

241
00:17:38,890 --> 00:17:44,980
OK, now we can go ahead and add that to the Jason requests, so we just prepared a Jason object here.

242
00:17:44,990 --> 00:17:49,720
The state to object just contains this information and now we can put that data object to the Jason

243
00:17:49,720 --> 00:17:50,310
request.

244
00:17:50,680 --> 00:18:00,400
So we're just going to say put the constants that have the key data to be the data object.

245
00:18:01,580 --> 00:18:07,910
All right, so that's the structure here and then we also need to pass into Tolkan, so put constants

246
00:18:08,060 --> 00:18:08,510
that.

247
00:18:10,030 --> 00:18:11,290
SCMP to.

248
00:18:14,780 --> 00:18:17,660
Which is this one here and the token.

249
00:18:19,500 --> 00:18:21,320
So that is what we are putting in there.

250
00:18:23,770 --> 00:18:29,860
And at this point, we need to use our ritcher here, so use we are not right bytes.

251
00:18:30,850 --> 00:18:33,790
And Boolean, but bites right by its.

252
00:18:36,330 --> 00:18:38,280
With our Jason request.

253
00:18:39,250 --> 00:18:45,820
To strength, so now we make a string out of our Jason request so that the bites can be written and

254
00:18:45,820 --> 00:18:50,620
then we flushed the brighter and we cross the brighter.

255
00:18:53,430 --> 00:18:57,580
As we are sending something to a server, things can go wrong, right?

256
00:18:57,900 --> 00:19:02,220
So I want to get the http result code.

257
00:19:02,520 --> 00:19:10,740
So http result, which will be an integer and it will be connection dot response code.

258
00:19:11,430 --> 00:19:15,990
So whatever the response code is, let's say it's two hundred and we know, OK, everything is fine.

259
00:19:16,020 --> 00:19:23,130
We got the data, if it's four four for example then file not found for example and so forth, or you're

260
00:19:23,160 --> 00:19:25,090
not font or whatever I'm trying to do there.

261
00:19:25,410 --> 00:19:33,040
So now I'm checking if the request code is http url connection dot http.

262
00:19:33,330 --> 00:19:35,690
And you can see these are the different codes.

263
00:19:35,700 --> 00:19:37,380
There are OK response codes.

264
00:19:37,530 --> 00:19:38,340
So these are just.

265
00:19:39,750 --> 00:19:45,400
In the church, as you see, so it's constants, for example, the one that I want to have is HTP,

266
00:19:45,420 --> 00:19:45,970
OK?

267
00:19:46,610 --> 00:19:49,150
And if you look at it, it's the value.

268
00:19:49,170 --> 00:19:49,780
Two hundred.

269
00:19:50,180 --> 00:19:54,820
So then you can check out this file here, your your old connection, dot Java.

270
00:19:55,040 --> 00:19:59,810
You'll find the status codes here, two on one created, one or two accepted and so forth.

271
00:20:00,020 --> 00:20:07,880
So everything with the two is a rather positive one with the three is more of a redirect thing and everything

272
00:20:07,880 --> 00:20:10,520
with a four is just didn't work.

273
00:20:10,550 --> 00:20:13,670
So four hundred is bad request, no internet connection and so forth.

274
00:20:15,360 --> 00:20:16,890
Yep, so that's the.

275
00:20:18,380 --> 00:20:20,340
HTP, real connection.

276
00:20:20,390 --> 00:20:25,460
Now let's look what we want to do if that works out so.

277
00:20:26,420 --> 00:20:31,640
What I want to do is I want to have an input stream that reads from this connection, so vital input

278
00:20:31,640 --> 00:20:36,110
stream that goes and says connection, the input stream.

279
00:20:37,210 --> 00:20:41,590
And then we create a reader based on that, but this time it's a Bufford reader.

280
00:20:43,290 --> 00:20:49,140
With the input stream, reader input stream.

281
00:20:52,240 --> 00:21:00,070
OK, so we need to pass all of this information to the reader so that it can do its magic and then we

282
00:21:00,070 --> 00:21:01,210
need a ring builder.

283
00:21:01,210 --> 00:21:06,330
So what it will do is it will create a bill string out of whatever is given to it.

284
00:21:07,210 --> 00:21:09,220
So string builder.

285
00:21:12,020 --> 00:21:18,480
VAR line string, so we've worked with readers and input streams and so forth, right.

286
00:21:18,740 --> 00:21:23,060
So what it basically does is it gives us the details line by line.

287
00:21:23,540 --> 00:21:27,230
And as these things can go wrong, we're going to have a try and catch here.

288
00:21:27,890 --> 00:21:35,200
So what I'll try to do is to read every single line, just going to say while reader dot reline.

289
00:21:35,870 --> 00:21:46,340
So this will be called as long as there are things to read and the line is equal it.

290
00:21:48,670 --> 00:21:51,250
Just go ahead and append.

291
00:21:52,720 --> 00:21:53,950
The string builder.

292
00:21:55,770 --> 00:21:56,550
So here.

293
00:21:58,360 --> 00:22:05,290
This should be inside of curly brackets, too, has to be happened, the current line.

294
00:22:07,010 --> 00:22:15,260
With a line break, so here I'm just going to use a line break also with backslash and.

295
00:22:17,240 --> 00:22:22,880
And by the way, this may not be known here, so the line should not be No.

296
00:22:25,290 --> 00:22:25,710
All right.

297
00:22:25,750 --> 00:22:32,880
Now let's catch what should happen if something went wrong, so usually we would get an IO exception,

298
00:22:32,890 --> 00:22:38,910
so an input output exception and let's just print the stack trace for that.

299
00:22:40,670 --> 00:22:47,030
And then finally, I will try to close the connection, so here, try.

300
00:22:48,210 --> 00:22:49,230
Input stream.

301
00:22:50,740 --> 00:22:51,520
That close.

302
00:22:53,200 --> 00:22:58,210
OK, because we opened up an input stream and they should never stay open, so I'm trying to close it

303
00:22:58,210 --> 00:23:05,080
usually -- that should work and then if something went wrong, then let's just have an Iowa exception

304
00:23:05,080 --> 00:23:05,820
here as well.

305
00:23:09,380 --> 00:23:14,390
Because that's one of the exceptions that can arise, you can, of course, also use the default exception

306
00:23:14,390 --> 00:23:14,580
here.

307
00:23:15,380 --> 00:23:16,080
All right.

308
00:23:16,400 --> 00:23:18,550
And then at this point.

309
00:23:18,950 --> 00:23:21,050
So after this.

310
00:23:21,890 --> 00:23:22,820
Finally, blog.

311
00:23:25,010 --> 00:23:30,290
That's where we can set the result to be as be thought to string.

312
00:23:33,290 --> 00:23:37,730
And by the way, so here in this health blog.

313
00:23:40,030 --> 00:23:43,510
And that is our statement with the period.

314
00:23:43,870 --> 00:23:50,470
OK, so if we had a good result, that's cool, then let's do all of this magic.

315
00:23:50,650 --> 00:23:53,140
But if we didn't get a good result, what should we do then?

316
00:23:53,800 --> 00:23:54,220
Well.

317
00:23:56,280 --> 00:24:05,220
I'm just going to set the result to be connection, that response message, so whatever the response

318
00:24:05,220 --> 00:24:08,190
message is for us, I will use that.

319
00:24:10,830 --> 00:24:18,180
OK, and then this whole thing here, this whole connection part where we try to even establish the

320
00:24:18,180 --> 00:24:21,410
connection that everything else is inside of a tribe block, right?

321
00:24:21,660 --> 00:24:23,970
So we are still missing the catch block.

322
00:24:24,300 --> 00:24:29,100
Could see this is quite some code that we need here just for this notification.

323
00:24:29,340 --> 00:24:31,460
And that is only in the async task class.

324
00:24:31,500 --> 00:24:34,590
And we still have the other class, which we need to adjust.

325
00:24:34,860 --> 00:24:36,420
So here, catch.

326
00:24:37,720 --> 00:24:43,690
And we can have multiple different arrows here, so it's going to be a socketed time out exception that

327
00:24:43,690 --> 00:24:47,580
could arise time out exception.

328
00:24:48,470 --> 00:24:56,960
And in that case, I'm just going to set the result to Conexion time out, then we can have a default

329
00:24:56,960 --> 00:25:00,860
exception, in which case I'm just going to.

330
00:25:02,430 --> 00:25:04,320
Set the resolve to error.

331
00:25:06,680 --> 00:25:14,690
With the budget, but message, so the error message, the exception message, so to speak, and then

332
00:25:14,690 --> 00:25:16,520
finally in either way.

333
00:25:17,540 --> 00:25:25,340
I want to check the connection and if it exists, then disconnect because you don't want to keep the

334
00:25:25,340 --> 00:25:31,100
connection open, that results in a bunch of errors and on unwanted behavior.

335
00:25:33,250 --> 00:25:39,970
OK, and then for this video, I will just do one more thing, and that is to go to our.

336
00:25:41,080 --> 00:25:47,750
Function where we create the members or what we just say, member assign success.

337
00:25:47,770 --> 00:25:55,940
So here when we have successfully assigned a member, that's where I want to send the notification.

338
00:25:56,410 --> 00:25:58,090
So here I'm going to say sent.

339
00:26:00,500 --> 00:26:07,310
Fiction to user async task, I need to pass in the board details and the token.

340
00:26:09,150 --> 00:26:12,030
OK, so these are the two things that I need to pass in here.

341
00:26:12,690 --> 00:26:17,970
And by the way, it's not the details themselves, it's just the name of the user who is assigned to

342
00:26:17,970 --> 00:26:20,610
do or the of the board detail.

343
00:26:21,270 --> 00:26:29,280
And then the token we get that from the ACM token so users have some token, if you look at it, the

344
00:26:29,290 --> 00:26:30,420
user object.

345
00:26:31,420 --> 00:26:38,500
Has the statement here, FCMB tokens, so we need to see talking of the specific user here and then.

346
00:26:40,300 --> 00:26:43,960
We need to execute that ising task, so DOD execute.

347
00:26:45,250 --> 00:26:52,180
And that's it for this video, because we didn't do any Firebrace magic yet, and that's what we're

348
00:26:52,180 --> 00:26:53,200
going to do in the next video.

349
00:26:53,230 --> 00:26:57,780
So here you can see use and registration to server needs to be implemented and so forth.

350
00:26:57,790 --> 00:26:58,120
So.

351
00:26:59,120 --> 00:27:03,140
I'd say let's have a break here as we just long enough see you in the next video where we are going

352
00:27:03,140 --> 00:27:10,190
to finally finish this feature and then you have a fully working, pretty cool app.

353
00:27:10,190 --> 00:27:10,990
So see you there.

