How to change statusbar background color dynamically and statusbar text color based on background color in ionic 3?

Hey guys, I want first to change the status bar unique background color for different pages in my app.
And based on that background color, I want to change status bar text color. So if the background color is dark, then text color should be a light color. And if the background color is light, so the text color should be darker.

Thank you in advance.