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 /plugins | |
parent | 5b8d116e335bd7574928485adc1d4e9cf5ee0564 (diff) | |
download | voidsky-f61d1e1f9410865505a316d825a314354a84171d.tar.zst |
Apply notification icon settings of FCM on Android (#3113)
Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/withAndroidManifestFCMIconPlugin.js | 37 |
1 files changed, 37 insertions, 0 deletions
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 + }) +} |