Push notification icon - OneSignal

0

I'm using OneSignal to send push notifications to an application in Cordova that I'm developing.

Notifications are sent correctly, but I'm not able to change the notification icon. It is just an icon of a bell that is the default of OneSignal.

I followed the official documentation for icon customization ( link ) and it still did not work, creating the icons in the folders:

project-root/platforms/android/res/drawable-mdpi/ic_stat_onesignal_default.png (24x24)
project-root/platforms/android/res/drawable-hdpi/ic_stat_onesignal_default.png (36x36)
project-root/platforms/android/res/drawable-xdpi/ic_stat_onesignal_default.png (48x48)
project-root/platforms/android/res/drawable-xxdpi/ic_stat_onesignal_default.png (72x72)
project-root/platforms/android/res/drawable-xxxdpi/ic_stat_onesignal_default.png (96x96)

Does anyone know what I'm doing wrong?

    
asked by anonymous 26.09.2017 / 19:54

2 answers

0

After a very long week, I was able to resolve this issue of ONESIGNAL.

1st Forget the method of the IONIC website, code yourself a hole in this IF

if (fs.existsSync(srcfile) && fs.existsSync(destdir))

fs.existsSync (destdir) returns false because the folder does not exist in the root (/) folder. To see the error, just insert some console.log into the code and analyze what is being done.

2nd Based on the installation of IONIC Cloud Build within the Onesignal documentation to change the default icon ( link )

3rd Understand how RESOURCE-FILE works for config.xml, which belongs to APACHE CORDOVA architecture ( link )

4th After you generate the icon folder with the correct names and store them inside your project in a specific folder and understand all the previous steps, you can paste this code into your CONFIG. XML

<resource-file src="resources/android/onesignal/res/drawable-mdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-mdpi/ic_stat_onesignal_default.png" />
<resource-file src="resources/android/onesignal/res/drawable-hdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-hdpi/ic_stat_onesignal_default.png" />
<resource-file src="resources/android/onesignal/res/drawable-xhdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-xhdpi/ic_stat_onesignal_default.png" />
<resource-file src="resources/android/onesignal/res/drawable-xxhdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-xxhdpi/ic_stat_onesignal_default.png" />
<resource-file src="resources/android/onesignal/res/drawable-xxxhdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-xxxhdpi/ic_stat_onesignal_default.png" />

Conclusion : from what I understood there was a change in the file generation architecture res / within the IONIC platform, thus generating a disagreement between the documentation. And also, we can conclude that, IONIC has a portion of fault because the code type HOOK within the documentation does not work in version v1. (I do not know if it also buga in v1 and v3)

    
28.03.2018 / 18:40
0

I also went through the same problem, I watched and read several materials on the internet that seemed to get more and more complicated, and it is not. Well, I used the Paint 3D program, but I can use others also since I gave to change the image. The following is. Fill in all white icon and leave background transparent.

-Select the image you want to place as an icon.

-Open with Paint 3D.

-Use the Magic Selection to crop the image, be careful because it is this cut that will define the shape of its icon.   -After the cut done go to > Screen, and check the "Transparent Screen" option.

-Select the clipping and drag out of the image, then run the eraser at the bottom of the image making it all transparent.

-After you leave the background of the image all transparent, drag your cut back into the image, and fill it all white.

-When you finish filling, you will see that you have already created your icon, now it's just fine.

* Cut out the image in square format, the ideal 72px and 72px.

* Make sure there are not too many large borders as this affects the size of the icon.

- Now save the image, JPG or PNG format.

Now test, create a test notification and put your icon in "Badge."

See what your icon looks like.

NOTE: Depending on the version of your Android and Chrome, the icon will not appear, keep the two updated.

So that's it, I hope I have helped.

    
14.10.2018 / 22:59