3

我試圖在通知中顯示應用程序圖標。但它顯示空白圖標。圖標不顯示在離子2中的推送通知中

我給pushoptions如下:

const options: PushOptions = { 
     android: { 
     titleKey: 'App', 
     sound: 'true', 
     icon: 'res/drawable/notification_icon', 
     topics: ['MyTopic'] 
     }, 
     ios: { 
     alert: 'true', 
     badge: false, 
     sound: 'true' 
     }, 
     windows: {} 
    }; 

和複製的圖標圖像作爲低於該具有40 * 40像素的分辨率。

<resource-file src="resources/notification_icon.png" target="res/drawable/notification_icon.png" /> 

有什麼我失蹤了嗎? enter image description here

更新:

我跟着這個鏈接:https://github.com/ionic-team/ionic-cli/issues/608和複製資源下的所有通知圖標/安卓/通知/繪製-XYZ/ic_stat_ac_unit.png水庫/可繪製-XYZ/ic_stat_ac_unit嘗試過。

<resource-file src="resources/android/notification/drawable-hdpi/ic_stat_ac_unit.png" target="res/drawable-hdpi/ic_stat_ac_unit.png" /> 
     <resource-file src="resources/android/notification/drawable-mdpi/ic_stat_ac_unit.png" target="res/drawable-mdpi/ic_stat_ac_unit.png" /> 
     <resource-file src="resources/android/notification/drawable-xhdpi/ic_stat_ac_unit.png" target="res/drawable-xhdpi/ic_stat_ac_unit.png" /> 
     <resource-file src="resources/android/notification/drawable-xxhdpi/ic_stat_ac_unit.png" target="res/drawable-xxhdpi/ic_stat_ac_unit.png" /> 
     <resource-file src="resources/android/notification/drawable-xxxhdpi/ic_stat_ac_unit.png" target="res/drawable-xxxhdpi/ic_stat_ac_unit.png" /> 

和改性PushOptions在app.component.ts到:

android: { 
    titleKey: 'App', 
    sound: true, 
    vibrate:true, 
    icon: 'ic_stat_ac_unit', 
    iconColor:'#343434', 
    topics: ['MyTopic'] 
    } 
使用以下語句爲png

即使這樣也行不通 - 同樣的問題。

回答

2

它可能不是在要顯示的形狀中的圖標上設置alpha通道。 Android 5.0+爲所有小型通知圖標添加了白色蒙版。您可以使用Android Asset Studio來創建圖標集,因爲它會告訴您它將如何在設備上顯示,以確保其正確。

在Android 5.0+中,推送通知圖標必須爲雙色: 透明背景+白色前景;否則默認應用 圖標拍攝,以及任何非透明顯示爲白色(所以 很有可能,用戶將看到一個白色的)

+0

我試着用https://i.stack.imgur.com/Vr27p.png該圖是在Android資產Studio鏈接,但不在設備上。僅供參考,我使用離子2 – user1188867

+0

@ user1188867 for Ionic,請通過此[問題](https://github.com/ionic-team/ionic-cli/issues/608)它應該引導您正確的路徑 – Webruster

+0

I認爲url鏈接被破壞。請驗證並再次發佈。 – user1188867