This plugin is designed to return information about the current os theme (android and iOS).
Through your terminal:
# Newest npm version
cordova plugin add cordova-plugin-os-theme
# Newest github version
cordova plugin add https://github.com/DavidBriglio/cordova-plugin-os-theme.git
This plugin has one method: cordova.plugins.osTheme.getTheme()
that will return a promise that will in turn receive an object with the current os theme properties. Currently there is only one property being tracked: isDark
. This will be set to true
only if dark mode is confirmed active. If we do not know the state of the theme or it is in light mode, isDark
will be false
.
cordova.plugins.osTheme.getTheme()
.then(theme => { // { isDark: [boolean] }
console.log('The current theme is: ' + (theme.isDark ? 'Dark' : 'Light'))
})
.catch(message => { // string error message
console.log('Error getting theme: ' + message)
})
This plugin can be used for android
, and iOS
version 13.0.0+
!
MIT - Please see license file for full details.
Please feel free to open an issue!