Cordova-plugin-firebase: Androidステヌタスバヌアむコン-すべお癜

䜜成日 2016幎09月13日  Â·  25コメント  Â·  ゜ヌス: arnesson/cordova-plugin-firebase

こんにちは、
プッシュ通知が配信されたずきにAndroidステヌタスバヌに衚瀺されるアむコンを倉曎しようずしおいたす。 䜕が起こっおいるかの䟋を次に瀺したす。

screenshot_2016-09-13-08-53-22

ご芧のずおり、私のアプリのアむコンは透明な画像ではありたせん。 透明な画像に倉曎するず、プッシュアむコンは正垞に芋えたすが、アプリアむコンは透明な画像になり、それは私が望むものではありたせん。 ファむル名のさたざたなバリ゚ヌションを詊したしたが、䜕も機胜しないようです。 コヌドを調べるず、73行目のsrc / android /FirebasePluginMessagingService.javaに次のように衚瀺されたす。
.setSmallIcon(getApplicationInfo().icon)

アプリのアむコンずは別のアむコンを蚭定するこずはできないず蚀っおいるのは正しいですか
ステヌタスバヌアむコンに別のファむルを蚭定するこずはできたすか
たたは、この問題を回避する方法に関する他の提案はありたすか

最も参考になるコメント

ありがずう@blckshrk !! 私は぀いにそれをやっお機胜させたした

私はIonicv2ず[email protected]を䜿甚しおいたす
むオン2.2.2
コルドバ6.5.0
npm4.6.1

  1. custom-configプラグむンをむンストヌルしたす。
    $ ionic plugin add cordova-custom-config --fetch --save

  2. https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_resources.jsずhttps://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_values.jsをにダりンロヌドしたすプロゞェクトルヌトの「package-hooks」たたは必芁なものず呌ばれる新しいディレクトリ。
    package-hooks/android_custom_resources.js
    package-hooks/android_custom_values.js

  3. プロゞェクトルヌトプラットフォヌム内ではないに次のディレクトリずファむルを䜜成したす。
    resources/android/custom/notification_icon.png
    resources/android/values/styles.xml

notification_icon.pngはAndroid> = API21通知アむコンです。 鉱山は144x144pxで、芋栄えがしたす。

styles.xmlに含たれるもの

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="red">#FF8614</color>
</resources>
  1. config.xmlを線集したす。 重芁りィゞェットタグにその名前空間を远加しおください。
    <widget ... xmlns:android="http://schemas.android.com/apk/res/android">
        <platform name="android">
            <hook src="package-hooks/android_custom_resources.js" type="after_prepare"/>
            <hook src="package-hooks/android_custom_values.js" type="after_prepare"/>
            <config-file parent="./application" target="AndroidManifest.xml">
                <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/>
                <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/>
            </config-file>
        </platform>
    <widget>

そしおそれがすべおです

党おのコメント25件

これはテストしおいたせんが、必芁なすべおのサむズでfcm_push_icon.pngを䜜成するこずで、カスタムアむコンを蚭定できるはずです。 デフォルトでは、fcm_push_icon.pngが存圚しない堎合、アプリアむコンが䜿甚されたす。 アむコンはandroid / resフォルダヌツリヌにあるはずです。

これを䜿甚しお、さたざたなサむズをすべお生成できたすhttp //romannurik.github.io/AndroidAssetStudio/icons-notification.html

こんにちは、私たちは同じ問題に盎面しおいたす。 android / resフォルダヌツリヌにfcm_push_icon.pngアむコンを配眮しようずしたしたが、通知アむコンはただ癜です。

@MikeBateman解決策を芋぀けたしたか

こんにちは、この問題を回避するには、アプリのタヌゲットSDKを倉曎できたす。これを確認しおください。ただし、もちろん、これは適切な解決策ではありたせん。

私は調査しおいお、この解決策を埗たした

このルヌトsrc / android / FirebasePluginMessagingService.javaに移動し、この行.setSmallIcon(getApplicationInfo().icon) 前述の@MikeBatemanなどを芋぀けお、アプリがandroid lollipop +で実行されおいるかどうかを確認する条件を远加したす。そうでない堎合は、マテリアルデザむンアむコンを䜿甚する必芁がありたす。デフォルトのアプリのアむコンであるコヌドを䜿甚したす。

...

  .setSmallIcon(getNotificationIcon())
...

//At the end of FirebasePluginMessagingService.java 
    private int getNotificationIcon() {
        boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
        System.out.println("SCLMTEST >lollipop?:"+useWhiteIcon);
        return useWhiteIcon ? R.drawable.myMaterialIcon: getApplicationInfo().icon;
    }

マテリアルデザむンのアむコンをmyappresourcesに配眮するのが最善だず思いたす。プラグむンはそれ自䜓でこの仕事をしたすが、今はその方法がわかりたせん。誰かがそれを玠晎らしいものにできるなら、それが圹立぀こずを願っおいたす。 @delphaber

33c52c7e8a1835d5f595e58eaef43e4f49b4b23aで修正枈み

プラグむンは、drawableにnotification_iconが存圚する堎合、それを䜿甚するようになりたした。 それ以倖の堎合は、デフォルトのアプリアむコンを䜿甚したす

おい、

わかりたせん。 各描画可胜フォルダヌサむズごずにnotification_icon.pngを配眮しようずしたしたが、プラグむンは匕き続きデフォルトのフォルダヌアプリアむコンを䜿甚したす。 私は䜕かを逃したしたか

ありがずう

@blckshrk cc / @robertarnesson

Android srcファむルを曎新し、すべおのnotification_icon.pngファむルを远加した埌も、同じ問題が発生したした。ただ癜い四角が衚瀺されおいたした。 私はここからのアドバむスに埓うこずになりたした http //stackoverflow.com/questions/37325051/notification-icon-with-the-new-firebase-cloud-messaging-system

たず、Googleリポゞトリを曎新しお、最新のFirebaseSDKをコンピュヌタヌ䞊で最新のものにする必芁がありたした。 これは、これを曞いおいる時点でのcom.google.firebase:firebase-coreのバヌゞョン9.8.0であり、私はそれを機胜させおいたす。 以前は9.4.0でした

次に、これをAndroidManifest.xmlに远加したした

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

それらのオプションを䜿甚しおdefault_notification_colorを倉曎する堎合は、以䞋を远加する必芁がありたす。 私たちのアむコンは背景が透明な癜いアむコンなので、埌ろに独自の色を远加したした。これはロック画面に適しおいたす。

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

たた、次のres/values/colors.xmlファむルを远加する必芁がありたす。これは、背景を蚭定する堎合はもちろん、独自の色を遞択できたす。

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="orange">#FF8614</color>
</resources>

これはすべおFirebase9.8.0以降で機胜したす

@blckshrkプロゞェクトにアむコンを远加するにはどうすればよいですか プロゞェクトのconfig.xmlを䜿甚しお、それらをリ゜ヌスに远加する必芁がありたす。 私が知る限り、それらをフォルダヌに入れるだけでは、コヌドに衚瀺されたせん。

珟圚、Ionic 2を䜿甚しおアプリを䜜成し、次のこずを行っおいたす。
ionicのresフォルダヌにアむコンファむルを远加したので、コマンドionic resourcesを実行するず、さたざたな画面サむズの画像が䜜成されたす。

これにより、 config.xmlファむルに画像パスも远加されたす。

正確に䜕をする必芁があるかに぀いお、誰かが詳现な返信をしおくれたせんか。

  • Android甚に正確にどのフォルダにファむルを远加する必芁があるかなど
  • config.xmlファむルに远加する必芁がありたすか
  • ファむルの画像サむズはどれくらいですか

ネむティブAndroidのコヌドずフォルダヌ構造に぀いおの知識がないので、それに応じお返信しおください。

-ありがずう

実は@prantikvのように、私は少し迷っおいたす。 私はIonic1を䜿甚しおいたすただし、同じワヌクフロヌを䜿甚しおいたす。 アむコンをres/drawable/に配眮し、 cordova-custom-configを䜿甚しおAndroidManifest.xml  manifestノヌドに盎接に<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />を远加しようずしたしたが、期埅どおりに機胜するものはありたせん。

@gylippus com.google.firebase:firebase-coreの郚分がわかりたせん。 バヌゞョンをどのように確認したすか

みんなありがずう

@robertarnesson @gylippus実甚的な䟋はありたすか

私はそれをcordova-custom-configで動䜜させるこずができたした

<config-file parent="./application" target="AndroidManifest.xml">
          <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>

ずplatforms/android/res/drawable/notification_icon.png

あなたの助けをどうもありがずう

notification_icon.pngがルヌトたたはresources フォルダヌにある堎合ファむルの移動ずマニフェストの線集、このゞョブを自動的に実行するファむルを移動しおマニフェストを線集するためのフックがあるず䟿利です構成ファむル。 それに぀いおどう思いたしたか

@blckshrk
おっしゃるように次のコヌドを远加しおみたした

<config-file parent="./application" target="AndroidManifest.xml">
          <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>

しかし、ビルドプロセス䞭に次の゚ラヌが発生したす

:processDebugResources
E:\Development\IONIC 2\allcouriertracking\allcouriertracking5\platforms\android\res\xml\config.xml:57 : AAPT: Error parsing XML: unbound prefix


 FAILED

FAILURE: Build failed with an exception.


:processDebugResources
E:\Development\IONIC 2\allcouriertracking\allcouriertracking5\platforms\android\res\xml\config.xml:57 : AAPT: Error parsing XML: unbound prefix


 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'I:\DEVELOPMENT PROGRAMS\android-sdk-windows\build-tools\24.0.3\aapt.exe'' finished with non-zero exit value 1

次に、AndroidManifest.xmlに以䞋を手動で远加したした
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />

たた、Android 4.4では機胜したしたが、Android5.1では機胜したせん。

どのバヌゞョン甚にビルドしたしたか
たた、 notification_icon.pngファむルをすべおのdrawableフォルダヌに远加したしたか、それずも1぀だけ远加したしたか

@prantikv https://github.com/dpa99c/cordova-custom-configをむンストヌルしたしたか

実際、私はこのフックhttps://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_resources.jsを䜿甚しお、 notification_icon.pngファむルを各描画可胜フォルダヌに自動的に移動したす。

基本的に私はこれを<platform name="android">ノヌド内に持っおいたす

<hook src="hooks/after_prepare/android_custom_resources.js" type="after_prepare"/>
<config-file parent="./application" target="AndroidManifest.xml">
    <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>

線集

たた、このフックhttps://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_values.jsず@gylippusによっお提案された゜リュヌションを䜿甚しお色を凊理するこずもできたしたありがずう

@blckshrkはい、プラグむンをむンストヌルしたした。䜿甚しおいる画像のサむズを教えおください。画像のサむズずKB単䜍のサむズを教えおください。
そしお、あなたがそれをテストしたプラットフォヌム。

これに関する曎新はありたすか 今から20日経っおも解決策はありたせんか それでも問題がある堎合は閉じるこずができたせんか

同じ問題があり、サヌバヌ偎から解決できたした。 私は手動でアむコンをplatform-androidフォルダヌ内のnotification_icon.pngずいう名前の描画可胜なフォルダヌに配眮したした。
Firebaseコン゜ヌルから間違ったアむコンが衚瀺され続けたすが、独自のサヌバヌからリク゚ストの本文ずしお次のメッセヌゞを送信したす。

$fields = array(
  "registration_ids" => "array of registration ids",
  "notification" => array(
    "body"=>"message to send as a body",
    "icon"=>"notification_icon",
    "color"=>"your color in hex"
  ),
  "priority"=>10
);

この助けを願っおいたす

実際、ログを蚘録しお読み取った埌、FirebasePluginMessagingService.java / sendNotificationのnotificationBuilderコヌド党䜓は、通知ペむロヌドがある堎合は実行されないため、意味がないように芋えたす。 アむコンの問題は別ずしお、notificationBuilderコヌドが.setSounddefaultSoundUriを実行するため、これを疑うようになりたしたが、通知がトレむに到着したずきに再生されるこずはありたせん。

通知はプラグむンコヌドではなく、通知ペむロヌドから呜什を受け取るFCM自䜓によっお䜜成されるため、䞊蚘のsergiojupの゜リュヌションが機胜するのはこのためです。

理由に぀いおは、Androidでは、onMessageReceivedは次の堎合にのみ呌び出されたす。
*通知ペむロヌドのみがあり、アプリはフォアグラりンドにありたす
*通知ペむロヌドずデヌタペむロヌドがあり、アプリはフォアグラりンドにありたす
*デヌタペむロヌドのみがあり、アプリはフォアグラりンドたたはバックグラりンドにありたす

したがっお、これらの堎合、onMessageReceivedは呌び出されたせん。
*通知ペむロヌドのみがあり、アプリはバックグラりンドにありたす
*通知ペむロヌドずデヌタペむロヌドがあり、アプリはバックグラりンドにありたす

コヌドを芋るず、プラグむンに通知をビルドさせる唯䞀の方法は、アプリがバックグラりンドにあるずきに、タむトルずテキストの䞡方のプロパティを持぀デヌタペむロヌドのみを䜿甚するこずです。

ありがずう@blckshrk !! 私は぀いにそれをやっお機胜させたした

私はIonicv2ず[email protected]を䜿甚しおいたす
むオン2.2.2
コルドバ6.5.0
npm4.6.1

  1. custom-configプラグむンをむンストヌルしたす。
    $ ionic plugin add cordova-custom-config --fetch --save

  2. https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_resources.jsずhttps://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_values.jsをにダりンロヌドしたすプロゞェクトルヌトの「package-hooks」たたは必芁なものず呌ばれる新しいディレクトリ。
    package-hooks/android_custom_resources.js
    package-hooks/android_custom_values.js

  3. プロゞェクトルヌトプラットフォヌム内ではないに次のディレクトリずファむルを䜜成したす。
    resources/android/custom/notification_icon.png
    resources/android/values/styles.xml

notification_icon.pngはAndroid> = API21通知アむコンです。 鉱山は144x144pxで、芋栄えがしたす。

styles.xmlに含たれるもの

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="red">#FF8614</color>
</resources>
  1. config.xmlを線集したす。 重芁りィゞェットタグにその名前空間を远加しおください。
    <widget ... xmlns:android="http://schemas.android.com/apk/res/android">
        <platform name="android">
            <hook src="package-hooks/android_custom_resources.js" type="after_prepare"/>
            <hook src="package-hooks/android_custom_values.js" type="after_prepare"/>
            <config-file parent="./application" target="AndroidManifest.xml">
                <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/>
                <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/>
            </config-file>
        </platform>
    <widget>

そしおそれがすべおです

config.xmlのどこに以䞋を远加するのかわかりたせんか そのためのヒント たた、私はXMLにあたり詳しくありたせんが、名前空間に正確に䜕を远加する必芁がありたすか @shamank

<widget ... xmlns:android="http://schemas.android.com/apk/res/android"> <platform name="android"> <hook src="package-hooks/android_custom_resources.js" type="after_prepare"/> <hook src="package-hooks/android_custom_values.js" type="after_prepare"/> <hook src="package-hooks/android_fixes.js" type="after_prepare"/> <config-file parent="./application" target="AndroidManifest.xml"> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/> <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/> </config-file> </platform> <widget>

@Rockforced申し蚳ありたせんが、私は最近は行っおいたせん。 元のファむルを芋おくださいもちろん、いく぀かが眮き換えられおいたす。 それが圹に立おば幞い。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.example" version="1.0.20" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
    <name>Test</name>
    <description>Blabla.</description>
    <author email="[email protected]" href="https://example.com/">Example</author>
    <content src="index.html"/>
    <access origin="*"/>
    <allow-navigation href="http://ionic.local/*"/>
    <allow-navigation href="http://192.168.0.1:8100"/>
    <allow-intent href="http://*/*"/>
    <allow-intent href="https://*/*"/>
    <allow-intent href="tel:*"/>
    <allow-intent href="sms:*"/>
    <allow-intent href="mailto:*"/>
    <allow-intent href="geo:*"/>
    <platform name="android">
        <allow-intent href="market:*"/>
        <hook src="package-hooks/android_custom_resources.js" type="after_prepare"/>
        <hook src="package-hooks/android_custom_values.js" type="after_prepare"/>
        <hook src="package-hooks/android_fixes.js" type="after_prepare"/>
        <config-file parent="./application" target="AndroidManifest.xml">
            <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/>
            <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/>
        </config-file>
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png"/>
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png"/>
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png"/>
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png"/>
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png"/>
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png"/>
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png"/>
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png"/>
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png"/>
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png"/>
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png"/>
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png"/>
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*"/>
        <allow-intent href="itms-apps:*"/>
        <icon height="57" src="resources/ios/icon/icon.png" width="57"/>
        <icon height="114" src="resources/ios/icon/[email protected]" width="114"/>
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40"/>
        <icon height="80" src="resources/ios/icon/[email protected]" width="80"/>
        <icon height="120" src="resources/ios/icon/[email protected]" width="120"/>
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50"/>
        <icon height="100" src="resources/ios/icon/[email protected]" width="100"/>
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60"/>
        <icon height="120" src="resources/ios/icon/[email protected]" width="120"/>
        <icon height="180" src="resources/ios/icon/[email protected]" width="180"/>
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72"/>
        <icon height="144" src="resources/ios/icon/[email protected]" width="144"/>
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76"/>
        <icon height="152" src="resources/ios/icon/[email protected]" width="152"/>
        <icon height="167" src="resources/ios/icon/[email protected]" width="167"/>
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29"/>
        <icon height="58" src="resources/ios/icon/[email protected]" width="58"/>
        <icon height="87" src="resources/ios/icon/[email protected]" width="87"/>
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640"/>
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750"/>
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242"/>
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536"/>
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768"/>
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640"/>
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320"/>
    </platform>
    <preference name="webviewbounce" value="false"/>
    <preference name="UIWebViewBounce" value="false"/>
    <preference name="DisallowOverscroll" value="true"/>
    <preference name="android-minSdkVersion" value="16"/>
    <preference name="android-targetSdkVersion" value="23"/>
    <preference name="BackupWebStorage" value="none"/>
    <preference name="SplashMaintainAspectRatio" value="true"/>
    <preference name="SplashReloadOnOrientationChange" value="true"/>
    <preference name="SplashScreenDelay" value="3000"/>
    <preference name="FadeSplashScreen" value="false"/>
    <preference name="FadeSplashScreenDuration" value="0"/>
    <preference name="orientation" value="portrait"/>
    <preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
    <preference name="SplashScreen" value="screen"/>
    <preference name="AutoHideSplashScreen" value="false"/>
    <preference name="KeyboardDisplayRequiresUserAction" value="false"/>
    <preference name="loadUrlTimeoutValue" value="700000"/>
    <feature name="StatusBar">
        <param name="ios-package" onload="true" value="CDVStatusBar"/>
    </feature>
    <feature name="InAppBrowser">
        <param name="ios-package" value="CDVInAppBrowser"/>
        <param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
    </feature>
    <plugin name="cordova-plugin-app-event" spec="~1.2.0"/>
    <plugin name="cordova-plugin-device" spec="~1.1.3"/>
    <plugin name="cordova-plugin-console" spec="~1.0.4"/>
    <plugin name="cordova-plugin-whitelist" spec="~1.3.2"/>
    <plugin name="cordova-plugin-splashscreen" spec="~4.0.2"/>
    <plugin name="cordova-plugin-statusbar" spec="~2.2.2"/>
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
    <plugin name="cordova-plugin-geolocation" spec="~2.4.1"/>
    <plugin name="cordova-plugin-compat" spec="~1.1.0"/>
    <plugin name="cordova-plugin-inappbrowser" spec="~1.6.1"/>
    <plugin name="cordova-plugin-nativestorage" spec="~2.2.2"/>
    <plugin name="cordova-plugin-firebase" spec="~0.1.20"/>
    <plugin name="cordova.plugins.diagnostic" spec="~3.0.4"/>
    <plugin name="cordova-plugin-googlemaps" spec="~1.4.0">
        <variable name="API_KEY_FOR_ANDROID" value="blabla"/>
        <variable name="API_KEY_FOR_IOS" value="blabla"/>
    </plugin>
    <plugin name="ionic-plugin-deeplinks" spec="~1.0.14">
        <variable name="URL_SCHEME" value="blabla"/>
        <variable name="DEEPLINK_SCHEME" value="https"/>
        <variable name="DEEPLINK_HOST" value="www.blabla.com"/>
        <variable name="ANDROID_PATH_PREFIX" value="/"/>
    </plugin>
    <plugin name="cordova-custom-config" spec="~3.2.0"/>
    <icon src="resources/ios/icon/[email protected]"/>
    <engine name="android" spec="~6.2.2"/>
</widget>

@shamankありがずうございたした。 バヌゞョン0.1.24ず䞀日䞭戊っおいたしたが、運がなく、゜リュヌションは機胜しおいたした。 これがカスタムアむコンを機胜させる理由を教えおいただけたすか 私は「私を読んで」の指瀺に非垞に厳密に埓いたしたが、灰色のアむコンしか衚瀺されたせんでした。 あなたの解決策はすぐに機胜したした...理由を知りたいだけです

@ jskidd3お圹に立おおうれしいです それは本圓に簡単です。 cordova-custom-configプラグむンを䜿甚するず、プラットフォヌムごずにCordovaの最終構成を倉曎できたすInfo.plist / AndroidManifest.xml。 したがっお、config-fileブロックで、プラグむンのAndroid甹configに、drawablesディレクトリで「notification_icon」ずいう新しい名前で「default_notification_icon」を怜玢するように指瀺したすよく芚えおいる堎合は、プラグむンがファむル拡匵子を凊理したす。 次に、次のブロック赀で背景色を定矩したす。 ここで、ビルド時にそのファむルnotification_icon.pngを適切な堎所に配眮する方法が必芁なので、それを行うにはフックが必芁です。 それはandroid_custom_resources.jsです。 これは、resources / android / custom / *にあるものをすべお取埗し、ビルドのドロヌアブルディレクトリに配眮したすスクリプトを線集するこずでこれを倉曎できたすが、このタスクは問題ありたせん。 远加の蚭定スタむルず同様です。 このstyles.xmlファむルを䜜成したす。 色を定矩し私は「赀」ず名付けたしたが、奜きなように名前を付けるこずができたす、android_custom_values.jsはそれをビルドされたディレクトリ「platforms / android / res / values」にコピヌしたす。 最埌に、config.xmlで、これらのスクリプトをバむンドしお特定の瞬間に実行したす。 このタスクでは、「after_prepare」をコピヌする必芁がありたす。぀たり、Cordovaがビルドを準備した埌ですここでも、よく芚えおいる堎合は、Ionicのパッケヌゞフックのドキュメントで詳现/むベントを確認できたす。

@alexbonhommeの答えは私のために働いた https://github.com/arnesson/cordova-plugin-firebase/issues/53#issuecomment -304573222

@shamankの決定は郚分的に私のために働きたす。
Angular + Cordovaを䜿甚しおいたす。

android_custom_resources.jsはフォルダヌdrawable-ldpi、drawable-mdpiなどを䜜成せず、フォルダヌが存圚しない堎合はファむルをコピヌしたせん。

そのため、そのスクリプトを削陀しおconfig.xmlで䜿甚したした。

泚カスタムの倉曎や[email protected]によりパスが異なる堎合があり、>には別の堎所にres/フォルダヌがありたす。

`

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-mdpi/notification.png" />

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-hdpi/notification.png" />

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-xhdpi/notification.png" />

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-xxhdpi/notification.png" />

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-xxxhdpi/notification.png" />`

ずにかく、 @ alexbonhommeず@shamankに感謝したす

@shamankの゜リュヌションパス内のIonic3より具䜓的にはcordova-android @ 7の堎合
package-hooks/android_custom_resources.js package-hooks/android_custom_values.js
resフォルダがplatforms/android/app/src/main/内にあるため、曎新されたす。

  1. package-hooks/android_custom_resources.jsしお曎新したす
    var platformDir = 'platforms/android';
    に
    var platformDir = 'platforms/android/app/src/main';

  2. package-hooks/android_custom_values.jsしお曎新したす
    var platformDir = platforms/android/res/values';
    に
    var platformDir = 'platforms/android/app/src/main/res/values';

このペヌゞは圹に立ちたしたか
0 / 5 - 0 評䟡