Skip to content

Instantly share code, notes, and snippets.

@albovieira
Created September 11, 2017 19:35
Show Gist options
  • Save albovieira/cfef9e3d9a60a06022bc6c280c75c951 to your computer and use it in GitHub Desktop.
Save albovieira/cfef9e3d9a60a06022bc6c280c75c951 to your computer and use it in GitHub Desktop.
Hook to add push icons with his respective size to android folder
//add this in: /hooks/before_prepare
var chalk = require('chalk');
var exec = require('child_process').exec;
exports.run = copyPushIcon;
function copyPushIcon() {
var rootdir = process.argv[2] + '/resources/android/push_icons/';
var androidPath = 'platforms/android/res/';
console.log(chalk.green('Copying push icons..'));
var pathsResolution = [
'drawable-hdpi',
'drawable-ldpi',
'drawable-mdpi',
'drawable-xhdpi',
'drawable-xxhdpi',
'drawable-xxxhdpi'
];
var command = '';
var lastWithAnd = pathsResolution.length-1;
pathsResolution.forEach(function(resolution, index) {
var drawablePath = androidPath + resolution;
var screen = resolution.split('-')[1];
var iconDir = rootdir + screen + '/notification_icon.png';
command += 'cp -Rf ' + iconDir + ' ' + drawablePath;
if(index !== lastWithAnd){
command += ' && ';
}
});
exec( command , function (error) {
if(!error){
process.stdout.write('Copied android native resources');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment