5 Common App features that can be hard to work with in Ionic using Cordova . 
Still we will get past them!!
Tags: ionic, cordova, angular, hybridmobileapp
Published: 2020-04-03 15:40:31



Hello Devs. It’s Ray here and it’s becoming clear that although we can do pretty much anything we want with Ionic. But depending on the Cordova plugin you use there are some things that are very good to know ahead of time. We will go in order of most difficult workarounds to things that will save you debugging time if you know ahead. Now if you were expecting an article that would go through them like I was a journalist or writer you assumed too quickly.

The rest of the article is an array containing the list of tips of class featureTips. The properties are relevant strings. But also writing out the tips as actual code might be hard to read so I’ll structure this almost like a powerpoint for a high level overview. 


#1: Background Tasks 
Plugin Name: cordova-plugin-background-mode
Function: Performing actions while the app has left the foreground.
Examples: 
Playing music continuously after the user has switched apps recording data such as geolocation for a rideshare app or maybe periodically pulling data for caching data for the user so the app loads much faster.
What can go wrong?
Impossible to have a task running past a few minutes after the app has left the foreground. Pausing after a short time or only running your code once the app is back at the front. The problem ended up costing me months of development time and rewriting a very large of my code for my precious app Latitunes. 
Why? Infinite background tasks are not official supported on most mobile operation systems and thus not compliant with public store vendors
How to get past this problem? 
Consider whether you can do everything you want within those conditions. Would it be okay if the app runs that task immediately after the user returns to your app? Could telling your user that they need to come back to the app for the current feature to work and send local notifications to return to the app if they leave be suitable?

If neither works for you then you may need to build your own plugin that does exactly what you want your app to do. I would rank this highly difficult but it's also a great opportunity to level up and haven’t you wanted to try! 
I will put together a guide on how to start this in a different article.



#2 Camera
Name: cordova-plugin-camera
Function: Taking photos or accessing the user’s photo library and performing some kind of modification.
What can go wrong?
Pulling up the images too slowly. Having trouble modifying the amount of frames per second of videos. Limited 
Solutions:
For improving load speed passing in a lower quality value in the camera api parameters will change the load time. What I’ve experienced is that the quality change is not noticeable until you get to very small values like 25. Using the Cordova Camera library this modification will only work on iOS devices. I did not record any changes on Android.
Solution for a problem in the Solution:
Use the Capacitor Camera API

For doing more complex features, oh let’s say boomerang video clip I would recommend building this out natively. 


#3 Contacts:
Name: cordova-plugin-contacts
Problems:
Long load time for very users with very large contact lists. Approximately 1000+.
Solution: 
Using a different plugin if you only need emails or phone numbers. If you only need phone numbers or emails try this plugin. It ended up being much better to use and I encourage you to donate to BradDuell for his excellent save. 
https://bitbucket.org/BradDuell/cordova-plugin-contacts-phone-numbers-emails/src/master/

# 4 Push Notification:
What can go wrong? I’ve leaned towards Capacitors API’s for most features including this one because it's thought to be more reliable. With the Push Notifications though this API worked on Android and not on iOS for me. 
Solution:
Using https://www.npmjs.com/package/capacitor-fcm. 






#5 Firebase Authentication
What can go wrong: When you publish the app and authentication fails.
Solution: Generating the app sign in key for deployment and adding that info to google play.



This article is meant to tell you the things that can go wrong and help guide you towards a solution quicker or avoid the problem altogether. Please let me know your thoughts and comment about any of the plugins you would like for me to go more into. 

One last word. I think the entire Ionic and Cordova ecosystem will benefit from more people knowing how to develop these libraries. Saying this out loud I think there’s a repo that I need to help maintain.. Just remember that I am someone pushing towards the education of building plugins and anything I learn one this path I will be happy to share with you if you are interested.