Я пытаюсь сделать push-уведомление, я установил файлы .p12 в папку parse-server/certs. Вот мой код в моем index.js:
var api = new ParseServer({
databaseURI: process.env.DATABASE_URI || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: 'xx',
masterKey: 'xx',
fileKey: 'xx',
clientKey: 'xx',
serverURL: 'xx',
push: {
ios: [
{
pdx: 'certs/ParsePushDevelopmentCertificate.p12', // Dev PFX or P12
bundleId: 'bundleId',
production: false // Dev
}
]
}
});
Я хотел бы отправить push-уведомление с помощью облачного кода. Итак, вот мой main.js:
Parse.Cloud.define("pushToAll", function (request, response) {
var message = request.params.message;
if (message != null && message !== "") {
message = message.trim();
} else {
response.error("Must provide \"message\" in JSON data");
return;
}
// Can see this at https://www.parse.com/apps/{APP_NAME}/cloud_code/log
var logMessage = "Sending \"{0}\" to all installations".format(message);
console.log(logMessage);
var pushQuery = new Parse.Query(Parse.Installation);
// pushQuery.containedIn("deviceType", ["ios", "android"]); // errors if no iOS certificate
// Send push notification to query
Parse.Push.send({
where: pushQuery, // Set our installation query
data: {
alert: message
}
}, {
success: function () {
// Push was successful
console.log("Message was sent successfully");
response.success('true');
},
error: function (error) {
response.error(error);
}
, useMasterKey: true});
});
И я называю это в своем проекте Xcode:
[PFCloud callFunctionInBackground:@"pushToAll" withParameters:@{@"message" : @"test"} block:^(id object, NSError *error) {
if (!error) {
NSLog(@"YES");
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Try Again !" message:@"Check your network" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}];
Но это не работает [Error]: {"code":1,"message":"Internal server error."} (Code: 1, Version: 1.12.0)
На Parse.com у меня есть поле «Установка» в моей БД:
У вас есть идеи?