This feature is only available when running on an emulator or actual device. You can not test this feature with Ionic Serve.
OK thats fine but can you please help me out in how will my ionic serve work now?
Do I have to delete my code for time being or what?
Look into using a mock version of the plugin. The docs (https://github.com/ionic-team/ionic-native) talk about this.
Or you could perform a platform check before calling the code (less than ideal)
Platform check worked fine.