2017-09-17 17 views
0

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

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) 

何が問題になりますか?パース開発JSガイドでは、それは言う:

はJavascriptを使用して独自の解析・サーバーを初期化するために、あなたは この

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

を使用して、現在の初期化コードを交換する必要があり、私はback4appのURLを使用しましたiOSアプリで使用しているとても混乱

答えて

0

あなたは以下のこのような構造に従っていることを確認してください:

Parse.initialize("YOUR_APP_ID", "YOUR_JAVASCRIPT_KEY"); 
Parse.serverURL = 'https://parseapi.back4app.com' 
+0

を、私はそれも試してみましたが、それは同じエラー – Minebomber

+0

あなたのコード「Parse.serverUrl」を持っているが、あなたが使用する必要がありました代わりに "Parse.serverURL" –