Reputation: 1711
I am trying to send FCM notifications directly on the firebase POST url. When i comment out the httpRequest block, the function executes properly. When i uncomment the block, it starts to give me 'invalid function (141)' error on Android app.
The request works and delivers notification via postman.
Here's my cloud function:
const httpResponse = await Parse.Cloud.httpRequest(
url: 'https://fcm.googleapis.com/fcm/send/',
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8',
'Authorization': 'key='+fcm_key
},
body:{
'data':{
'key1': 'value1',
'key2' : 'value2',
'key3': 'value3',
'key4': 'value4',
'key5': 'value5',
'key6': 'value6',
'key7': oneParseObject.get('someColumnName')
},
'registration_ids': new Array(targetFcmToken)
}
);
return 'Done with status code '+httpResponse.status;
Upvotes: 0
Views: 561
Reputation: 1711
Curly braces inside function call were missing. Solution:
const httpResponse = await Parse.Cloud.httpRequest({
url: 'https://fcm.googleapis.com/fcm/send/',
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8',
'Authorization': 'key='+fcm_key
},
body:{
'data':{
'key1': 'value1',
'key2' : 'value2',
'key3': 'value3',
'key4': 'value4',
'key5': 'value5',
'key6': 'value6',
'key7': oneParseObject.get('someColumnName')
},
'registration_ids': new Array(targetFcmToken)
}
});
return 'Done with status code '+httpResponse.status;
Upvotes: 1