【问题标题】:Image not displaying using cordova-plugin-local-notifications attachment property图片未使用 cordova-plugin-local-notifications 附件属性显示
【发布时间】:2018-08-29 06:38:30
【问题描述】:

我是Cordova android 开发的新手,希望创建一个非常简单的应用程序来显示最新电影并向用户显示电影的横幅我的代码如下,通知正在显示但它没有显示横幅。我的图像保存在www/img 文件夹中

 cordova.plugins.notification.local.schedule({
                id: 1,
                title: 'My first notification',
                text: 'Thats pretty easy...',
                attachments: ['file://img/logo.png'],
                foreground: true,
                vibrate: true
            });

这是我的文件路径

以下是我想要实现的示例,任何建议都会很棒。

【问题讨论】:

    标签: javascript android cordova android-notifications


    【解决方案1】:

    你的推送通知是什么样子的,看看文件名和它的扩展名,而不是文件名为 Logo.jpg 而你写的是 logo.jpg。 Android 是基于 linux 的,这可能会导致错误。

    我尝试用你的代码构建它,纯推送是没有图像的,点击从上面拉出来后,它会显示如下图像:

    我的代码是 index.js 中的一个简单代码:

    // deviceready Event Handler
    //
    // Bind any cordova events here. Common events are:
    // 'pause', 'resume', etc.
    onDeviceReady: function() {
        cordova.plugins.notification.local.schedule({
            id: 1,
            title: 'My first notification',
            text: 'Thats pretty easy...',
            attachments: ['file://img/logo.png'],
            foreground: true,
            vibrate: true
        });
    
    }
    

    应用程序的推送消息

    看看这个 Gif 来看看图像(我知道,质量很糟糕):

    【讨论】:

    • 你好!我更新了我的问题,显示了文件路径。
    • 我自己测试了代码,推送消息的第一眼是最小化的,如果你看它就会显示图像。
    • 你能更新你的答案并向我展示你想要交叉比较的完整代码
    • 如果您对此有任何疑问,我在这里为您服务 :)
    • 不过,我的附件没有显示可能是因为我的安卓版本这真的让我很困惑,我会在不同的安卓手机上尝试。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-01
    • 2017-08-04
    • 1970-01-01
    • 2014-12-02
    • 1970-01-01
    • 2020-04-19
    • 2023-02-02
    相关资源
    最近更新 更多