0

Parse からプッシュ通知を送信するクラウド コードを実行するための簡単なテスト Web ページをセットアップしようとしています。back4app.com を使用しています。これが私がこれまでに持っているものです:

JS:

Parse.initialize('APP_ID');
Parse.serverUrl = 'https://parseapi.back4app.com/';

function sendPushNotification() {

    let messageBox = document.getElementById('messageBox');
    let messageToPush = messageBox.value;

    Parse.Cloud.run("sendPushNotification", { message: messageToPush }).then(function(result) {
        console.log("result: " + JSON.stringify(result));
    }, function(error) {
        console.log("Error: " + JSON.stringify(error));
    });
}

HTML:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>title</title>
        <script src="https://unpkg.com/parse/dist/parse.min.js"></script>
        <script src="main.js"></script>
    </head>
    <body>
            Message to Push:<br>
            <input id="messageBox" type="text" /><br>
            <input type="button" value="Push" onclick="sendPushNotification()" />
    </body>
</html>

しかし、テキスト ボックスにテキストを追加すると、次のエラーが発生します。

[Error] Failed to load resource: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “api.parse.com” which could put your confidential information at risk. (sendPushNotification, line 0)

何がうまくいかないのですか?Parse Developers JS Guide では、次のように述べています。

独自の Parse-Server を Javascript で初期化するには、現在の初期化コードをこれに置き換える必要があります

Parse.initialize("YOUR_APP_ID"); 
Parse.serverURL = 'http://YOUR_PARSE_SERVER:1337/parse'

iOS アプリで使用する back4app URL を使用しました。混乱している

4

1 に答える 1

0

以下の構造に従っていることを確認してください。

Parse.initialize("YOUR_APP_ID", "YOUR_JAVASCRIPT_KEY");
Parse.serverURL = 'https://parseapi.back4app.com'
于 2017-09-19T11:47:05.653 に答える