[OneSignal Plugin] How to set small icon for Android

[OneSignal Plugin] How to set small icon for Android

  
Forge Component
(5)
Published on 6 Oct (14 days ago) by OutSystems R&D
5 votes
Published on 6 Oct (14 days ago) by OutSystems R&D

Hi,

We are currently getting a default bell icon as a small icon on Android devices. We have icon as ldpi on resources but it seems it is ignored:

{  
    "resources" : "MyResources.zip",
    "icons": {
        "android": [{
            "resource": "iconAndroid-ldpi.png",
            "density": "ldpi"
        }, ...


Also as for Androids > 5 the icon should be "all white" and on previous versions it is normal icon - should we have 2 different icons and where can we set them then?

Thank you.

Mykola Tkachenko wrote:

Hi,

We are currently getting a default bell icon as a small icon on Android devices. We have icon as ldpi on resources but it seems it is ignored:

{  
    "resources" : "MyResources.zip",
    "icons": {
        "android": [{
            "resource": "iconAndroid-ldpi.png",
            "density": "ldpi"
        }, ...


Also as for Androids > 5 the icon should be "all white" and on previous versions it is normal icon - should we have 2 different icons and where can we set them then?

Thank you.

Hi Mykola,


I just tested everything and it seems to be working. This is what I've done:


1. Created a default application;

2. Added this JSON to my extensibility configurations:

{
    "icons": {
        "android": [{
            "resource": "android/mipmap-ldpi/ic_launcher.png",
            "density": "ldpi"
        },{
            "resource": "android/mipmap-mdpi/ic_launcher.png",
            "density": "mdpi"
        },{
            "resource": "android/mipmap-hdpi/ic_launcher.png",
            "density": "hdpi"
        },{
            "resource": "android/mipmap-xhdpi/ic_launcher.png",
            "density": "xhdpi"
        },{
            "resource": "android/mipmap-xxhdpi/ic_launcher.png",
            "density": "xxhdpi"
        },{
            "resource": "android/mipmap-xxxhdpi/ic_launcher.png",
            "density": "xxxhdpi"
        }]
    },
    "resource": "android.zip"
}

3. Added a android.zip to the resources with this file structure:

android.zip

|--- android

|----- mipmap-xxxhdpi

|--------- ic_launcher.png

|----- mipmap-ldpi

|--------- ic_launcher.png

| ----- .....

5. Added the Notification plugin with an action

4. In the end, generated an Android app.


Please, check if this helps you :)


Best Regards,

Bruno Grácio

Hi Bruno,

Thank you very much for reply. I'll create a separate app for testing and share here the result. 

Just to confirm the "small icon" for Android >=5 should be a different then app logo image (white with transparency). In resources you have only one image for each size that will be used as app icon, right?

Thank you.

Best regards,

Nick

Solution

Hello, Nick,

It's been a long time coming, but there was a new version released that allows for the customization of the notification's icons, so you probably don't need to use this method anymore.

Could you please test it and let us know if it fits your purpose?

Best regards,

Carlos Simões

Solution

Hello Carlos,

Thank you for update - I will try it ASAP.

Just to confirm the file "smallIcon" attribute has a description "...the resource to display should be drawable...". Does it mean that this con file should be in some special folder of resources zip file ? Should the file name contain extension?


Thank you.

Nick

Yep, looks like it, Nick!

Some of the other images ('BigPicture' or 'LargeIcon') can use a URL, but small icon must be a drawable resource (as mentioned in OneSignal's Android SDK documentation).

Best regards,

Carlos Simões

It works if use this dummy plugin 

https://www.outsystems.com/forums/discussion/23123/add-drawable-icons-to-mobile-application/#Post90866 to place images in correct folders :)


Best regards,

Nick

Hi Mykola.

I followed the same steps mentioned in https://www.outsystems.com/forums/discussion/23123/add-drawable-icons-to-mobile-application/#Post90866 and could not get it working.

The icons are not included in the APK file generated by Outsystems.

I also tried these two others articles without success:

https://success.outsystems.com/Documentation/10/Delivering_Mobile_Apps/Customize_Your_Mobile_App/Extensibility_Configurations_JSON_Schema

https://success.outsystems.com/Documentation/10/Delivering_Mobile_Apps/Customize_Your_Mobile_App/Modify_the_App_Icon#Icon_Sizes_and_Densities

Could you help me trying to figure out what could be happenned ?

How could this be so complicated :-(

Thanks in advance.

Luciano Guimaraes

Hi Luciano, 

I don't know how you check whether files are included properly on app but following https://www.outsystems.com/forums/discussion/23123/add-drawable-icons-to-mobile-application/#Post90866 instructions without any modification you should be able to generate api file and when use this one signal plugin use server action with SmallIcon parameter set to "pw_notification"  the default icon (bell) is changed to square. 

You can replace files with your logo and add more files - just have to include paths  to plugin.xml file too.

Hello, Luciano,

Sorry to hear you're having trouble getting this to work. :\

Here's what I found:

  1. At the moment, there's no way to add drawable resources via Extensibility Configurations, unless you change your app's icon (which incidentally is a drawable resource);
  2. You can, however, use the workaround Nick and yourself mentioned, using a plugin that includes de image resources and copies them to the correct folder at build time.

You mentioned you tried the workaround, but the images were not included on the app you generated. Were the images named 'pw-notification' as in the original file? Could you share the Zip file you are using to achieve this with us?

EDIT: Just saw Nick's post and would like to reinforce the part that mentions that you need to edit the plugin.xml file if you add more files to the folders.

Best regards,

Carlos Simões

Hi Carlos and Mykola.

I was trying to change my mobile app following the steps suggested before.

Now I understood I have to build a "dummy" plugin and references it on my mobile app, right ?

I'll try this later and let you know the results.

Cheers.

Luciano

Yes, Luciano. Just follow Carlos Alfaro's instructions on the thread you mentioned, making sure that either the names need to stay the same or you will need to adjust them on the plugin.xml, like Nick mentioned.

Sorry for the hassle, but that's the only way to add drawable resources to your mobile apps.

Hi everyone!

I tried this and it is working using OneSignal Plugin also.

Thank you all for your help! It was amazing! You deserve a Nobel Prize ;-)

Cheers

Luciano Guimaraes

That's great news, Luciano!

Glad to help!

Best regards,

Carlos Simões