FCM and Swift firebase-sdk version 8.1.0 localization problem - swift

I'm hoping to get some answers here, I have been searching and try almost everything. I even tried to customized my firebase sdk to fit to localization format but it doesnt work. the Push notification on my iphone shows: REMINDER_TO_BRUSH_YOUR_TEETH instead of the localization text i have on my app.
What i tried is:
"notification": {
"title": "CompanyTitle",
"body": "REMINDER_TO_BRUSH_YOUR_TEETH"
"body_loc_key": "REMINDER_TO_BRUSH_YOUR_TEETH" <----- Also tried to add that here
},
"androidConfig": {
"priority": "high",
"ttl": "120s",
"notification": {
"color": "#FFFF00",
"sound": "default"
}
},
"apnsConfig": {
"payload": {
"aps": {
"badge": 17,
"body_loc_key": "REMINDER_TO_BRUSH_YOUR_TEETH" <----- Added that
}
}
},
"token": "cwCqkaNhrE_GsNzrNXxn7V:APA91bHNLg0F7ho9tvOqosWopX9L28FnZxHNoiwxvWJDekVt9hX2RgNa6W_CNUaRe22J2iKcMc5waGHOiC57fLF1H4c-yqOtN7eTujYGWwdMAoGHJEM828-mIa1sMCrSQbZwL7MZOKJI"
}
My piece of code:
private Message.Builder getPreconfiguredMessageBuilder(PushNotificationRequest request) {
AndroidConfig androidConfig = getAndroidConfig(request.getTopic());
ApnsConfig apnsConfig = getApnsConfig(request.getTopic(), request.getBadge(), "REMINDER_TO_BRUSH_YOUR_TEETH");
Notification notification = Notification
.builder()
.setTitle(request.getTitle())
.setBody(request.getMessage())
.build();
return Message.builder()
.setApnsConfig(apnsConfig).setAndroidConfig(androidConfig).setNotification(notification);
}
private ApnsConfig getApnsConfig(String topic, int badge, String locKey) {
return ApnsConfig.builder()
.setAps(Aps.builder().setBadge(badge).setLocKey(locKey).setCategory(topic).setThreadId(topic).build()).build();
}
Thank you for your help in Advance.

This appears to be a syntax issue. Try the following:
"apnsConfig": {
"payload": {
"aps": {
"alert": {
"title": "some title",
"body": "some body"
}
}
}
}

Related

FirebaseMessaging.onBackgroundMessage is not invoked when my app is on background in flutter , its happening only in Ios devices

I Am making an app which has push notification Property app is working when we hit notification on the foreground , but when app is on background my _backgroundHandler() method is not invoking, its happening only In IOS App Only
also struggle this issue.
set payload as below. mutable-content make sense.
apns: {
payload: {
aps: {
'mutable-content': 1,
'content-available': 1
}
}
}
https://github.com/firebase/flutterfire/issues/9381#issuecomment-1229167020
set "mutable-content:1" in payloads, iOS passes the notification to our notification service app extension.
For more information APNs payload, see the following links:
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification
Enable background fetch, background processing and remote notification in Xcode
Edit
Add mutable key to payload
{
"to": "dWdhfjfjdbzbmjJ5....",
"content_available": true,
"mutable_content": true,
"data":
{
"message": "some msg",
"mediaUrl": "image url here"
},
"notification":
{
"body": "notification msg",
"sound": "default"
}
}
EDIT
var payload = {
notification: {
title: `msg title here`,
body: `msg body here`
}`,
},
// Set Android priority to "high"
android: {
priority: "high",
},
// Add APNS (Apple) config
apns: {
payload: {
aps: {
contentAvailable: true,
},
},
headers: {
//"apns-push-type": "background", // This line prevents background notification
"apns-priority": "10",
},
},
token: "dnqTQVso60GfnnuOjHv8_e:APA91bElr-K3xkQMdYHX8VMrasdfasdfkjhasidfgjn"
};
Adding this in my payload solved my issue:
apns: {
payload: {
aps: {
'mutable-content': 1,
'content-available': 1
}
}
}
I have face this issue too.
#goza's answer should been accepted.
This is my sending json.
{
"message":{
"token":"fcm token",
"notification":{
"title":"NotifyTitle",
"body":"NotifyBody"
},
"data":{
"title":"DataTitle",
"body":"DataBody"
},
"apns":{
"payload":{
"aps":{
"content-available":1
}
}
}
}
}

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-"
}

Error trying to use an uploaded image in Linkedin

I'm trying to use the Linkedin API to share a post with an image. I've followed all the steps in the documentation:
https://learn.microsoft.com/es-es/linkedin/consumer/integrations/self-serve/share-on-linkedin?context=linkedin/consumer/context#share-media
First, I register the upload with a POST to https://api.linkedin.com/v2/assets?action=registerUpload and this body:
{
"registerUploadRequest": {
"recipes": [
"urn:li:digitalmediaRecipe:feedshare-image"
],
"owner": "urn:li:person:{{owner_ID}}",
"serviceRelationships": [
{
"relationshipType": "OWNER",
"identifier": "urn:li:userGeneratedContent"
}
]
}
}
I get this response:
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
"uploadUrl": "https://api.linkedin.com/mediaUpload/C4E22AQF6AS1WhrD1lw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQKLg3lSJnswAgAAAXSgLwWp6iAPzjh6E_5XQh8QuP1Aucf_j9bgW3m5vQ&app=74851466&sync=0&v=beta&ut=2h9vtCSeuP0ps1",
"headers": {
"media-type-family": "STILLIMAGE"
}
}
},
"asset": "urn:li:digitalmediaAsset:C4E22AQF6AS1WhrD1lw",
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C4E22AQF6AS1WhrD1lw,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)"
}
}
Then I use the uploadURL to make another post with the image as body, and get a 201 Created response.
I've checked the upload with a GET https://api.linkedin.com/v2/assets/C4E22AQF6AS1WhrD1lw and it has been uploaded correctly:
{
"recipes": [
{
"recipe": "urn:li:digitalmediaRecipe:feedshare-image",
"status": "AVAILABLE"
}
],
"serviceRelationships": [
{
"relationshipType": "OWNER",
"identifier": "urn:li:userGeneratedContent"
}
],
"mediaTypeFamily": "STILLIMAGE",
"created": 1600415270252,
"id": "C4E22AQF6AS1WhrD1lw",
"lastModified": 1600415345915,
"status": "ALLOWED"
}
When I try to share a post referencing this image I get this error:
{"message":"com.linkedin.restli.server.RestLiServiceException [HTTP Status:401]: com.linkedin.content.common.ResponseException: Writers of type person are not authorized to modify UserGeneratedContent.","status":401}
I'm sending a POST to this URL https://api.linkedin.com/v2/ugcPosts with this body:
{
"author": "urn:li:person:{{person_id}}",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Feeling inspired after meeting so many talented individuals at this year's conference. #talentconnect"
},
"shareMediaCategory": "IMAGE",
"media": [
{
"status": "READY",
"description": {
"text": ""
},
"media": "urn:li:digitalmediaAsset:C4E22AQF6AS1WhrD1lw",
"title": {
"text": ""
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
I can share an only text post without trouble, look at my person ID, even like a post, but I'm stuck with this.
Can anyone tell me what am I doing wrong?
Solved. I had an error in the person_id variable, so I was trying to create a post with the wrong id.

google actions: conversation exit using actions sdk does not invoke actions.intent.CANCEL

I am using the actions SDK to build fulfilments. I am using Google Functions for the same. I have the following in the action.json
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "App"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
. . .
]
}
}
}
],
"conversations": {
"App": {
"name": " ... ",
"url": " ...",
"fulfillmentApiVersion": 2
}
},
"locale": "en"
}
In the function code I notice that the custom intent code of actions.intent.CANCEL is not getting called when the user says/ types exit or Goodbye. In the emulator only the <earcon> appears. The JS code is as below:
app.intent('actions.intent.MAIN', (conv) => {
conv.ask('Welcome to ...');
});
app.intent('actions.intent.TEXT', (conv, input) => {
// the main logic of the application is here
});
app.intent('actions.intent.CANCEL', (conv) => {
conv.close(`Okay, let's try this again later.`);
// this code does not get called
});
Is something to be set in action.json for the cancel intent to work
Yes, you need to add something to your action.json for it to send you the CANCEL Intent. In your existing conversations object, add an inDialogIntents attribute with an array of objects giving the name of the CANCEL Intent. Something like this:
"conversations": {
"App": {
"name": "...",
"url": "...",
"fulfillmentApiVersion": 2
"inDialogIntents": [
{
"name": "actions.intent.CANCEL"
}
]
}
}

How can I create a response with rich messages in Dialogflow?

Currently, When an intent is invoked, I am calling a webhook and getting a response from the web service as json structure show below.
{
"speech": "this text is spoken out loud if the platform supports voice interactions",
"displayText": "this text is displayed visually"
}
This is mere text. Alternatively, What response do I have to get to display a list for example.
I tried the rich message section of dialogflow documentation. Those structures didn't work.
Every time DialogFlow matches an intent, you have the possibility to ask DialogFlow to send a request to a specific endpoint. An endpoint which you’ll obviously have to code.
That will allow you to retrieve the matched intent, as well as the matched parameters and contexts, and do some useful work with those.
How to use Message Object in Dialogflow
Kommunicate - Custom webhook Dialogflow integration example
Example of rich message with webhook
{
"fulfillmentMessages": [{
"payload": {
"message": "Object1",
"platform": "", // Example - Facebook, Slack...etc
{
"name": "Save Promo",
"action": {
"type": "quickReply",
"payload": {
"message": "text will be sent as message",
"replyMetadata": {
"key1": "value1"
}
}
}
},
{
"name": "Save Coupon",
"action": {
"type": "quickReply",
"payload": {
"message": "text will be sent as message",
"replyMetadata": {
"key1": "value1"
}
}
}
}
}, {
"payload": {
"message": "Object2",
"platform": "" // Example - Facebook, Slack...etc
}
}]
}
To add an Actions on Google List as part of the reply, you'll need to use the data field in your response to include a richResponse with what should be said, along with a systemIntent that contains the list information.
You can see more examples at their github example repository, but here is the one for showing a list:
{
"data": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Choose an item"
}
}
]
},
"systemIntent": {
"intent": "actions.intent.OPTION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
"listSelect": {
"title": "Hello",
"items": [
{
"optionInfo": {
"key": "first title"
},
"description": "first description",
"image": {
"url": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"accessibilityText": "first alt"
},
"title": "first title"
},
{
"optionInfo": {
"key": "second"
},
"description": "second description",
"image": {
"url": "https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw",
"accessibilityText": "second alt"
},
"title": "second title"
}
]
}
}
}
}
}
}