我正在使用FCM
,我可以成功向我的应用发送推送通知。我想使用自定义通知图标,但它始终显示白色图标。我正在运行Lollipop
。
从它所说的documentation
icon可选,字符串表示通知图标。将值设置为 myicon for drawable resource myicon。
(我不知道究竟是什么意思)。但这就是我所做的。
我从here生成了图标。它确实有只有白色文字和透明背景的图标。该图标的示例截图图片为
我编辑了AndroidManifest并添加了android:icon="@drawable/ic_stat_set" in <Application
我尝试在设备上运行项目,新应用图标 ic_stat_set 正用作应用启动器。
从控制台我发送通知我确实收到了它,但它不是我刚设置的图标。
我也试过通过api发送。我收到了通知,但没有收到我设置的图标。
curl -X POST --header "Authorization: key=SERVERKEY" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"REGISTERATION-TOKEN-ID\",\"notification\":{\"body\":\"Yellow\" , \"icon\" : \"ic_stat_set\"} \"priority":\"10"}"
更新:我的可绘制图标文件为https://drive.google.com/open?id=0B5Fi1l7EbQ_BOERUMzNuQy1OWXM
我是否必须在控制台中的某些自定义数据文件中添加内容?我的偶像?我缺少什么?
由于
答案 0 :(得分:1)
I think it might be your icon size for the status bar that is off
Take a look here.
https://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html
Your app icon should be different than your notification icon.
The icon param in the notification is for the status bar.
The icon param in the Manifest is for the app icon(Shortcut)
I recommend this sample
答案 1 :(得分:0)
public function sortArticles($articles, $type)
{
// init sorted
$sorted = array();
// Array that contains order
$order_c = $this->category_o;
// Exchange key with value, so we can access "position by value"
$flipped_c = array_flip($order_c);
// Array that contains order
$order_o = $this->order_o;
// Exchange key with value, so we can access "position by value"
$flipped_o = array_flip($order_o);
// Iterate each article
foreach ($articles as $article) {
// If custom order was specified set it to article
// Otherwise, set 99999 value.
if ( array_key_exists( $article["category"], $flipped_c) ){
$article["category_o"] = $flipped_c[$article["category"]];
}else{
$article["category_o"] = 99999;
}
// If custom order was specified set it to article
// Otherwise, set 99999 value.
if ( array_key_exists($article["order"], $flipped_o) ){
$article["order_o"] = $flipped_o[$article["order"]];
}else{
$article["order_o"] = 99999;
}
// Push new article inside array
array_push($sorted, $article);
}
// get a list of sort columns and their data to pass to array_multisort
$sort = array();
foreach($sorted as $key => $value) {
$sort['order_o'][$key] = $value['order_o'];
$sort['category_o'][$key] = $value['category_o'];
}
// Determinate order type, category or order
if (strcmp($type, "category") == 0) {
// sort by category_o asc and then order_o asc
array_multisort($sort['category_o'], SORT_ASC, $sort['order_o'], SORT_ASC,$sorted);
}else{
// sort by order_o asc and then category_o asc
array_multisort($sort['order_o'], SORT_ASC, $sort['category_o'], SORT_ASC,$sorted);
}
// Return sorted array
return $sorted;
}
版本使用没有背景Lollipop
图片的图标。
png
答案 2 :(得分:0)
您应该使用侧影图标。你必须创建你的图标的轮廓图标(即通知图标)。白色背景问题将由此解决。 它对我有用。请试一试。
答案 3 :(得分:0)
默认情况下,在Lolipop状态栏的图标色调为白色后,Android API需要为上层版本和旧版本设置图标。没有黑客,你可以试试这个:
int icon = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? R.drawable.your_logo_for_Kitkat : R.mipmap.your_logo_for_Lolipop_and_uper_version;
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(icon)
.setContentTitle(remoteMessage.getData().get("title"))
.setContentText(remoteMessage.getData().get("shortDescription"))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setColor(Color.RED)
.setStyle(notiStyle)
.setContentIntent(pendingIntent);