如何更改离线的android本地通知图标? [英] How to change android local notification icon in ionic?

查看:297
本文介绍了如何更改离线的android本地通知图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用离子建立一个Android应用程式。我使用
$ cordovaLocalNotification 获取本地通知。通知正常工作,但显示默认铃声图标。如何自定义通知图标?

解决方案

  $ scope.scheduleSingleNotification = function {
$ cordovaLocalNotification.schedule({
id:1,
title:'GRM APP Builder',
text:'Quercafé?!?',
badge :1,
icon:'res://coffee.png',
data:{
customProperty:'custom value 1'
}
}) (function(result){
console.log('Notification 1 triggered');
});
};

这个问题花了几个小时后,我发现上面有一条评论真的很对。

如果要更改图标,则需要在[my ionic app folder] \platforms\android\res\drawable中创建一个名为drawable的文件夹。



但诀窍是:在这之后,你需要退出你的livereload模式并再次执行CLI命令ionic run android -l -c -s。这是必要的,因为您需要将新的资产复制到设备。



我只用Android设备测试,如果你可以测试与iOS,请在这里发送评论。

I'm using ionic to build an android app. I'm using $cordovaLocalNotification for local notifications. The notification works but it shows a default bell icon. How can I customize the notification icon?

解决方案

$scope.scheduleSingleNotification = function () {
    $cordovaLocalNotification.schedule({
      id: 1,
      title: 'GRM APP Builder',
      text: 'Quer café?!?',
      badge: 1,
      icon: 'res://coffee.png',
      data: {
        customProperty: 'custom value 1'
      }
    }).then(function (result) {
      console.log('Notification 1 triggered');
    });
  };

After spend hours with this question, I saw that one comment above it's really right.

If you want to change icon, you need to create a folder called "drawable" in "[my ionic app folder]\platforms\android\res\drawable".

But the trick is: after this you need to quit your livereload mode and execute again CLI command "ionic run android -l -c -s". It's necessary because you need to copy new assets to device.

I only tested with Android device, if you can test with iOS please send a review here.

这篇关于如何更改离线的android本地通知图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆