Parse and Heroku Service(2)Mail Templates and Push Notification

本文详细介绍了如何利用Parse和Heroku搭建云应用,包括配置Parse账户、生成API密钥、代码示例、部署流程及调用SDK等关键步骤。同时展示了如何通过Parse发送邮件模板和推送通知,并提供了与Parse相关的命令行工具使用教程。
Parse and Heroku Service(2)Mail Templates and Push Notification

1 Sample Project for Parse Cloud
Parse Account Key
> parse configure accountkey

enter to open the key generate page.

The key is stored in local
> cat ~/.parse/netrc
machine api.parse.com#luohuazju@gmail.com
login default
password xxxxxxxxxxxxx


machine api.parse.com
login default
password xxxxxxxxxxxxx


Link Parse to Heroku
> parse new

existing —> Heroku

Following this document
https://www.parse.com/docs/cloudcode/guide#command-line

It will create an empty parse hello world project for us.

Project Structure
cloud/main.js will the place for cloud codes.

Deploy the cloud and public directories to Parse.com
> parse deploy

Then we can visit the static content here.
https://parsesample-3izxfd-1382.herokuapp.com/

2 Understand Some Codes

Define the function on the cloud
Parse.Cloud.define("hello", function(request, response) {
console.log('Ran cloud function.');
response.success("Hello world! " + (request.params.a + request.params.b));
});

Then we call functions from SDK(Android and iOS), PHP, .NET SDK, Javascript SDK, REST API

A lot of parse.com SDK command to debugging, logging and etc.

Command Line Tool with Heroku
…snip...

3 Read More Code Examples
Email Templates
We should Generate the Template Once, and Render the different users, orders, products times.
Email-templates from https://github.com/niftylettuce/node-email-templates

Cloud Code Request
Parse.Cloud.httpRequest({
method: 'POST',
url: url,
headers: {
'Content-Type': 'application/json',
'x-api-key': AMAZON_GATEWAY_KEY
},
body: JSON.stringify(data)
}).then(function(httpResponse) {
console.log(httpResponse.text);
var result = JSON.parse(httpResponse.text);
if (result['status'] === 'Fail') {
response.error('Request failed with message ' + httpResponse.text);
} else {
response.success(httpResponse.text);
}
}, function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
response.error('Request failed with response code ' + httpResponse.status);
});

Push Message
Parse.Push.send({
channels: ["global"],
data: {
alert: "We found a new job for you!"
}
});

AngularJS 1.4.9
Parse.com JS SDK 1.6.14 (Parse SDK provide SDK to deal with RestClients and a lot of .)

References:
http://sillycat.iteye.com/admin/blogs/2284695

https://www.parse.com/docs/cloudcode/guide#command-line
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值