Translation | "JavaScript Everywhere" Chapter 25 Mobile Application Released
Write at the top
Hello everyone, I am Mao Xiaoyou, a front-end development engineer. An English technical book is being translated.
In order to improve everyone's reading experience, the structure and content of sentences have been slightly adjusted. If you find any flaws in this article, or if you have any comments or suggestions, you can leave a message in the comment area, or add my WeChat: code_maomao, welcome to communicate and learn from each other.
(σ゚∀゚)σ…:*☆Oh, good
Chapter 25 Mobile Application Release
In my 90
high school in the middle of the last century , TI-81
downloading games for your graphing calculator was a trend.
Someone will get a copy of the game, and then it will spread like wildfire. Each of us takes turns connecting the calculator to another calculator with a data cable to load the game. Playing games on your calculator is a way for you to finish your spare time after class or in the study room, while maintaining the appearance of doing homework. However, as you can imagine, this distribution method is slow and requires two students to stay connected for a few minutes, while the other students can only wait. Today, our digital pocket computer is much more powerful than my rudimentary graphing calculator, partly because we can easily extend its functionality through installable third-party applications.
With our initial application development complete, we can now publish our application so that others can access it. In this chapter, we will learn how to configure our application.
Then we will Expo
publish our application publicly on.
Finally, we will generate Play
application packages that can be submitted to Apple or Google warehouses.
app.json configuration
Expo
The application includes a app.json
file that is used to configure application-specific settings.
When we generate a new Expo
application, a app.json
file is automatically created for us . Let's take a look at the files generated for our application:
{
"expo": {
"name": "Notedly",
"slug": "notedly-mobile",
"description": "An example React Native app",
"privacy": "public",
"sdkVersion": "33.0.0",
"platforms": ["ios", "android"],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 1500
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
"android": {
}
}
}
Most of these configurations are self-explanatory, but let's review their purpose:
-
name
The name of our application.
-
slug
Expo
TheURL
name used to publish the application , located atexpo.io/project-owner/slug
. -
description
The description of our project will be
Expo
used when publishing the application. -
privacy
Expo
Public availability of the project. It can be set topublic
orunlisted
. -
sdkVersion
Expo SDK
version number. -
platforms
Our target platforms, includingios
,android
,and web.
-
version
The version number of our application should follow the semantic version standard .
-
orientation
directionThe default orientation of our application can be locked using portrait or landscape values, or the rotation direction of the user device can be matched with the default orientation.
-
icon
The path of the application icon will be used for
iOS
and at the same timeAndroid
. -
splash
Image location and settings of the application loading screen.
-
updates
After loading the application, how our application should
OTA
update the configuration over the air ( ). ThisfallbackToCacheTimeout
parameter allows us to specify the length of time (in milliseconds). -
assetBundlePatterns
Allows us to specify the location of resources that should be bundled with our application.
-
ios
withandroid
Enable platform-specific settings.
This default configuration provides a solid foundation for our application. Expo
Many other settings can be found in the documentation.
Icons and application loading screen
The small square icon on our device has become one of the most well-known designs in modern society. Close your eyes, I believe you can imagine dozens of icons, including logos or specific background colors. In addition, when the user clicks on the icon, an initial static "startup screen" appears, which is displayed when the application loads. So far, we have used the default blank Expo
icon and startup screen. We can replace it with a custom design in the application.
I assets/custom
included a "notable" icon and splash screen in the folder. We can take advantage of them by replacing them with images in the assets directory or updating our app.json
configuration to point to files in a custom subdirectory.
App
icon
icon.png
The file is a square 1024
× 1024
pixel PNG
file. If app.json
the attributes we are using point to this file, Expo
appropriate icon sizes will be generated for various platforms and devices. The icon should be completely square without any transparent pixels. This is the easiest and most straightforward way to include application icons:
"icon": "./assets/icon.png",
In addition to a single cross-platform icon, we can also choose to include platform-specific icons. The main advantage of this method is to include suitable Android
and iOS
individual style icon, especially if you are interested in using Android
icon style.
For iOS
, we will continue to use a single 1024
× 1024 png
. In the app.json
file:
"ios": {
"icon": IMAGE_PATH
}
To use Android
the adaptive icon, we need to specify a foreground image, a background color (or backgroundImage
) and a backup static icon:
"android": {
"adaptiveIcon": {
"foregroundImage": IMAGE_PATH,
"backgroundColor": HEX_CODE,
"icon": IMAGE_PATH
}
}
For our use case, we can continue to use a single static icon.
startup screen
The splash screen is a full-screen image that is briefly displayed when our application is launched on the device. We can assets/custom
replace the default picture with the default picture found in Expo
. Although the size of the device will vary within and between platforms, I still choose to use the size of 1242
×2436
Expo
file. Then, Expo
the image will be resized to work across device screens and aspect ratios.
We can app.json
configure the initial screen in the file as follows:
"splash": { "image": "./assets/splash.png", "backgroundColor": "#ffffff", "resizeMode": "contain" },
By default, we set a white background color, which may be visible when the image is loaded; or, depending on the color we choose.
resizeMode
, As a border around the initial screen image. We can update it to match the color of the screen:
"backgroundColor": "#4A90E2",
resizeMode
Indicate how to adjust the image size for various screen sizes.
By setting contain
the time, we reserve the aspect ratio of the original image.
When you use contain
it, certain screen sizes or resolutions will be backgroundColor
used as a border around the initial screen image.
Or we can resizeMode
set it to cover
, which will expand the image to fill the entire screen.
Since our application has subtle gradients, we will resizeMode
set it to cover:
"resizeMode": "cover"
Figure 25-1
. Our application splash screen
This configures our icon and initial screen image (see figure 25-1
). Now, we are ready to study how to publish our application so that others can access it.
Published by Expo
During the development process, our application can be accessed in the Expo Client
application on the mobile phone through the local area network . This means that as long as our development computer and mobile phone are on the same network, we can access the application. Expo
Enables us to publish the project, which uploads the application to Expo CDN
and provides us with publicly accessible URL
. In this way, anyone can Expo Client
run our application through the application. This is useful for testing or quickly releasing applications.
To publish our project, we can click Expo Dev Tools
on the "publish or republish project" link in the browser (see figure 25-2
), or enter it in our terminal expo publish
.
Figure 25-2
. We can Expo Dev Tools
publish our application directly from
After packaging is complete, anyone can access https://exp.host/
@/pass to Expo Client App
access the application.
Create native version
Although direct Expo
release is an excellent choice for testing or quick use, it is likely that we want to pass Apple App Store
or Google Play Store
release our application. To do this, we upload the build package to the respective store.
Windows users
According to the Expo
documentation, the Windows
user needs to enable Linux
the Windows
subsystem ( WSL
). To do this, follow Microsoft
the Windows 10
installation guide provided.
iOS
The generated iOS
version needs to be available Apple Developer Program
and is charged in 99
USD per year . Using this account, we can add one to the app.json
file .iOS
bundleIdentifier
This identifier should follow the reverse DNS
notation:
"expo": {
"ios": {
"bundleIdentifier": "com.yourdomain.notedly"
}
}
As the app.json
file is updated, we can generate a build. In the terminal application, enter from the root directory of the project directory:
$ expo build:ios
After running the build, you will be prompted to Apple ID
log in. After logging in, you will be asked a few questions about how to handle your credentials. Expo
Being able to manage all credentials and certificates for us, you can allow them by selecting the first option at each of the following prompts:
? How would you like to upload your credentials? (Use arrow keys)
❯ Expo handles all credentials, you can still provide overrides
I will provide all the credentials and files needed, Expo does limited validat
ion
? Will you provide your own Apple Distribution Certificate? (Use arrow keys)
❯ Let Expo handle the process
I want to upload my own file
? Will you provide your own Apple Push Notifications service key? (Use arrow keys)
❯ Let Expo handle the process
I want to upload my own file
If you have a valid Apple Developer Program
account, Expo
a file will be generated, which can be submitted to Apple App Store
.
Android system
For Android
, we can generate Android
package file ( APK
) or Android
application bundle ( AAB
) file. Android App Bundles
It's a more modern format, so let's go this way.
If you are interested, the Android
developer documentation describes the App Bundle
benefits in detail .
Before generating the bundle, let's update the app.json
file to include an Android
identifier. And iOS
similar, which should be used reverse DNS
notation:
"android": {
"package": "com.yourdomain.notedly"
}
In this way, we can be used to generate application packages from terminal applications. Make sure to enter the root directory of the project and run the following command:cd
$ build:android -t app-bundle
The app bundle must be signed. Although we can generate signatures ourselves, we Expo
can manage the keystore for us. After running the command to generate the bundle, you will see the following prompt:
? Would you like to upload a keystore or have us generate one for you?
If you don't know what this means, let us handle it! :)
1) Let Expo handle the process!
2) I want to upload my own keystore!
If you choose 1
, the Expo
application bundle will be generated for you. At the end of the process, you can download the file, which can be uploaded to the Google Play
store.
Publish to App Store
Due to changes in the review guidelines and related costs, I will not describe the specific process of submitting the application to the Apple App Store
or Google Play
store. Eopo
The documentation is a good collection of resources and guides, and is a useful and up-to-date guide on the process of how to publish an app to the store.
in conclusion
In this chapter, we studied how to publish and publish React Native
applications.
Expo
The tool allows us to quickly release the application for testing and generate a production version that can be uploaded to the application warehouse. Expo
It also provides us with options to control certificates and dependencies.
In this way, we have successfully written and published a back-end data API
, an Web
application, a desktop application and a cross-platform mobile application!
If there is any inadequate understanding, please correct me. If you think it's okay, please like to collect or share it, hoping to help more people.