How To Automatically Copy OneSignal Custom Notification Icons Into The Android Resources Directories For Ionic Projects

If you are using OneSignal for your push notifications in your Ionic project then here’s a useful hook to automatically copy your custom icons into your android resources folder.

The OneSignal Ionic SDK installation is here and the note about custom android notification icons is here which links to the custom android notification generator.

Once you have generated your icons and downloaded them follow these instructions:

1) Create a directory at the root of your project called ‘onesignal’, extract the files from into it

2) Add a file to your ‘hooks’ directory inside the ‘after_prepare’ folder called ‘030_copy_android_notification_icons.js’

Put the following code in it:

(Many thanks to DevGirl for the code that I have adapted for this tutorial. See the original blog post here)

3) From the root of your project make the file executable:

4) Run ionic prepare

And your files will be copied into the correct directories for your android project

Leave a Reply