Oynatıcıya atla
Ana içeriğe atla
Altbilgiye atla
Ara
Oturum açın
Tam ekran izle
Beğen
Yorumlar
Yer işareti ekle
Paylaş
Çalma Listesine ekle
Bildir
34 - Configure Mobile App for Network Connections
Mustafa Demirhan
Takip Et
24.08.2024
Kategori
📚
Öğrenme
Döküm
Tüm video dökümünü görüntüle
00:00
Welcome back guys. Now in this lesson we're going to just go through a few
00:06
explanations of how our emulators work and some configurations that are needed.
00:13
So up until now clearly we've been focusing on Android development mostly
00:18
because of the environment that I have which is a Windows PC and it would be a
00:22
bit more difficult to do this with Mac OS and I haven't turned on developer
00:26
mode in my Windows. So I'm focusing on Android development. So the the main of
00:32
our concern really is how the Android emulator interacts with other networks.
00:37
So the fact is that this Android emulator actually is running like in
00:44
its own little network as it stands right. So yes it reaches out to the
00:49
internet and whatever but it cannot see localhost on my machine as easily
00:55
especially if it's broadcasting from Visual Studio. So I had a round of
01:02
difficulties trying to get that to work and especially with SSL certificates and
01:06
all sorts of things and in a development environment there's a lot of
01:11
configuration overhead when it comes to getting and trusting certs and you know
01:16
for development purposes. So to spare all of that we just publish the API to IIS
01:22
and it is not protected by SSL. That's what we did in the previous lesson.
01:28
Now what we need to do is let the Android emulator know that it can
01:35
actually connect to certain addresses without needing SSL because it in itself
01:43
is actually looking for a secure connection point. So what I'm about to do
01:48
if we were integrating with a fully secured third-party SSL secured third
01:54
party API we wouldn't necessarily have to do this but for development purposes
01:59
and for our own local testing then it is necessary. So after that monologue let me
02:06
get to it. The first thing I want to do is go to platforms. Remember that with
02:11
MAUI we have a platforms folder which allows us to configure specific
02:17
manifest files and you know device specific files for the different
02:24
operating systems. So we're dealing with Android right now if I expand
02:30
Android then I'm going to see that I have a file called Android manifest. So
02:36
the red tick here means that I have modified it since the last time we were
02:39
here and that's fine I'm going to walk you through everything. What I want you
02:43
to do is in the resources folder create a new folder and we're going to call it
02:48
XML. Then inside of the XML folder go ahead and add a new file new item and
02:55
it's an XML file that I'm calling network underscore security underscore
03:01
config dot XML. So make sure you get that name correctly right network underscore
03:07
security underscore config dot XML. Inside this file and let me comment it
03:15
out some of it remove what is not absolutely necessary inside this file we
03:20
want this text and I'm going to explain what all of this is saying. So open up
03:26
this node network hyphen security hyphen config and then inside of that we want
03:33
domain hyphen config and then it's going to say clear text traffic permitted
03:39
is equal to true. So clear text traffic is essentially saying well if traffic is
03:48
not encrypted by SSL or protected by SSL then it is what we call clear text. So
03:54
the Android emulator Android phone Android devices in general do not take
03:59
kindly to connecting to a source that is not sending over an encrypted message
04:04
right. So this is why we have to go in manually and say I am allowing it yes
04:10
please permit it allow to be connected to an endpoint that is not SSL secured.
04:18
Then we go on to specify domains that are allowed to do this clear text
04:25
traffic. So I say domain include subdomains equal true so the domain and
04:32
any subdomain of this main domain and then I have 10.0.0 sorry 10.0.2.2
04:42
now 10.0.2.2 is essentially a loopback Android address for localhost. So like I
04:52
said the Android the emulator can't really see localhost that way if I'm
04:56
running it from Visual Studio. So if you have done other courses with me when I
05:01
teach API development and consuming the API you would run both projects and then
05:05
you know one project would talk to the other. Android phone is not a really like
05:09
a project it's by itself so it can't really see the Visual Studio localhost.
05:14
So that and localhost is really more going to be seen as 10.0.2.2
05:22
10.0.2.2 as opposed to 198.168.0.1 or 127.0.0.1
05:30
so those are the usually the IP addresses associated with localhost on a
05:35
Windows machine. This is localhost on an Android so what I'm saying here now is
05:40
allow any traffic coming from this address to be seen by the domain allow
05:46
to be to be allowed for clear text rather allow any localhost domain
05:52
traffic to be seen and I added this one because I did an IP config on my machine
05:57
I saw that my localhost or my IIS localhost is actually broadcasting from
06:03
that but I don't really use that one in the course so that one is optional and
06:06
this one is actually relative to your machine configuration so make sure that
06:10
you capture at a bare minimum these two but just as a contingency to get to that
06:16
one if I go to my command prompt and then say IP config IP config then the
06:29
address that I selected would have been underneath the Ethernet adapter and the
06:35
IPv4 address. So I selected this one and that is what I added to this
06:43
config file so as a contingency just to make sure that we're all on the same
06:48
page you can also take that step. Now after you've done all of that
06:55
what we want to do is go to the Android manifest and we're going to modify the
07:00
application section let me break lines so it's easier to see my modification
07:07
and this line would be the modification I made this one. So we add
07:16
android-networksecurityconfig and then it's equal to and we put at sign
07:22
and the path so at sign and our path is XML because of the XML folder slash the
07:28
name of the file which was network security config but not XML just the
07:33
name not the extension right and then we can do that and then we save and with
07:40
that configuration made we can proceed now to start writing code confidently
07:47
that will talk to our API
Önerilen
1:21
|
Sıradaki
37 - Section Summary
Mustafa Demirhan
24.08.2024
0:56
38 - Section Overview
Mustafa Demirhan
24.08.2024
14:04
30 - Configure API Endpoints
Mustafa Demirhan
24.07.2024
23:05
47 - Adjust App Flow and Layout
Mustafa Demirhan
02.09.2024
14:00
36 - Essential Fixes
Mustafa Demirhan
24.08.2024
1:08
32 - Prepare Server for API Deployment
Mustafa Demirhan
24.08.2024
15:35
42 - Add App Login Page
Mustafa Demirhan
02.09.2024
14:28
23 - Add SQLite Database to App
Mustafa Demirhan
24.07.2024
6:36
43 - Seed Users and Roles
Mustafa Demirhan
02.09.2024
10:11
40 - Set Up Login Endpoint
Mustafa Demirhan
24.08.2024
14:11
33 - Refactor and Publish API To Local Server
Mustafa Demirhan
24.08.2024
6:51
25 - Section Summary
Mustafa Demirhan
24.07.2024
20:07
35 - Refactor MAUI App for API
Mustafa Demirhan
24.08.2024
3:46
14 - Create Data Access Services
Mustafa Demirhan
18.07.2024
20:55
21 - Implement a Details Page
Mustafa Demirhan
24.07.2024
4:46
13 - Create Data Model
Mustafa Demirhan
18.07.2024
2:16
49 - Section Summary
Mustafa Demirhan
02.09.2024
6:41
26 - Section Overview
Mustafa Demirhan
24.07.2024
4:14
31 - Test API Functions
Mustafa Demirhan
24.08.2024
10:31
17 - Set Up View Model and Command
Mustafa Demirhan
18.07.2024
8:53
39 - Add Identity to API
Mustafa Demirhan
24.08.2024
5:16
48 - Handle Logout
Mustafa Demirhan
02.09.2024
7:16
20 - Style Our List Page View
Mustafa Demirhan
18.07.2024
2:39
28 - Setup CORS Policy
Mustafa Demirhan
24.07.2024
0:31
mobile web application development mobile application
Jin Freecs
29.05.2016