From 9eb29f89248991286c500423f6e0ed9fdb0e070b Mon Sep 17 00:00:00 2001 From: Matias Solis de la Torre Date: Wed, 7 Jun 2017 20:48:13 -0300 Subject: [PATCH] docs(): add copy icons instructions (#1670) Add how to copy icons to use in push notifications. --- src/@ionic-native/plugins/onesignal/index.ts | 52 ++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/@ionic-native/plugins/onesignal/index.ts b/src/@ionic-native/plugins/onesignal/index.ts index 248a32792..75214b3c0 100644 --- a/src/@ionic-native/plugins/onesignal/index.ts +++ b/src/@ionic-native/plugins/onesignal/index.ts @@ -268,6 +268,58 @@ export enum OSActionType { * * Requires Cordova plugin: `onesignal-cordova-plugin`. For more info, please see the [OneSignal Cordova Docs](https://documentation.onesignal.com/docs/phonegap-sdk-installation). * + * #### Icons + * If you want to use generated icons with command `ionic cordova resources`: + * + * 1. Add a file to your `hooks` directory inside the `after_prepare` folder called `030_copy_android_notification_icons.js` + * + * 2. Put the following code in it: + * + * ``` + * #!/usr/bin/env node + * + * var filestocopy = [{ + * "resources/android/icon/drawable-hdpi-icon.png": + * "platforms/android/res/drawable-hdpi/ic_stat_onesignal_default.png" + * }, { + * "resources/android/icon/drawable-mdpi-icon.png": + * "platforms/android/res/drawable-mdpi/ic_stat_onesignal_default.png" + * }, { + * "resources/android/icon/drawable-xhdpi-icon.png": + * "platforms/android/res/drawable-xhdpi/ic_stat_onesignal_default.png" + * }, { + * "resources/android/icon/drawable-xxhdpi-icon.png": + * "platforms/android/res/drawable-xxhdpi/ic_stat_onesignal_default.png" + * }, { + * "resources/android/icon/drawable-xxxhdpi-icon.png": + * "platforms/android/res/drawable-xxxhdpi/ic_stat_onesignal_default.png" + * } ]; + * + * var fs = require('fs'); + * var path = require('path'); + * + * // no need to configure below + * var rootdir = process.argv[2]; + * + * filestocopy.forEach(function(obj) { + * Object.keys(obj).forEach(function(key) { + * var val = obj[key]; + * var srcfile = path.join(rootdir, key); + * var destfile = path.join(rootdir, val); + * //console.log("copying "+srcfile+" to "+destfile); + * var destdir = path.dirname(destfile); + * if (fs.existsSync(srcfile) && fs.existsSync(destdir)) { + * fs.createReadStream(srcfile).pipe( + * fs.createWriteStream(destfile)); + * } + * }); + * }); + * ``` + * + * 3. From the root of your project make the file executable: + * `$ chmod +x hooks/after_prepare/030_copy_android_notification_icons.js` + * + * * @usage * ```typescript * import { OneSignal } from '@ionic-native/onesignal';