Web-app dev2, Expo Webview app making

This writing is about Webview app making and app icon, splash image etc. This is continued writing from previous one.


1. Create Expo app

  • Open Visual Studio Code and make some folder route to make project.


  • In the terminal, run the command: npm install -g expo-cli
  • Note that you should install Node.js, homebrew, Git scm, etc such libraries (what I mentioned in first step writting) first to perform above command correctly otherwise it may show some error.

  • Run the command: npx create-expo-app --template blank to make project. And the enter your app name. Space or some special characters are not allowed for the name.
  • I want to make just simple webview app so blank template is enough for me. For other template, refer to Expo document: https://docs.expo.dev/more/create-expo/#--template

  • Then you will see basic app structure (App.js, app.json, ...) is created.



2. Make your app to Webview app

  • Change directory to project by entering cd ProjectName.
  • Install React Native Webview library by running command: npx expo install react-native-webview

import { WebView } from 'react-native-webview';
import Constants from 'expo-constants';
import { StyleSheet } from 'react-native';

export default function App() {
  return (
    <WebView
      style={styles.container}
      source={{ uri: 'https://expo.dev' }}
    />
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: Constants.statusBarHeight,
  },
});


  • You can easily notice that uri is the one will be shown in the Webview app. Put your web address here.
export default function App() {
  return (
    <WebView
      style={styles.container}
      source={{ uri: 'putYourWebAddressHere!' }}
    />
  );
}


3. Make your own app icon

  • Once you make the app with Expo blank template, you will see icons in assets. adaptive-icon.png, favicon.png, icon.png, splash.png
  • You can go to that directory and change the file what you want to show as your app icon.

3-1. adaptive-icon.png


3-2. favicon.png

  • png image, 48x48 pixels
  • favicon is used when your app is opened in web browser. It is shown as below.
  • You can easily make one when you search favicon generator in Google.

3-3. icon.png

  • png image, 1024x1024 pixels
  • This is normal app icon which is shown in iOS or sometimes Android. (In lower version of Android which does not support adaptive icon.)

3-4. splash.png

  • png image, 1284x2778 pixels
  • This is an image, which appears while app is being loaded initially.

3-5. Change property of icon


3-6. Small tip

  • Be careful about uppercase and lowercase for icon file name. Of course it is always important to be careful about upper- and lowercase when coding and it is same in file name too. One day I made file name "Splash.png" by mistake, while "splash.png" is correct. My app could not be built due to that and I spent several hours until I found out the reason...


Comments

Mostly viewed post

About this blog

Web-app dev4, Google AdMob (Banner and Interstitial ads)