私はプッシュ通知をしようとしていますが、私は自分の.p12ファイルをparse-server/certsフォルダに設定していました。 index.jsのコードは次のとおりです。パーズサーバ:iOSプッシュ通知
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
}
]
}
});
私はクラウドコードでプッシュ通知を送信したいと思います。だからここに私の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];
}
}];
しかし、それは動作しません:Parse.comオン
[Error]: {"code":1,"message":"Internal server error."} (Code: 1, Version: 1.12.0)
ご存知ですか?
あなたが解析して接続できることを確認します - サーバーを最初に。何かを送ったり、アプリを正しく接続しているかどうかを確認してください。 –
@DanLはいそれはうまく動作します:オブジェクトの追加/削除、他のPFCloudメソッドは正常に動作しますが、通知プッシュのPFCloudは機能しません。 – Viny76
設定で本番と開発用の両方の証明書を設定すると、サーバーが両方向で送信しようとするため、コンソールで毎回少なくとも1つのエラーが発生し、そのうちの1つが常に失敗するため、この瞬間...いくつかのログを提供するクラウドコードが実行されるとき何が起こる –