diff options
author | Eiichi Yoshikawa <edo@bari-ikutsu.com> | 2024-03-07 03:24:08 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-06 10:24:08 -0800 |
commit | f61d1e1f9410865505a316d825a314354a84171d (patch) | |
tree | 832ab38d083164b6f2548a05e732ded768fd6a4f | |
parent | 5b8d116e335bd7574928485adc1d4e9cf5ee0564 (diff) | |
download | voidsky-f61d1e1f9410865505a316d825a314354a84171d.tar.zst |
Apply notification icon settings of FCM on Android (#3113)
Co-authored-by: Hailey <me@haileyok.com>
-rw-r--r-- | app.config.js | 3 | ||||
-rw-r--r-- | plugins/withAndroidManifestFCMIconPlugin.js | 37 |
2 files changed, 39 insertions, 1 deletions
diff --git a/app.config.js b/app.config.js index 530e07b9b..2552d3489 100644 --- a/app.config.js +++ b/app.config.js @@ -153,10 +153,11 @@ module.exports = function (config) { 'expo-notifications', { icon: './assets/icon-android-notification.png', - color: '#ffffff', + color: '#1185fe', }, ], './plugins/withAndroidManifestPlugin.js', + './plugins/withAndroidManifestFCMIconPlugin.js', './plugins/withAndroidStylesWindowBackgroundPlugin.js', './plugins/shareExtension/withShareExtensions.js', ].filter(Boolean), diff --git a/plugins/withAndroidManifestFCMIconPlugin.js b/plugins/withAndroidManifestFCMIconPlugin.js new file mode 100644 index 000000000..066a975d8 --- /dev/null +++ b/plugins/withAndroidManifestFCMIconPlugin.js @@ -0,0 +1,37 @@ +const {withAndroidManifest} = require('expo/config-plugins') + +module.exports = function withAndroidManifestFCMIconPlugin(appConfig) { + return withAndroidManifest(appConfig, function (decoratedAppConfig) { + try { + function addOrModifyMetaData(metaData, name, resource) { + const elem = metaData.find(elem => elem.$['android:name'] === name) + if (elem === undefined) { + metaData.push({ + $: { + 'android:name': name, + 'android:resource': resource, + }, + }) + } else { + elem.$['android:resource'] = resource + } + } + const androidManifest = decoratedAppConfig.modResults.manifest + const metaData = androidManifest.application[0]['meta-data'] + addOrModifyMetaData( + metaData, + 'com.google.firebase.messaging.default_notification_color', + '@color/notification_icon_color', + ) + addOrModifyMetaData( + metaData, + 'com.google.firebase.messaging.default_notification_icon', + '@drawable/notification_icon', + ) + return decoratedAppConfig + } catch (e) { + console.error(`withAndroidManifestFCMIconPlugin failed`, e) + } + return decoratedAppConfig + }) +} |