Open steeper opened 6 years ago
In the config.xml i'm using this for android:
<resource-file src="resources/android/notification_icon/drawable-mdpi/notification_icon.png" target="app/src/main/res/drawable-mdpi/notification_icon.png" />
<resource-file src="resources/android/notification_icon/drawable-hdpi/notification_icon.png" target="app/src/main/res/drawable-hdpi/notification_icon.png" />
<resource-file src="resources/android/notification_icon/drawable-xhdpi/notification_icon.png" target="app/src/main/res/drawable-xhdpi/notification_icon.png" />
<resource-file src="resources/android/notification_icon/drawable-xxhdpi/notification_icon.png" target="app/src/main/res/drawable-xxhdpi/notification_icon.png" />
<resource-file src="resources/android/notification_icon/drawable-xxxhdpi/notification_icon.png" target="app/src/main/res/drawable-xxxhdpi/notification_icon.png" />
<config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>
<config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml">
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:value="@color/accent" />
</config-file>
It does copy the resources in resources/android/notification_icon/drawable-***/notification_icon.png
to the android respective folders and references them later in the manifest, i tested this and it works, maybe try it.
The icons are generated in here
@christianguevara I got a error AAPT: No resource found that matches the given name (at 'resource' with value '@drawable/notification_icon
Can you check if the resources were successfully copied to the android resources folders? Because if it's not found, then it's not been copied.
Edit: Remember, the original resources must be in resources/android/notification_icon/drawable-xxx/notification_icon.png
that's the cordova project folder as stated in the src
attribute of the XML copied.
In the config.xml i'm using this for android:
<resource-file src="resources/android/notification_icon/drawable-mdpi/notification_icon.png" target="app/src/main/res/drawable-mdpi/notification_icon.png" /> <resource-file src="resources/android/notification_icon/drawable-hdpi/notification_icon.png" target="app/src/main/res/drawable-hdpi/notification_icon.png" /> <resource-file src="resources/android/notification_icon/drawable-xhdpi/notification_icon.png" target="app/src/main/res/drawable-xhdpi/notification_icon.png" /> <resource-file src="resources/android/notification_icon/drawable-xxhdpi/notification_icon.png" target="app/src/main/res/drawable-xxhdpi/notification_icon.png" /> <resource-file src="resources/android/notification_icon/drawable-xxxhdpi/notification_icon.png" target="app/src/main/res/drawable-xxxhdpi/notification_icon.png" /> <config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml"> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" /> </config-file> <config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml"> <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:value="@color/accent" /> </config-file>
It does copy the resources in
resources/android/notification_icon/drawable-***/notification_icon.png
to the android respective folders and references them later in the manifest, i tested this and it works, maybe try it.The icons are generated in here
But this will set the default notification icon and when the method that creates the notification is called It will just use it as Small Icon and will not set it as Large Icon,can you show me an example of notification with Small and Large icon?
@rhanesoghlyan that would suggest you haven't got the icon resources in a location matching the src
parameter like in the example above. The src location is relative to the cordova folder.
In the config.xml i'm using this for android:
<resource-file src="resources/android/notification_icon/drawable-mdpi/notification_icon.png" target="app/src/main/res/drawable-mdpi/notification_icon.png" /> <resource-file src="resources/android/notification_icon/drawable-hdpi/notification_icon.png" target="app/src/main/res/drawable-hdpi/notification_icon.png" /> <resource-file src="resources/android/notification_icon/drawable-xhdpi/notification_icon.png" target="app/src/main/res/drawable-xhdpi/notification_icon.png" /> <resource-file src="resources/android/notification_icon/drawable-xxhdpi/notification_icon.png" target="app/src/main/res/drawable-xxhdpi/notification_icon.png" /> <resource-file src="resources/android/notification_icon/drawable-xxxhdpi/notification_icon.png" target="app/src/main/res/drawable-xxxhdpi/notification_icon.png" /> <config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml"> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" /> </config-file> <config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml"> <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:value="@color/accent" /> </config-file>
It does copy the resources in
resources/android/notification_icon/drawable-***/notification_icon.png
to the android respective folders and references them later in the manifest, i tested this and it works, maybe try it. The icons are generated in hereBut this will set the default notification icon and when the method that creates the notification is called It will just use it as Small Icon and will not set it as Large Icon,can you show me an example of notification with Small and Large icon?
Right, for the larger icon i'm almost sure a small code modification is needed in the lib, so if the icon exists it will show it.
I also can't get a different icon to show up for the life of me. Has anyone gotten this to work? And if so, can you break it down as much as possible?
For instance:
Also, if anyone could clarify how this is different from the cordova
@steeper ever found how to get this to work?
Here, I have put my files in a folder call res
in my cordova root. You can see the corresponding lines in my config.xml on the right.
now, as a result this is where the files get copied at build time and baked into the build
I been wondering if there is a way to set a different LargeIcon and Small Icon in the notification, as cordova-plugin-local-notifications does. I saw the code for both plugins and the only thing missing is the .setLargeIcon parameter in cordova-plugin-firebase but I don't know if this is correct and will work. Not so good with this code at the moment, I read what #764 says but you have to send the parameter from firebase console or by code. Is there a way it can be created with two different icons without sending params from the back in the json? Thanks for the help 😄