解析iOS-在特定时间发送推送通知 [英] Parse iOS - Send push notification at specific time

查看:215
本文介绍了解析iOS-在特定时间发送推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的一部分目前允许用户使用UIDatePicker安排约会.他们按下一个按钮,我的后端处理了日期以存储约会数据,然后我使用以下代码发送推送:

A part of my app currently lets a user schedule appointments using a UIDatePicker. They press a button and my backend does some work with the date to store the appointment data, then I send a push using the following code:

NSString *objectID = [NSString stringWithFormat:@"user_%lu", (unsigned long)self.salespersonObject.userID];

PFPush *push = [PFPush new];
[push setChannel:[NSString stringWithFormat:@"%@",objectID]];

NSString *message1 = [NSString stringWithFormat:@"%@ sent you an appointment request. Visit your profile in the app to confirm", self.currentUser.fullName];

NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
                                  message1, @"alert",
                                  @"Increment", @"badge",@"default",@"sound",
                                  nil];

[push setData: data];
[push sendPushInBackground];

我想知道的是...可以使用Parse iOS SDK设置发送推送的特定时间吗?我也想在此方法中添加一个要在UIDatePicker日期之前1小时发送的推送,该推送内容应为提醒您与x的约会在1小时之内"

What I'm wondering ... is there any way using the Parse iOS SDK to set a specific time for a push to be delivered? I'd like to also in this method add a push to be sent 1 hour prior to the UIDatePicker date that says something like "Reminder your appointment with x is in 1 hour"

提前谢谢!

推荐答案

来自解析文档":

当前不支持发送预定的推送通知 iOS或OS X SDK.看看REST API,JavaScript SDK或 Parse.com推送控制台.

Sending scheduled push notifications is not currently supported by the iOS or OS X SDKs. Take a look at the REST API, JavaScript SDK or the Parse.com push console.

执行IMO的最佳方法是使用Cloud Code,因此您可以创建触发器(afterSave,afterDelete)或从iOS App调用的函数. 由于CloudCode使用Javascript SDK,因此您可以进行以下操作:

The best thing to do IMO is to use Cloud Code, so you can make a trigger (afterSave, afterDelete) or a function that you call from your iOS App. Since CloudCode use the Javascript SDK you can make something like that:

var tomorrowDate = new Date(...);

var query = new Parse.Query(Parse.Installation);
query.equalTo('user_id', 'user_123');

Parse.Push.send({
  where: query,
  data: {
    alert: "You previously created a reminder for the game today" 
  },
  push_time: tomorrowDate
}, {
  success: function() {
    // Push was successful
  },
  error: function(error) {
    // Handle error
  }
});

解析推送通知计划指南

这篇关于解析iOS-在特定时间发送推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆