Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question]: Custom push notification icon in Ionic Capacitor #956

Closed
1 task done
ayokay123 opened this issue Dec 29, 2023 · 4 comments
Closed
1 task done

[question]: Custom push notification icon in Ionic Capacitor #956

ayokay123 opened this issue Dec 29, 2023 · 4 comments

Comments

@ayokay123
Copy link

ayokay123 commented Dec 29, 2023

How can we help?

I'm currently encountering an issue while attempting to add the ic_stat_onesignal_default icon in a Capacitor project for Android. The documentation provides information on manually creating icons but does not specifically cover the Capacitor case.

I initially attempted to include the default icon inside capacitor-cordova-android-plugins, but after running npm run build && npm run sync, the updates I made were not reflected.

Now, I'm seeking guidance on the appropriate location to add the default icon for Capacitor. I've considered placing it either in app->src->main->AndroidManifest.xml or app->src->main->xml->config.xml. However, I'm unsure of the correct approach.

Has anyone encountered a similar situation with Capacitor and successfully resolved it? Some guidance would be appreciated.

Folder structure:
image

Code of Conduct

  • I agree to follow this project's Code of Conduct
@kpturner
Copy link

I followed the same documentation and have the icons in the folder structure defined here:
image

I have not even got a capacitor-cordova-android-plugins folder.

I have not tested this yet as the documentation also refers to updating config.xml file that does not exist either.

@kpturner
Copy link

It seems to work - kindof. I get a large icon to the left of the message as expected. To the right of the message I get something a bit odd looking :D

@kpturner
Copy link

kpturner commented Jan 10, 2024

OK this is now working as expected. I created a monochrome .png as per the docs and used
https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.space.trim=1&source.space.pad=0&name=ic_stat_onesignal_default
to generate the required folders/images. These folders can just be dropped straight into android/app/src/main/res.

I then put a full colour 256x256 png into drawable-xxxhdpi called ic_onesignal_large_icon_default.png (this gets displayed in the message body).

I then specified an accent-color for the small icon. You can pass this on the createNotification REST API call or via the method described here https://documentation.onesignal.com/docs/customize-notification-icons#set-default-small-icon-and-accent-colors

Seemed to work just fine with no other config.

@ayokay123
Copy link
Author

Yup worked for me as well 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants