简体   繁体   中英

Change the icon of the push notification status bar on Android and IOS

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.

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 ):

In the banner, iOS displays your notification message and the small version of your app icon.

Unless you change the small version of the app icon, this is not possible at all on 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.

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

Now with this plugin is completely possible.

    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)

您需要在drawables目录中创建一个名为ic_stat_onesignal_default的图标,该图标将显示而不是OneSignal的默认响铃图标。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM