How to send a promotional image in the push notification in MFP - push-notification

How to send the promotional image in the push notification as it is like the below image? Do I need to use any html code in payload? If possible kindly share the code snippet.
.

Edit April 2019:
IBM MobileFirst 8.0 supports sending rich push notifications. Update to the latest server and client side fix packs to get the feature. Use the following payload structure when dispatching Push:
Push payload:
{
"message":{
"alert":"Picture Notification for Android devices ",
"url":"http://www.test.com"
},
"target":{
"deviceIds": ["MyDeviceId1", ...],
"platforms": ["A,G", ...],
"tagNames": ["Gold", ...],
"userIds": ["MyUserId", ...]
},
"settings":{
"gcm":{
"style":{
"notification_type":"PICTURE_NOTIFICATION",
"url":"<URL of the image that needs to be displayed>",
"title":"Test"
},
"apns": {
"attachmentUrl" : "http://test.com/test.png",
"badge" : 1,
"category" : 1,
"iosActionKey" : "Ok",
"launchImage" : "test.png",
"locArgs" : [ "["Shelly"]", ... ],
"locKey" : "REQ_FORMAT",
"payload" : {"custom":"data"},
"sound" : "song.mp3",
"subtitle" : "Sub Title",
"title" : "Title",
"titleLocArgs" : [ "["Shelly"]", ... ],
"titleLocKey" : "REQ_FORMAT",
"type" : "SILENT"
}
}
}
}

Related

Sending messages with attachments via Linkedin v2 messages API Fail

Sending any attachments via https://api.linkedin.com/v2/messages results in an empty message on the receiver end. It was working fine during the development and until a few months ago.
I followed the steps as mentioned in the doc here: Messages API.
1. Register upload
POST 'https://api.linkedin.com/v2/assets?action=registerUpload'
Headers: { 'x-li-format: json' ,'X-Restli-Protocol-Version: 2.0.0', 'Authorization': <AUTH TOKEN'>, 'Content-Type: application/json'}
Body:
{
"registerUploadRequest": {
"recipes": [
"urn:li:digitalmediaRecipe:messaging-attachment"
],
"owner": "urn:li:person:tVBKuamGQA",
"serviceRelationships": [
{
"identifier": "urn:li:userGeneratedContent",
"relationshipType": "OWNER"
}
],
"supportedUploadMechanism": [
"SYNCHRONOUS_UPLOAD"
]
}
}
2. Media upload
PUT 'https://api.linkedin.com/mediaUpload/D5606AQEyWs_FuSOhpQ/messaging-attachmentFile/0?ca=vector_messaging&cn=uploads_encrypted&m=AQLwVYaN1VD0FAAAAYZWQ5iaB1P3EvIEqybGym69KocRancNKS12YAhD2A&app=109663&sync=1&v=beta&ut=39P3TAA2AwmGE1'
Headers: Same as above
Body: Image in bytes format
3. Send message with the Attachment URN
POST 'https://api.linkedin.com/v2/messages'
Additionally, I was also able to verify that the status of the upload was successful.
Body:
{
"recipients": [
"urn:li:person:eDPvPwsUVS"
],
"subject": null,
"body": "Body3",
"messageType": "MEMBER_TO_MEMBER",
"attachments": [
"urn:li:digitalmediaAsset:D5606AQEyWs_FuSOhpQ"
]
}
4. Check status of the upload:
Additionally, I was also able to verify that the upload was successful with the status "AVAILABLE"
GET 'https://api.linkedin.com/v2/assets/D5606AQEyWs_FuSOhpQ'
All API calls shared here were successful, making it even more challenging to figure out why the attachments fail. Sending only texts works fine. Any insights/guidance on this issue will be greatly appreciated. It's currently blocking our major release.
I have gone through the assets api, images api documentations from LI, but that doesn't seem to be relevant for sending attachments via private message.
Assets API
Images API

Telegram bot api : issue with GIF upload/download size

Faced with issue, when i am trying to send GIF to my bot, but bot can't access to original size of image. Seems like telegram servers converting it to mp4 (it is a good idea, looks fine) and when i trying to download it - it always looks like a thumbnail with maximum 320px of bigger side.
Looks, like it is an api bug, because for example here :
It describes as 600x473px, but real downloaded mp4 size is :
So, trying to understand - where i'm wrong here, as original gif size require for my project needs... Maybe any workaround exists here?
ps. in case of converting gif to mp4 manually with saving quality and size and then submitting to bot - it works awesome, without any additional compression and etc, but it is unacceptable to ask use do it before using bot.
update :
To reproduce (you need you bot/bot_token and also, be able to receive webhook with json) :
1) sending this gif (https://c2n.me/47Y3H37.gif) to the bot via windows 10 telegram client (v2.1.10). Using "send without compression".
Gif size : 600x473, 3.35MB
2) Bot received and Telegram sending webhook :
{
"update_id": 290360893,
"message": {
"message_id": 21,
"from": {
"id": 101483786,
"is_bot": false,
"first_name": "edited",
"last_name": "edited",
"username": "edited",
"language_code": "en"
},
"chat": {
"id": edited,
"first_name": "edited",
"last_name": "edited",
"username": "edited",
"type": "private"
},
"date": 1591962500,
"animation": {
"file_name": "9Ywn9p.gif.mp4",
"mime_type": "video/mp4",
"duration": 4,
"width": 600,
"height": 473,
"thumb": {
"file_id": "AAMCAgADGQEAAxVe42t2MTQQrFMyXbskwWiNkHjm3wACKwgAAtZ-GEtFrAh9bgzTOnpJm5QuAAMBAAdtAAMIgQACGgQ",
"file_unique_id": "AQADekmblC4AAwiBAAI",
"file_size": 15304,
"width": 320,
"height": 252
},
"file_id": "CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA",
"file_unique_id": "AgADKwgAAtZ-GEs",
"file_size": 68253
},
"document": {
"file_name": "9Ywn9p.gif.mp4",
"mime_type": "video/mp4",
"thumb": {
"file_id": "AAMCAgADGQEAAxVe42t2MTQQrFMyXbskwWiNkHjm3wACKwgAAtZ-GEtFrAh9bgzTOnpJm5QuAAMBAAdtAAMIgQACGgQ",
"file_unique_id": "AQADekmblC4AAwiBAAI",
"file_size": 15304,
"width": 320,
"height": 252
},
"file_id": "CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA",
"file_unique_id": "AgADKwgAAtZ-GEs",
"file_size": 68253
}
}
}
, so you can see there, that size is correct, but weight - no, it is only 68253 bytes = 66.65kb, instead of ~3.35MB (some less, because of converting)
3) Get File_id : CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA from this webhook and trying to use it in api by calling GET "https://api.telegram.org/bot{your_bot_token}/getFile?file_id=CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA" and you will receive :
{
"ok": true,
"result": {
"file_id": "CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA",
"file_unique_id": "AgADKwgAAtZ-GEs",
"file_size": 68253,
"file_path": "animations/file_12.mp4"
}
}
4) Downloading file using this file_path :
GET "https://api.telegram.org/file/bot{your_bot_token}/animations/file_12.mp4" and... getting this mp4 file : https://c2n.me/47Y4oAv.mp4 , with loss quality, weight and size (320x252)
But when you are trying to download it from Telegram client - by clicking "save as" - works fine, mp4 with appropriate size/weight. So seems like an api bug...
update#2 : tried to submit it via tfs telegram support, but also, can't login using my phone number... (https://c2n.me/47Yqswl.png). #pavel_durov, could you please fix it all :))
It seems like the only workaround atm is to convert gif to mp4 (yeah, such a frustrating experience) until the issue is fixed.

Push fir base notification dynamical every device different notification in single API post

I want to push firebase notification dynamically every device different notification in bulk using asp.net
https://android.googleapis.com/gcm/send
[{
"to" : "eqGiWA3POYA:APA91bHXf-Eo9aUI-XtIdHUcGrWaNtfgjPM3luED2LRAafAvemPIBOoUEXFCjnnoAL5xOXescizfpafi-RqwssuyHclShImoYNzYaAjrrw03rLPMLUjN7pAW3RJj1P3f07VJxGBmGm6z",
"collapse_key" : "type_a",
"notification" : {
"body" : "Body of Your Notification",
"title": "Title of Your Notification"
},
"data" : {
"body" : "Body of Your Notification in Data",
"title": "Title of Your Notification in Title",
"key_1" : "Value for key_1",
"key_2" : "Value for key_2"
}
}]
it's working on single message multiple device.
I need different message different device based on device registered id.
According to this documentation it doesn't seem possible to do what you are trying to do. You would need to send the messages in a loop seperatly.

Symfony, Monolog and Slack : how can I format notifications?

On a Symfony 3.4 project, I want to send notifications to a Slack channel via Monolog. I use the SlackHandler and it works well but now I want to find a way to format my notification, using Slack's recommendations. Is it possible ?
For now, each key I send is a new field title and each value associated is a field. Can I directly change the content of "Message" ? Can I also hide the "Level" entry ? I try to use 'fields' from $attachment in SlackRecord.php, but no success so far.
Many, many thanks.
Extracts of what I've done so far. My yaml config:
# monolog.yml
reviews:
type: slack
token: '%token%'
channel: "#mychannel"
bot_name: 'My bot'
icon_emoji: :sports_medal:
level: info
channels: [reviews]
include_extra: true
And in my controller :
// ...
$message = [
'a' => $post->getTitle(),
'b' => $ur->getInterventionRating(),
"fields" => [
"title": "Priority",
"value": "High",
"short": false ], ];
$this->container->get('monolog.logger.myChannel')->info("test", $message);

How do you get a list of all developers and apps for an API in Apigee?

Say you have exposed an API Product in Apigee. You would like to get a list of all the developers and their apps that have registered for the API Product.
There is a call to return those, documented here:
http://apigee.com/docs/api/get-list-keys-apps-developers-or-companies-api-product
But the IDs it returns appear to be useless. If you try developers, for instance:
https://api.enterprise.apigee.com/v1/organizations/YOUR-ORG/apiproducts/YOUR-PRODUCT?query=list&entity=developers
you get back a list of IDs. But to find which developer a given ID relates to is impossible, as the call to get a developer:
http://apigee.com/docs/api/get-developer
only accepts an email address.
How can I get a list of all the developers and their apps registered for a given API product?
The Apps a developer has is nested in each developer:
https://api.enterprise.apigee.com/v1/o/{your org}/developers
will return a list of developers like this:
["email#domain.com", "email2#domain2.com"]
Then you have to loop through each developer to get a list of their apps:
https://api.enterprise.apigee.com/v1/o/{your org}/developers/tesla#weathersample.com
Which gives you a bunch of meta data including apps:
{
"apps" : [ "weather" ],
"companies" : [ ],
"email" : "tesla#weathersample.com",
"developerId" : "Hk5mmLw9kKIM95qF",
"firstName" : "Nikolai",
"lastName" : "Tesla",
"userName" : "Nikolai",
"organizationName" : "jokeindex",
"status" : "active",
"attributes" : [ ],
"createdAt" : 1357858239543,
"createdBy" : "noreply_admin#apigee.com",
"lastModifiedAt" : 1357858239543,
"lastModifiedBy" : "noreply_admin#apigee.com"
}
Finally, if you look at each app you can see the products associated with that developer app:
https://api.enterprise.apigee.com/v1/o/{your org}/developers/tesla#weathersample.com/apps/weather
Gets you this detail:
{
"accessType" : "read",
"appFamily" : "default",
"appId" : "030fdcea-cf97-40b1-96df-12084aea513c",
"attributes" : [ {
"name" : "Developer",
"value" : "tesla#weathersample.com"
}, {
"name" : "DisplayName",
"value" : "Weather"
}, {
"name" : "Notes",
"value" : "not yet"
}, {
"name" : "lastModifier",
"value" : ""
} ],
"callbackUrl" : "http://example.com/callback",
"createdAt" : 1363578857830,
"createdBy" : "adminui#apigee.com",
"credentials" : [ {
"apiProducts" : [ {
"apiproduct" : "weather",
"status" : "approved"
} ],
"attributes" : [ ],
"consumerKey" : "{key}",
"consumerSecret" : "{key}",
"expiresAt" : -1,
"scopes" : [ ],
"status" : "approved"
} ],
"developerId" : "Hk5mmLw9kKIM95qF",
"lastModifiedAt" : 1386042817268,
"lastModifiedBy" : "michael.bissell#apigee.com",
"name" : "weather",
"scopes" : [ ],
"status" : "approved"
}
Take a look at the Org Snapshot Tool on git if you want to interrogate the entire org with one script:
https://github.com/apigee/api-platform-samples/tree/master/tools
This will interrogate every developer and every app and put it into a nice tree structure in your file system for future reference.

Resources