sending push notification to Iphone using FCM - push

I am trying to send push notification to iPhone using FCM but notification is not received on my phone. Is there any issue in request json? please help me.
my request json is
{ "notification":{"aps": {"alert": "Hello","badge": 1,"sound ": "default "},"pushtype": "", "message": "Hello"} ,"to" : "c6IJyzv8LiY:APA91bHE1g-51dWnh_ofus0nUfVGwWQBV8zOp5fn9VcQe5GLL6gqLUCQQv1RUnYvQ0MP7Q5bKwgG1_8Uuudf67HV4hU1N-3U4u4uRVpdXw3QrivE8ONxjAAfcbn5cIUzu3B6FbHR8EkG"}
and my response json is:
{\"multicast_id\":5810493506209108338,\"success\":1,\"failure\":0,\"canonical_ids\":0,\"results\":[{\"message_id\":\"0:1473238399084785%fc69f82ff9fd7ecd\"}]}

I have fixed my problem, correct request json is:
{
"notification ": {
"title": "some title",
"text": "some text"
},
"to": "XjV2kOqh1yXNkJsQop17RlwSwT4jZpuAu-...",
"priority": "high"
}

Related

WSO2 email connector - Issue with sending attachments

I'm working on an email connector that is sending emails successfully.
But I want to send emails with an attachment.
I am using email connector 1.0.2 that support the attachments in its payload.
<email.send configKey="EMAIL_CONNECTION_SMTP">
<from>{json-eval($.from)}</from>
<to>{json-eval($.to)}</to>
<subject>{json-eval($.subject)}</subject>
<content>{$ctx:DecodedBodyTemplate}</content>
<contentType>{$ctx:contentType}</contentType>
<attachments>{json-eval($.attachments)}</attachments>
</email.send>
And the payload has:
"attachments": [
{
"name": "sampleimagefile.txt",
"content": "This is a text file"
}
]
I tried using base64encoded string in content too.
Yet I'm still receiving emails without any attachment.
I also use email connector 1.0.2 and I don't have any issue sending attachments.
Look here for more info.
So, your payload should look like this:
{
"from": "user1#gmail.com",
"to": "user2#gmail.com",
"subject": "This is the subject",
"content": "This is the body",
"contentType": "text/plain",
"attachments": [
{
"name": "sampleimagefile.png",
"content": "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
}
]
}

Flutter fcm push notifications are not able to show icon badges

final data = {
"notification": {
"title": title,
"body": body,
},
"apns": {
"payload": {
"aps": {"badge": 1}
}
},
"to": pid
};
When you receive your payload data you have to update the badge manually when you are using Flutter.
Integrate this library in your code so it can manage it easily
All you have to do is read the badge that is coming inside the FCM body from the following code block and increase the badge depending on that number OR just increase the badge every time you receive a new notification:
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Got a message whilst in the foreground!');
print('Message data: ${message.data}');
});
You have to use this type of Response when you get push notification then badges will show definitely.
code response:-
{
"notification": {
"body": "This is an FCM notification message!",
"title": "FCM Message",
"badge":4
},
"priority": "high",
"data": {
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"id": "1",
"status": "done"
},
"to": "eLk6p-WZ_kC-tZL60lRnp-:APA91bFhdwojQVVa-6wSCR9nTctBRZg0_Hx0ZACouKK2DsSjQzQX6EjrwCtJmWXfJzi2dO3t_ckcZmeWmoWoHMkgwrjMK5IAUJ3h1teBYD2mq-PjFb8-W3_PqMugl90e2fz7_AZYyTV-"
}

How can I send notification from Postman using FCM?

I am using a Post method from the postman to send notifications to my flutter app, If I include the body outside of the notification in this way I can send notifications.
{
"to": "cu6HFvgXSCyKz5kjp..........",
"notification": {
"sound": "default",
"body": "test body",
"title": "test title",
"content_available": true,
"priority": "high"
},
"data": {
"sound": "default",
"body": "test body",
"title": "test title",
"content_available": true,
"priority": "high",
"ride_request_id":"asdfasd"
}
}
I can parse the data to get my value from ride_request_id but the catch is I get double notification, so FCM has suggested including the body inside the notification, Now, neither do I get the notification nor able to parse it. Although in Postman it shows as successful.
{
"to": "cu6HFvgXSCyKz5kjp..........",
"notification": {
"sound": "default",
"body": "test body",
"title": "test title",
"content_available": true,
"priority": "high",
"data": {
"sound": "default",
"body": "test body",
"title": "test title",
"content_available": true,
"priority": "high",
"ride_request_id": "asdfasd"
}
}
}
here is an article about sending a notification using postman:
Test FCM Notification with POSTMAN

Rich Push notification with firebase and sending push notification with FCM on ios devices

I have integrated the normal text based push notification through Firebase Cloud Messaging. The push is send through FCM server and its working fine.
But I am stuck on media based push notification including images and media based notification. I have also tested with postman console with format mentioned below:
Use a service api.
URL: https://fcm.googleapis.com/fcm/send
Method Type: POST
Headers:
Content-Type: application/json
Authorization: key=your api key
Body/Payload:
{ "notification": {
"title": "Your Title",
"text": "Your Text"
},
"data": {
"message": "Offer!",
"mediaUrl": "https://cdn.pixabay.com/photo/2018/01/21/01/46/architecture-3095716_960_720.jpg"
},
"to" : "to_id(firebase refreshedToken)"
}
Through this, I am receiving only normal text based push. What should be the error or correct way to send rich notification in ios 10 or later device??
Thanks in advance.
The correct format is this (tested)
{
"to": "deviceFCMtoken",
"notification":{
"title" : "Check this Title",
"subtitle" : "Subtitle",
"body" : "Body",
"mutable_content" : true,
"category" : "categoryID"
},
"data":{
"image-url": "www.something.com"
}
}
You should provide the mutable-content and content-available in your FCM payload. Both are boolean and must also be outside the notification parameter
{
"to" : "to_id(firebase refreshedToken),
"mutable_content": true,
"content-available": true,
"data": {
"message": "Offer!",
"mediaUrl": "https://cdn.pixabay.com/photo/2018/01/21/01/46/architecture-3095716_960_720.jpg
},
"notification": {
"title": "my title",
"subtitle": "my subtitle",
"body": "some body"
}
}

Adding Videos to a Magento 2 product using REST

Magento version 2.2.5
Endpoint in question /V1/products/{sku}/media METHOD: POST
I am trying to add a video under a product sku using Magento's provided API endpoint.
{
"entry": {
"media_type": "external-video",
"label": "Video 2",
"position": 2,
"disabled": false,
"types": ["thumbnail"],
"content" : {
"base64_encoded_data": "encoded image data ",
"type": "image/jpeg",
"name": "0.jpg"
},
"extension_attributes": {
"video_content": {
"media_type": "external-video",
"video_provider": "youtube",
"video_url": "some youtube video url",
"video_title": "some title",
"video_description": "",
"video_metadata": ""
}
}
}
The response I get from this call is "invalid option value", I had debugged this in a local environment which leads me to failure during ProductRepository->save() within Magento\Catalog\Model\Product\GalleryGalleryManagement.php on line 70.
Is this an issue with my payload or actual magento bug?
Resolved this issue by adding videos directly using POST /V1/products or PUT /V1/products/{sku} endpoints.
post method example:
{
"product": {
"sku": "some-sku",
..... other product data,
"media_gallery_entries": {
"media_type": "external-video",
"label": "Video 2",
"position": 2,
"disabled": false,
"types": [],
"content" : {
"base64_encoded_data": "encoded image data ",
"type": "image/jpeg",
"name": "0.jpg"
},
"extension_attributes": {
"video_content": {
"media_type": "external-video",
"video_provider": "youtube",
"video_url": "some youtube video url",
"video_title": "some title",
"video_description": "",
"video_metadata": ""
}
}
}
}
I had no luck with Magento's MediaGallery POST endpoint (/V1/products/{sku}/media.
If you want to add a video to the product page then why you did not try using YouTube API?
You just need to follow these steps:
Generate a YouTube API Key by going goodle developer console
Then add Youtube API key to your Magento 2 by going to STORES --> Configuration
Then Add Video URL