![](/img/trans.png)
[英]Monaca: custom notification sound and small icon in Android with Onesignal
[英]OneSignal-Pushnotification small icon not displayed on Android
我們有一個Cordova-App,它在每個drawable-xy文件夾中都包含一個'icon.png'文件。 我們使用OneSignal提供推送通知。 通知按預期工作。 除了小圖標。 手機頂部欄上只有一個空白圖標,顯示應用程序符號。 我嘗試使用以下代碼段:
{
...
"small_icon" : "@android:drawable/icon.png"
....
}
我也嘗試過很多很多沒有“android”的變體,沒有“drawable”,沒有斜線,有.png和沒有.png。 等等
我在文檔中找到了這個:( https://documentation.onesignal.com/reference#create-notification )
small_icon: stringOptional
Specific Android icon to use. If blank the app icon is used. Must be the drawable resource name.
Android講述了可繪制資源:( https://developer.android.com/guide/topics/resources/drawable-resource.html )
將圖像保存在res / drawable / myimage.png中,此布局XML將圖像應用於視圖:
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/myimage" />
這對我來說應該是@drawable/icon
(不起作用)
將大圖標更改為網址對我來說很有用,帶有drawable的大圖標也沒有。
這個屬性small_icon
的正確用法是什么?
小圖標是Android資源,它是沒有文件擴展名或路徑的名稱。 在您的情況下,您需要在發送到OneSignal 創建通知 REST API調用的JSON有效負載中設置"small_icon" : "icon"
。
對於Cordova,您需要將您的圖標文件放在<project-root>/platforms/android/res
。 每個分辨率應該有一個,並使用Android Asset Studio推薦的方式來創建這個小圖標。 如果將名稱設置為ic_stat_onesignal_default
,OneSignal SDK將使用它來處理所有OneSignal通知,除非您在JSON消息中覆蓋它。 其中一個圖標文件的完整路徑應該是<project-root>/platforms/android/res/drawable-hdpi-v11/ic_stat_onesignal_default.png
。
有關完整詳細信息,請參閱OneSignal的“ 自定義通知圖標”指南。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.