ITeye博客

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

sillycat · 2016-03-22 02:45 · Summary · Mobile Platform · 企业架构 · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。