My app icon is blue/red and when I receive a push notification the icon on status bar is the same app icon(blue/red). I want the icon of the status bar be a transparent and white version.
我的应用程序图标为蓝色/红色,当我收到推送通知时,状态栏上的图标是相同的应用程序图标(蓝色/红色)。我希望状态栏的图标是透明的白色版本。
My ionic project is using this cordova plugin to receive push notifications. The official docs of the plugin theres nothing about how to configure the icon of the status bar notification.
我的离子项目正在使用这个cordova插件来接收推送通知。该插件的官方文档没有关于如何配置状态栏通知的图标。
3 个解决方案
#1
11
Looks like what you’d want isn’t possible with that library.
看起来你想要的东西是不可能的那个库。
On iOS
According to the documentation, the notification icon is automatically set to your app’s small icon (Icon-Small.png
):
根据文档,通知图标会自动设置为应用程序的小图标(Icon-Small.png):
In the banner, iOS displays your notification message and the small version of your app icon.
在横幅中,iOS会显示您的通知消息和应用程序图标的小版本。
Unless you change the small version of the app icon, this is not possible at all on iOS.
除非您更改应用程序图标的小版本,否则在iOS上根本无法实现。
On Android
Using the Android APIs this would be simple with Notification.Builder#setSmallIcon(int)
, but the library you’re using hard-codes that icon to the application’s icon.
使用Android API,这对于Notification.Builder#setSmallIcon(int)来说很简单,但是您正在使用的库将该图标硬编码到应用程序的图标。
You’d need to modify the library to accept other icons. It’s likely that this has not been implemented so that the behaviour would be consistent on all platforms.
您需要修改库以接受其他图标。它可能尚未实现,因此行为在所有平台上都是一致的。
UPDATE
UPDATE
Now with this plugin is completely possible.
现在有了这个插件是完全可能的。
#2
4
private void shownotification(String message, Context context) {
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mNotifyBuilder = new NotificationCompat.Builder(
context).setContentTitle("Jaswinderwadali").setContentText(message)
.setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true)
.setSmallIcon(R.drawable.Mypic);
Notification notification = mNotifyBuilder.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(0, notification);
}
Its For android change icon of notification in status bar .setSmallIcon(R.drawable.Mypic)
它的状态栏中的通知更改通知图标.setSmallIcon(R.drawable.Mypic)
#3
0
You need to create a icon named ic_stat_onesignal_default in your drawables directory which will be shown instead of OneSignal's default bell icon.
您需要在drawables目录中创建一个名为ic_stat_onesignal_default的图标,该图标将显示而不是OneSignal的默认响铃图标。
#1
11
Looks like what you’d want isn’t possible with that library.
看起来你想要的东西是不可能的那个库。
On iOS
According to the documentation, the notification icon is automatically set to your app’s small icon (Icon-Small.png
):
根据文档,通知图标会自动设置为应用程序的小图标(Icon-Small.png):
In the banner, iOS displays your notification message and the small version of your app icon.
在横幅中,iOS会显示您的通知消息和应用程序图标的小版本。
Unless you change the small version of the app icon, this is not possible at all on iOS.
除非您更改应用程序图标的小版本,否则在iOS上根本无法实现。
On Android
Using the Android APIs this would be simple with Notification.Builder#setSmallIcon(int)
, but the library you’re using hard-codes that icon to the application’s icon.
使用Android API,这对于Notification.Builder#setSmallIcon(int)来说很简单,但是您正在使用的库将该图标硬编码到应用程序的图标。
You’d need to modify the library to accept other icons. It’s likely that this has not been implemented so that the behaviour would be consistent on all platforms.
您需要修改库以接受其他图标。它可能尚未实现,因此行为在所有平台上都是一致的。
UPDATE
UPDATE
Now with this plugin is completely possible.
现在有了这个插件是完全可能的。
#2
4
private void shownotification(String message, Context context) {
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mNotifyBuilder = new NotificationCompat.Builder(
context).setContentTitle("Jaswinderwadali").setContentText(message)
.setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true)
.setSmallIcon(R.drawable.Mypic);
Notification notification = mNotifyBuilder.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(0, notification);
}
Its For android change icon of notification in status bar .setSmallIcon(R.drawable.Mypic)
它的状态栏中的通知更改通知图标.setSmallIcon(R.drawable.Mypic)
#3
0
You need to create a icon named ic_stat_onesignal_default in your drawables directory which will be shown instead of OneSignal's default bell icon.
您需要在drawables目录中创建一个名为ic_stat_onesignal_default的图标,该图标将显示而不是OneSignal的默认响铃图标。