Last active
January 22, 2021 16:44
-
-
Save hasnarobert/7d502284ec5ffcf47d76b4e871ff1171 to your computer and use it in GitHub Desktop.
Ionic android copy notification icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| var filestocopy = [ | |
| { "resources/android/notification/drawable-hdpi-icon.png": "platforms/android/res/drawable-hdpi/ic_stat_onesignal_default.png" }, | |
| { "resources/android/notification/drawable-mdpi-icon.png": "platforms/android/res/drawable-mdpi/ic_stat_onesignal_default.png" }, | |
| { "resources/android/notification/drawable-xhdpi-icon.png": "platforms/android/res/drawable-xhdpi/ic_stat_onesignal_default.png" }, | |
| { "resources/android/notification/drawable-xxhdpi-icon.png": "platforms/android/res/drawable-xxhdpi/ic_stat_onesignal_default.png" }, | |
| { "resources/android/notification/drawable-xxxhdpi-icon.png": "platforms/android/res/drawable-xxxhdpi/ic_stat_onesignal_default.png" }, | |
| { "resources/android/notification/drawable-xxxhdpi-large-icon.png": "platforms/android/res/drawable-xxxhdpi/ic_onesignal_large_icon_default.png" } | |
| ]; | |
| var fs = require('fs'); | |
| var path = require('path'); | |
| filestocopy.forEach(function (obj) { | |
| Object.keys(obj).forEach(function (key) { | |
| var val = obj[key]; | |
| var srcfile = key; | |
| var destfile = val; | |
| var destdir = path.dirname(destfile); | |
| if (!fs.existsSync(destdir)) { | |
| fs.mkdirSync(destdir); | |
| } | |
| if (fs.existsSync(srcfile) && fs.existsSync(destdir)) { | |
| fs.createReadStream(srcfile).pipe(fs.createWriteStream(destfile)); | |
| } else { | |
| console.warn(`Did not copy notification icon because source of restination does not exist. Copy '${srcfile}' to '${destfile}'`); | |
| } | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <platform name="android"> | |
| .... | |
| <hook src="build-scripts/copy-android-notification-icons.js" type="after_prepare" /> | |
| .... | |
| </platform> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment