Ionic / Onesignal - Error changing the default notification icon

Asked

Viewed 320 times

0

I’ve been trying for some time to change the standard Onesignal notifications icon using Ionic, but so far, unsuccessful.

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

I tried to make the change differently, following the documentation of Onsesignal itself, but I get the following mistakes when I try rotate the app on my phone with the command ionic cordova run android --device:

inserir a descrição da imagem aqui

To solve this problem, I manually created the folder xml in the directory <app-root>/platforms/android/res, but when executing the command again I get another error:

inserir a descrição da imagem aqui

At that point, I had to create the folder values and within it the archive strings.xml and when executing the new command ionic cordova run android --device I get the following error:

inserir a descrição da imagem aqui

And from that point on, I don’t know what else to do. I already searched here in Stack Overflow in Portuguese and also in gringo, but I did not find anything that could help me, because this last mistake is quite generic.

I’ve also tried to remove android from Cordova and add again with commands ionic cordova platform rm android and ionic cordova platform add android.

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

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

  • Managed to solve this problem?

1 answer

0

After a very long week I managed to solve this ONESIGNAL pie

1º Forget the method of the IONIC site, the code te a hole in this IF

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

Fs.existsSync(destdir) returns false, as 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 Take as a basis the installation of IONIC Cloud Build within the Onesignal documentation for changing the default icon (link)

Understand how the config.xml RESOURCE-FILE works, which belongs to the APACHE CORDOVA architecture (https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#Resource-file)

fourth After you generate the icon folder with the correct names and save them within your project in some 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" />

Completion: from what I understand there has been a change in the architecture of res/ file generation within the IONIC platform, thus generating a disagreement between the documentations. And also, we can conclude that IONIC is partly to blame because the HOOK type code within the documentation does not work in version v1. (I do not know if also Buga in v1 and v3)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.