docs/en/_deleted/getting-started-react-native.md
//[doc-params]
{
"Tiered": ["No", "Yes"]
}
ABP platform provide basic React Native startup template to develop mobile applications integrated to your ABP based backends.
Please follow the steps below to prepare your development environment for React Native.
You have multiple options to initiate a new React Native project that works with ABP:
ABP CLI is probably the most convenient and flexible way to initiate an ABP solution with a React Native application. Simply install the ABP CLI and run the following command in your terminal:
abp new MyCompanyName.MyProjectName -csf -u <angular or mvc> -m react-native
To see further options in the CLI, please visit the CLI manual.
This command will prepare a solution with an Angular or an MVC (depends on your choice), a .NET Core, and a React Native project in it.
You can generate a CLI command on the get started page of the abp.io website. Then, use the command on your terminal to create a new Startup Template.
React Native application does not trust the auto-generated .NET HTTPS certificate. You should use HTTP during the development.
When you are using OpenIddict, You should remove 'clientSecret' on Environment.js (if exists) and disable "HTTPS-only" settings. (Openiddict has default since Version 6.0)
A React Native application running on an Android emulator or a physical phone can not connect to the backend on localhost. To fix this problem, it is necessary to run the backend application on your local IP address.
{{ if Tiered == "No"}}
appsettings.json file in the .HttpApi.Host folder. Replace the localhost address on the SelfUrl and Authority properties with your local IP address.launchSettings.json file in the .HttpApi.Host/Properties folder. Replace the localhost address on the applicationUrl properties with your local IP address.{{ else if Tiered == "Yes" }}
appsettings.json file in the .AuthServer folder. Replace the localhost address on the SelfUrl property with your local IP address.launchSettings.json file in the .AuthServer/Properties folder. Replace the localhost address on the applicationUrl properties with your local IP address.appsettings.json file in the .HttpApi.Host folder. Replace the localhost address on the Authority property with your local IP address.launchSettings.json file in the .HttpApi.Host/Properties folder. Replace the localhost address on the applicationUrl properties with your local IP address.{{ end }}
Run the backend application as described in the getting started document.
You should turn off the "Https Restriction" if you're using OpenIddict as a central identity management solution. Because the IOS Simulator doesn't support self-signed certificates and OpenIddict is set to only work with HTTPS by default.
Open the {{ if Tiered == "No" }}MyProjectNameHttpApiHostModule{{ else if Tiered == "Yes" }}MyProjectNameAuthServerModule{{ end }} project and copy-paste the below code-block to the PreConfigureServices method:
#if DEBUG
PreConfigure<OpenIddictServerBuilder>(options =>
{
options.UseAspNetCore()
.DisableTransportSecurityRequirement();
});
#endif
react-native folder and run yarn or npm install if you have not already.Environment.js in the react-native folder and replace the localhost address on the apiUrl and issuer properties with your local IP address as shown below:{{ if Tiered == "Yes" }}
Make sure that
issuermatches the running address of the.AuthServerproject,apiUrlmatches the running address of the.HttpApi.Hostor.Webproject.
{{else}}
Make sure that
issuerandapiUrlmatches the running address of the.HttpApi.Hostor.Webproject.
{{ end }}
yarn start or npm start. Wait for the Expo CLI to print the opitons.The React Native application was generated with Expo. Expo is a set of tools built around React Native to help you quickly start an app and, while it has many features.
In the above image, you can start the application with an Android emulator, an iOS simulator or a physical phone by scanning the QR code with the Expo Client or choosing the option.
yarn start or npm start command.Enter admin as the username and 1q2w3E* as the password to login to the application.
The application is up and running. You can continue to develop your application based on this startup template.