_From @noor07 on February 6, 2018 11:7_
hi guyz, my ionic version is=>
Ionic Framework: 3.9.2
Ionic App Scripts: 3.1.6
Angular Core: 5.0.3
Angular Compiler CLI: 5.0.3
Node: 8.9.4
OS Platform: Windows 10
Navigator Platform: Win32
I write a command ionic start appname, and there is no hooks folder, plz help, cause i have to use the onesignal plugin.
_Copied from original issue: ionic-team/ionic#13963_
@noor07 Not sure why you need a hooks folder. Are you getting an error?
In any case, please update your CLI to the latest version and print the output of ionic info.
I want to use the OneSignal plugin, for this plugin I have to make a js file in my hooks folder as per the https://ionicframework.com/docs/native/onesignal/ this docs link. I have the latest cli, I uninstall it and then install it again, but nothing happened.
cli packages: (C:\Users\hodan\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.6
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Node : v8.9.4
npm : 5.6.0
OS : Windows 10
Misc:
backend : pro
@noor07 Could you try adding the hook to config.xml instead of using the directory method. You don't need to chmod +x the file, either: https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/#configxml
That documentation may need updating.
Hi, I am somewhat confused by @dwieeb's answer. If you suggest we add "the hook" to config.xml - am assuming you are talking about this hook <hook type="after_prepare" src="hooks/copy_android_notification_icons.js" /> - as per the documentation fore-mentioned, where exactly do we place the copy_android_notification_icons.js file in the project?
Most of the hooks as illustrated by https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/#configxml are placed inside a scripts folder. Does it mean we have to create a similar folder to place the copy_android_notification_icons.js file in?
I am also trying to add default icon for push notification.
Ionic:
ionic (Ionic CLI) : 4.3.1 (C:\Users\Paul\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0
Cordova:
cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : android 7.1.2
Cordova Plugins : cordova-plugin-ionic-webview 2.2.3, (and 16 other plugins)
System:
Android SDK Tools : 26.1.1 (C:\Users\Paul\AppData\Local\Android\Sdk)
NodeJS : v8.11.4 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10
OK. Figured it out. For all the lines of code in the copy_android_notification_icons.js in the hook folder, all it's doing is coping icons from one folder to another - should have guessed from the name! So basically it is as simple as copying the icon folder to the platforms res folder manually after generating the icons, in this case it will be coping icon resources from resources/android/folder_name/ to platforms/android/app/src/main/res/ as per the ionic documentation.
The second easy way to do this (The one I use in my project): I add
<resource-file src="resources/android/notification/drawable-mdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-mdpi/ic_stat_onesignal_default.png" />
<resource-file src="resources/android/notification/drawable-hdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-hdpi/ic_stat_onesignal_default.png" />
<resource-file src="resources/android/notification/drawable-xhdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-xhdpi/ic_stat_onesignal_default.png" />
<resource-file src="resources/android/notification/drawable-xxhdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-xxhdpi/ic_stat_onesignal_default.png" />
<resource-file src="resources/android/notification/drawable-xxxhdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-xxxhdpi/ic_stat_onesignal_default.png" />
to theconfig.xml
Then I load the notification(you can name it anything) folder with the resources I generated from Android Asset Studio. I build the project again and all is good!
Most helpful comment
I want to use the OneSignal plugin, for this plugin I have to make a js file in my hooks folder as per the https://ionicframework.com/docs/native/onesignal/ this docs link. I have the latest cli, I uninstall it and then install it again, but nothing happened.
cli packages: (C:\Users\hodan\AppData\Roaming\npm\node_modules)
global packages:
local packages:
System:
Misc: