Cordova-plugin-local-notifications: About the multiple line message

Created on 8 Jan 2016  路  9Comments  路  Source: katzer/cordova-plugin-local-notifications

About the multiple line message
Does this support multiple line of message?
How can i make the multiple line message?

makelocalNoif = function (serverStatus) {
cordova.plugins.notification.local.schedule({
id: 1,
title: "hello",
text: "Hello\nI am Kwan", //this just return "Hello I am Kwan"
icon: 'img/icon.png',
smallIcon: 'res://icon',
sound: null,
data: { test: id }
});
};

enhancement

Most helpful comment

Heads up: Pull Request #906 is set to add multiline support.

All 9 comments

You could try < br > instead of \n or try adding spaces around \n and maybe the link below is of any help. The link goes to a StackOverflow question that's about how you determine the \n character for the current environment.

http://stackoverflow.com/questions/1155678/javascript-string-newline-character.

@spottuit
Thanks you reply
After i try this, it just still cannot make a new line
text: "hi < br > hi \n hi /n hi", // < br > remove the space
Image of Result

Try \n\r or \r\n. I found that on a StackOverflow question and another website. The links are below.

http://stackoverflow.com/questions/13167928/phonegap-line-break-in-alert-on-android
http://www.rgagnon.com/jsdetails/js-0001.html

@spottuit
it still not working :/
btw, thanks you reply

This is not possible without using Big View (expanded) notifications, which this plugin does not yet support AFAIK.

You are talking about Inbox style, check this PR https://github.com/katzer/cordova-plugin-local-notifications/pull/828, he adds the big picture, I checking with the PR owner if he has plans do add inbox style also.
If not, I'll try to implement as soon as possible.

Heads up: Pull Request #906 is set to add multiline support.

HI guys, I'm not a expert on this, and i do not know how create a branch or another git with this projetc, but I made happen!

At file /platforms/android/src/de/appplant/cordova/plugin/notification/Builder.java, replace de code at line #144 for this below, and compile your project. The compatibility with ios do not change anything.

    String text = options.getText();
    String[] texts = text.split("\r\n");
    int qtdText = texts.length;
    if(qtdText > 1){
        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        inboxStyle.setBigContentTitle(options.getTitle());
        for (int i=0; i < qtdText; i++) {
            inboxStyle.addLine(texts[i]);
        }
        builder.setStyle(inboxStyle);
    }

Thats supported now with 0.9-beta. See the README. Thanks

Was this page helpful?
0 / 5 - 0 ratings