Skip to content

Commit

Permalink
fix(android icon): specify color through variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ElodieC committed Mar 7, 2018
1 parent 07d207d commit 732fe93
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ If you want to set a notification icon with another name, pass it through variab

`cordova plugin add cordova-plugin-firebase@0.1.25 --save --variable NOTIFICATION_ICON_NAME=my_beautiful_icon_name`

For the background color of the notification icon, the default is #FF00FFFF. You can modify the color by passing it through variable at plugin installation :

`cordova plugin add cordova-plugin-firebase@0.1.25 --save --variable NOTIFICATION_ICON_NAME=my_beautiful_icon_name NOTIFICATION_ICON_COLOR=#000000`

To set a big icon and small icon for notifications, define them through drawable nodes.
Create the required styles.xml files and add the icons to the
`<projectroot>/res/native/android/res/<drawable-DPI>` folders.
Expand Down
6 changes: 5 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ xmlns:android="http://schemas.android.com/apk/res/android">

<platform name="android">
<preference name="NOTIFICATION_ICON_NAME" default="notification_icon"/>
<preference name="NOTIFICATION_ICON_COLOR" default="#FF00FFFF"/>
<js-module name="FirebasePlugin" src="www/firebase.js">
<clobbers target="FirebasePlugin" />
</js-module>
Expand All @@ -35,6 +36,7 @@ xmlns:android="http://schemas.android.com/apk/res/android">
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<service android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementService" />
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/$NOTIFICATION_ICON_NAME" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/accent" />
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<service android:name="org.apache.cordova.firebase.FirebasePluginMessagingService">
Expand All @@ -55,7 +57,9 @@ xmlns:android="http://schemas.android.com/apk/res/android">
<source-file src="src/android/FirebasePluginInstanceIDService.java" target-dir="src/org/apache/cordova/firebase" />
<source-file src="src/android/FirebasePluginMessagingService.java" target-dir="src/org/apache/cordova/firebase" />
<source-file src="src/android/colors.xml" target-dir="res/values" />

<config-file target="res/values/colors.xml" parent="/resources">
<color name="accent">$NOTIFICATION_ICON_COLOR</color>
</config-file>
<framework src="src/android/build.gradle" custom="true" type="gradleReference" />
<framework src="com.google.gms:google-services:+" />
<framework src="com.google.android.gms:play-services-tagmanager:+" />
Expand Down
1 change: 0 additions & 1 deletion src/android/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
<resources>
<color name="primary">#FFFFFF00</color>
<color name="primary_dark">#FF220022</color>
<color name="accent">#FF00FFFF</color>
</resources>

0 comments on commit 732fe93

Please sign in to comment.