Herbst Produkt

You have probably used one of Scot Herbst’s products before. Not just admired it in a gallery but really used it. Reclining on garden furniture, riding a bike, cutting open a box, perhaps you even…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Camera and Image picker in Ionic 4 app

Camera and Image picker in Ionic 4 app

This is Part-1 of two post series. In this post, you will learn how to implement an Image picker in Ionic 4 app. Part 2 of the series discusses how to Crop those images in IONIC 4 app🔥

We will create a sample app, where users can pick an image from there gallery or camera. After picking, the user can crop his image.

You probably already know about Ionic, but put this section in every blog just for the sake of beginners. Ionic is a complete open-source SDK for hybrid mobile app development. Ionic provides tools and services for developing hybrid mobile apps using Web technologies like CSS, HTML5, and Sass. Apps can be built with these Web technologies and then distributed through native app stores to be installed on devices.

In other words — If you create native apps in Android, you code in Java. If you create native apps in iOS, you code in Obj-C or Swift. Both of these are powerful, but complex languages. With Cordova (and Ionic) you can write a single piece of code for your app that can run on both iOS and Android (and windows!), that too with the simplicity of HTML, CSS, and JS. I’m a huge fan of Ionic and been developing Ionic apps for last 4 years.

We’ll follow a stepped approach to create a Music player app in Ionic 4. We’ll use an IONIC native plugin for music playback. Following are the steps

So let’s dive right in!

In short, the steps you need to take here are

You can create a sidemenu starter for the sake of this tutorial. On running ionic start ionic-4-chartjs sidemenu , node modules will be installed. Once the installation is done, run your app on browser using

The app will launch on the browser. You can go to Inspect -> Device Mode to see the code in a mobile layout. Next, we’ll add the chart library to our app.

[Warning] Since IOS 10 the camera requires permissions to be placed in your config.xml add

inside of the <platform name=’ios> section

‌For that, open your terminal and type

‌It’s a bit clumsy to work with Cordova plugin so the ionic team created Ionic Native, which is a wrapper for the Cordova plugins so we can use them in a more “Angular/Ionic” way.

‌So now we will open our terminal and try this command‌ to install Facebook package from Ionic Native

For read/write access to files residing on the device. you also need File plugin. The File class implements static convenience functions to access files and directories.

so for installation of this plugin open your terminal and type,

and

Using this plugin The first step you will need to do is add this plugin to your app’s module

Import these plugins like this

and add this to providers of your app Like this

So after Adding Your app.module.ts look like this

Now time to import this plugin in your home.ts where we will use this plugin

So for using this plugin in our home.ts first, we will import the plugin like this

and inject it in your Constructor (Dependency injection) like this

And use this code for Adding Image Picker in IONIC App

So after Adding this code your home.ts something looks like this.

Home page before picking any image
Pick image from camera or Image Picker

If you have carried out the above steps correctly, Android build should be a breeze.

Run the following command to create Android platform

Once platform is added, run the app on device (Make sure you have a device attached to the system).

Once your app is up and running on the device, you can start testing all the functions. The images shown below are taken from a real Android device 😎

Properties

Use camera to click images

In this post, you learned how to implement Image Picker in your Ionic 4 app. In the next part of this post, you’ll learn how to crop Image in IONIC 4 app.

Now that you have learned the implementation of Camera and Image gallery in Ionic 4, you can also try

Make your next awesome app with Ionic 4 Full App

Add a comment

Related posts:

Friend and Box.

An echoing heartbeat, pulsates at the tips of my fingers, as I carry you up the dirt-laden hill. I do not expect that the memory will ever dissipate. It may, perhaps, leave in intervals — evaporating…

HAVING FUN KAYAKING

Have you ever seen pictures of people kayaking and though, “I’d love to do that one day”, but you keep putting it off? Or, are you a seasoned kayaker who is always looking for new adventures and…

How To Balance Your Hormones Naturally To Beat Infertility

There are so many reasons because of which issue like infertility is at high risk. If you consider the percentage of the same, you will learn that at a global level the problem is simply increasing…