通过网站发送Parse推送通知

时间:2015-09-18 23:25:32

标签: ios parse-platform push-notification

我多年来一直使用Parse将推送通知发送到我的iOS应用程序,并且它一直运行良好。

我现在希望能够做同样的事情 - 但是来自我自己的网页。意思是,我想转到常规网页(我将创建),在文本字段中键入一些文本,按下按钮 - 并将该文本作为推送通知发送到我的iOS应用程序。

我尝试过以下代码 - 到目前为止没有运气:

<html>
<head>
<title>PN TEST</title>

<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.0.min.js"></script>

<script type="text/javascript">

Parse.initialize("xxxxxxxxxxxxx", "xxxxxxxxxxxxxxx");

function makePushNotification() {
    alert ('sending a push!');

    $.ajax({
           type: 'POST',
           headers: { 'X-Parse-Application-Id’ : ‘xxxxxxxxxxxxxxxxxxxxxxxx’ , 'X-Parse-REST-API-Key’ : ‘xxxxxxxxxxxxxxxxxxxxxxxxxxx' },
           url: "https://api.parse.com/1/push", data: '{"channel": "",   "data": {"alert": "Sending a Push Notification from my web page."} }',
            contentType: "application/json"
        }); 
}


</script>

</head>


<body>
    Enter your push notification: <br/>

    <form id="testForm">
        <textarea cols="60" rows="4" id="textAreaText"></textarea>
            <br/>
        <input type="button" value="Send Push Notification" onclick="makePushNotification()" />
            <br/>
    </form>

</body>
</html>

(显然我在这里对推送通知的实际文本进行硬编码而不是真正从textarea框中读取 - 但这只是为了现在。)

无论如何,任何想法都缺少什么?

0 个答案:

没有答案
相关问题