LoginSignup
40
36

More than 5 years have passed since last update.

Firebase v9.8からFirebase Notificationsのアイコンが指定できるようになりました

Last updated at Posted at 2016-10-25

概要

正しくはFirebase Cloud Messagingがv9.8からデフォルトの通知アイコンとアクセントカラーを設定できるようになったことで、実質Notificationsのアイコンをランチャーアイコン固定から自由なアイコンに変更することができるようになりました。

Firebase Android SDK Release Notes  |  Firebase

Cloud Messaging

FEATURE Improved the reliability of message delivery to Android Wear devices that are paired with an iOS device.
FEATURE Added the ability to customize the default notification icon and color using AndroidManifest.xml metadata.

実装方法

AndroidManifest.xmlのapplication内のmeta-dataとして登録します。

AndroidManifest.xml
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:name=".FanfanApplication"
    >

    <meta-data android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@android:drawable/sym_action_email" />
    <meta-data android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorAccent" />

    <!-- 以降、省略 -->

スクリーンショット 2016-10-25 11.43.09.png

ランチャーアイコンとは違うアイコン+ピンクのアクセントカラーを設定しました。

実行結果

meta-dataを設定していない場合(Android 7.0)

Screenshot_20161025-115059~01.png

Android 6.0

Screenshot_1477362970.png

Android 7.0

Screenshot_1477362557.png

ようやく実用しやすい感じになりましたね!

40
36
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
40
36