Ionic / OneSignal - Error changing default notifications icon

0

I'm trying for some time to change the default notification icon of OneSignal using Ionic, but until then, to no avail.

I followed the suggested steps in the official Ionic documentation, created the file 030_copy_android_notification_icons in the <app-root>/hooks/after_prepare directory, and generated a new build, but the icon continued with the default notification bell.

I tried to make the change in a different way, following the OnseSignal's own documentation , but I get the following errors when I try to run the app on my phone with the command ionic cordova run android --device :

Toresolvethisproblem,Imanuallycreatedthexmlfolderinthe<app-root>/platforms/android/resdirectory,butwhenIrunthecommandagainIgetanothererror:

Atthispoint,Ihadtocreatethefoldervaluesandinsideitthefilestrings.xmlandwhenIruntheioniccordovarunandroid--devicecommandIgetthefollowingerror:

And from that point I do not know what else to do. I already researched here in Stack Overflow in Portuguese and also in the gringo, but I did not find anything that could help me, because this last error is quite generic.

I've also tried removing the android from the cord and adding it again with the commands ionic cordova platform rm android and ionic cordova platform add android .

I also tried to downgrade from version 8.0.0 to 7.1.0, and nothing.

Note: Despite the [OK] Your app has been deployed. message, the application is not installed on the phone. If I remove the folder <app-root>/platforms/android/res everything works normally, but without the icon I need to insert in the notifications.

    
asked by anonymous 06.02.2018 / 05:06

1 answer

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:35