【发布时间】:2015-09-18 23:25:31
【问题描述】:
多年来,我一直在使用 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 框中读取它 - 但这只是现在。)
无论如何,有什么想法缺少什么吗?
【问题讨论】:
标签: ios parse-platform push-notification