【问题标题】:Send email when a new user is created via iOS app using Parse.com使用 Parse.com 通过 iOS 应用创建新用户时发送电子邮件
【发布时间】:2014-07-14 01:41:21
【问题描述】:

每次在我的 iOS 应用中创建新用户时,我都想发送一封电子邮件。我使用 Parse.com 作为我的后端,并且一直在阅读有关 Cloud Code 的信息。我假设我可以使用它来监视对象的创建,并在数据库中创建特定对象(用户)时启动发送电子邮件的功能。我知道我可以在 CloudCode 中创建一个函数,然后在创建用户后在我的 iOS 应用程序中调用此函数,但我希望能够在不向 App Store 提交更新的情况下执行相同的操作。有没有办法在不提交新二进制文件的情况下完成此操作?

【问题讨论】:

    标签: ios parse-platform


    【解决方案1】:

    您可以添加afterSave Cloud Code 函数,然后您无需更改您的应用程序 - 每次保存用户对象时都会简单地调用新代码。此示例使用 SendGrid,因此您需要一个 SendGrid 帐户

    Parse.Cloud.afterSave(Parse.User, function(request) {
    
        if(!(request.object.existed())){
           var SendGrid = require("sendgrid");  
           SendGrid.initialize("username", "password");
    
           SendGrid.sendEmail({
              to: "email@example.com",
              from: "SendGrid@CloudCode.com",
              subject: "Hello from Cloud Code!",
              text: "Using Parse and SendGrid is great!"
            }, {
              success: function(httpResponse) {
                 console.log(httpResponse);
              },
              error: function(httpResponse) {
                 console.error(httpResponse);
              }
          });
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2019-07-26
      • 2012-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-05
      • 2012-07-14
      • 2018-12-05
      • 1970-01-01
      相关资源
      最近更新 更多