You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Method to generate manager with Q promises
function getFcmManager (socket) {
// Define a client service constructor
REST = restler.service(function (socket) {
this.defaults.query = {
// Query parameters here
};
}, {
baseURL: API_PATH
}, {
POSTNOTIFICATION: function(object) {
return this.post('send', {
parser: restler.parsers.json,
data: JSON.stringify(object),
headers: {
'Authorization': 'key=' + API_KEY,
'Content-Type': 'application/json'
}
});
}
});
// Create a client
var rest = new REST(socket);
// FCM manager
var fcm = {
// Post notification
postnotification: function (token) {
return Q.Promise(function (resolve, reject) {
var settings = {
notification: {
title: "Notification title", // Any value
body: "Notification body", // Any value
sound: "default", // If you want notification sound
click_action: "FCM_PLUGIN_ACTIVITY", // Must be present for Android
icon: "fcm_push_icon" // White icon Android resource
},
data:{
param1: "value1", // Any data to be retrieved in the notification callback
param2: "value2"
},
to: token, // Topic or single device
priority: "high", // If not set, notification won't be delivered on completely closed iOS app
restricted_package_name: "" // Optional. Set for application filtering
}
rest.POSTNOTIFICATION(settings).on('complete', function (data) {
console.log('POSTNOTIFICATION', data);
resolve(data);
});
});
}
}
// Return
return fcm;
}
And when I use: fcm.postnotification(token);
It throws: POSTNOTIFICATION [SyntaxError: Failed to parse JSON body: Unexpected token <]
The text was updated successfully, but these errors were encountered:
I have the following piece of code.
And when I use:
fcm.postnotification(token);
It throws:
POSTNOTIFICATION [SyntaxError: Failed to parse JSON body: Unexpected token <]
The text was updated successfully, but these errors were encountered: