android - Ionic 2 推送插件 : White Square while application is in Background?

标签 android push-notification ionic2 ionic-native

我正在使用 Native Push Plugin对于我正在开发的 Android 应用程序。我已经为我的通知配置了图标和图标颜色,如下所示:

let push = Push.init({
  android: {
    icon: "ic_notif",
    iconColor: "#f94915",
    forceShow: true, ...

如果我通过 Firebase 控制台发送通知(Target = User Segment -> App -> My App)并且我在前台(应用程序可见),我的通知图标是在通知区域中正确显示(图标颜色以及通知抽屉中的颜色)。但是,如果我的应用程序处于后台(或根本没有启动)并且我发送了一条消息,我会收到一个白色方 block (以及通知中的图标颜色抽屉是默认的灰色)。

enter image description here

通过查看源代码,在 GCMIntentService.java 中,我发现方法 onMessageReceived 处理传入的消息。当我在前台时,会触发以下条件:

else if (forceShow && PushPlugin.isInForeground()) {
            Log.d(LOG_TAG, "foreground force");
            extras.putBoolean(FOREGROUND, true);
            extras.putBoolean(COLDSTART, false);

            showNotificationIfPossible(applicationContext, extras);
        }

showNotificationIfPossible 方法负责创建通知(图标、图标颜色、振动、声音等)。这里的问题是,当应用程序在后台时,代码似乎没有被执行(我仍然收到消息),特别是以下代码,这就是我认为的问题所在:

// if we are not in the foreground always send notification if the data has at least a message or title
        else {
            Log.d(LOG_TAG, "background"); //this is not being logged at all
        ...

有人知道这里发生了什么吗?。我想我需要更彻底地检查源代码才能弄明白。

最佳答案

manifiest.json 文件的语法已经更新,并且出现了一些新的东西,请检查下面的示例是否与您的情况相同?

{ “名称”:“ ionic ”, "short_name": " ionic ", "start_url": "index.html", “显示”:“独立”, “图标”:[{ "src": "assets/imgs/logo.png", “尺寸”:“512x512”, “类型”:“图像/PNG” }], "background_color": "#4e8ef7", “主题颜色”:“#4e8ef7” }

您可以从这个文件中做任何您需要的 ui 更改。

关于android - Ionic 2 推送插件 : White Square while application is in Background?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43177919/

相关文章:

ionic2 - ionic 3 侧边菜单在 ios 中不起作用

android - 在撰写android中创建一个圆形按钮并将文本居中

android - 我可以通过 Firebase 禁用推送通知吗?

android - ionic2 - 应用程序错误

cordova - 如何为推送通知设置 Meteor Raix 推送包

android - Flutter 应用程序 - 通知设置选项

html - 如何通过 *ngFor 显示每行 3 个包含图像和增量数字的 <ion-card>

java - 如何在 Android 的 Sqlite 数据库中插入 Enum 数据?

java - 检查对象是否是类列表中任何一个的实例(Android)

ios - 为什么远程通知操作在点击后什么都不做?