I tried to use \n in my notification's decription but it did not work. what should I use instead.
notification.warning({
message: 'Notification Title',
description:
'This is the content of the notification.\n This is the content of the notification. This is the content of the notification.',
});
It's quite simple. Just use HTML instead of a string.
notification.warning({
message: 'Notification Title',
description: (
<>
This is the content of the notification.<br />
This is the content of the notification. This is the content of the notification.
</>
),
});
Here I made a demo for you.
Related
I'm using the Slack JS SDK's chat.postMessage call to post messages to a Slack channel. I'm forwarded text from another source, and I'd like for that text to be posted verbatim.
But I can't figure out how to get Slack to not interpret *, _, and :.
I've tried passing in mrkdwn: false and parse: 'full', but the messages always seem to come out the same:
const slackClient = new slack.WebClient(slackApiToken);
await slackClient.chat.postMessage({
channel: targetChannel,
text: '*hello* _bye_ :smile:',
});
await slackClient.chat.postMessage({
channel: targetChannel,
text: '*hello* _bye_ :smile:',
parse: 'full',
});
await slackClient.chat.postMessage({
channel: targetChannel,
text: '*hello* _bye_ :smile:',
mkrdwn: false,
});
What I want to see in the Slack app:
*hello* _bye_ :smile:
What I see in the Slack app (for all three chat.postMessage calls):
hello bye 😄
Is there a way to get Slack to not interpret those characters as being special?
Note: I do not want to use a inline code or code block formatting for my message. I just want it to appear in plain text.
Instead of using text parameter, you can use blocks parameter to send your 'plain text'
https://api.slack.com/methods/chat.postMessage#blocks_and_attachments
Example:
await slackClient.chat.postMessage({
channel: targetChannel,
blocks : [{
type: 'section',
text: {
type: 'plain_text',
text: '*This* is a _plain_ text section block. :smile:',
emoji: false
}
}]
});
Looks like this behaviour is a known bug with chat.postMessage. I'd recommend reporting this to feedback#slack.com so that the team can get the bug prioritized.
I'm trying to implement a share button on my website, but I'm having problems with iOS Safari.
var title = "Subject";
var text = "Body";
var url = "https://google.com";
if (navigator.share) {
navigator.share({
title: title,
text: text,
// url: url,
})
.then(() => console.log('Successful share'))
.catch((error) => console.log('Error sharing', error));
}
else{
window.open("mailto:?subject="+encodeURIComponent(title)+"&body="+encodeURIComponent(text)+" "+encodeURIComponent(url), '_blank');
}
It works fine on android, but if I try to send an email from an iPad the subject is not set, and when I send the email the subject becomes the whole message. I suspect the iOS' mail app doesn't receive the data in the same way as the android's gmail app.
Is it a known issue? Is there a workaround?
Thank you!
If you only pass the title navigator.share({ title, }) you'll find that in Apple's Mail, it becomes the body of the email, not the subject. This is contrary to Gmail on Android which uses the title to populate the subject.
Unfortunately, the spec doesn't spell out how the title should be used:
title member The title of the document being shared. May be ignored by the target.
See this article for more nuances and examples of navigator.share in iOS/Mac OS.`
I want to know that how I could build Assistant app based on basic card response linking to NASA's Apod website .It should be like app of fact image of the day.
Good morning, Annalhq! You can use this sample code to get started with a basic card:
if (!conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
conv.ask('Sorry, try this on a screen device or select the ' +
'phone surface in the simulator.');
return;
}
conv.ask('This is a basic card example.');
// Create a basic card
conv.ask(new BasicCard({
text: `This is a basic card. Text in a basic card can include "quotes" and
most other unicode characters including emoji 📱. Basic cards also support
some markdown formatting like *emphasis* or _italics_, **strong** or
__bold__, and ***bold itallic*** or ___strong emphasis___ as well as other
things like line \nbreaks`, // Note the two spaces before '\n' required for
// a line break to be rendered in the card.
subtitle: 'This is a subtitle',
title: 'Title: this is a title',
buttons: new Button({
title: 'This is a button',
url: 'https://assistant.google.com/',
}),
image: new Image({
url: 'https://example.com/image.png',
alt: 'Image alternate text',
}),
display: 'CROPPED',
}));
After your card displays as intended, you can add link out suggestion chips like so:
if (!conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
conv.ask('Sorry, try this on a screen device or select the ' +
'phone surface in the simulator.');
return;
}
conv.ask('These are suggestion chips.');
conv.ask(new Suggestions('Suggestion Chips'));
conv.ask(new Suggestions(['suggestion 1', 'suggestion 2']));
conv.ask(new LinkOutSuggestion({
name: 'Suggestion Link',
url: 'https://assistant.google.com/',
}));
For more information, see the docs:
https://developers.google.com/actions/assistant/responses#basic_card
https://developers.google.com/actions/assistant/responses#suggestion_chips
I'm using Mandrill in Nodejs to send emails to customers, and want to embed an image in my html content attached to the emails. I found some solutions from https://mandrill.zendesk.com/hc/en-us/articles/205582457-Tips-for-using-images-in-Mandrill-emails and decided to use the 4th one, which includes the image inline in the html. The code is as below:
var message = {
html: htmlContent,
subject: "Subject",
...
images = [{
"type": logo.logoType, // which is "image/jpeg"
"name": "logo",
"content": content // the content is valid when using in <img src="data:image/jpeg;base64,content"> directly
}]
};
mandrillClient.messages.send({
message: message
}, function() {
callback(null);
}, function(err) {
callback(err);
})
And the corresponding html code in htmlContent is
<img src="cid:logo">
However, when I checked with the sent email in Mandrill Outbound Activity, "View Content" doesn't show the image correctly. And I looked at the html source, found the image code was still as
<img src="cid:logo">
The plain text didn't get replaced by image data.
How can I get it work properly? Any ideas?
Thanks in advance.
Finally I found it just didn't work when checking the sent email in Mandrill Outbound Activity, but it works fine in your actual email inbox. So it means you will never see the embedded image when do testing, you must send it with production api key and see the results in a real email inbox.
Just FYI. Hope no one will waste any time on this like I did. :)
In Worklight, I have setup Push message for iOS and it works fine. Now for testing purpose, when i am sending push via URL call then the message title comes correctly while the body (payload) part truncates all spaces and shows all words together.
For example:
http://mydomain/myApp/invoke?adapter=aaPushAdapter&procedure=sendPush¶meters=["aahad","General Title 2", "This is General message body 2"]
then , title comes as "General Title 2" and the body part comes as "ThisisGeneralmessagebody2"
My Adapter is declared as:
function sendPush(userId, msgTitle, MsgContents){
var userSubscription = WL.Server.getUserNotificationSubscription('aaPushAdapter.PushEventSource', userId);
if (userSubscription==null){
return { result: "No subscription found for user :: " + userId };
}
WL.Server.notifyAllDevices(userSubscription, {
badge: 1,
sound: "sound.mp3",
activateButtonLabel: "Read",
alert: msgTitle,
payload: {
msg : MsgContents
}
});
return { result: "Notification sent to user :: " + userId };
}
(1) Now how I can preserve this formatting ?
(2) If i have to send URL then how i format and send my message?
Please suggest. Thanks
If %20 does not work, then change all spaces to something like '|', and then unencode this in your app. Or hex encode the whole string so it's one continuous alphanumeric string.
I am not entirely sure how you are using the URL as a means to send the push notification. Do you mean that you actually go to the browser and type this text in the address bar...? You're not supposed to do that (for other than quick tests). There are backend systems that should do that for you.
Anyway, instead of the space between words, use "%20" (w/out the quotation marks) and see if the text is then displayed with spaces in the dialog.