我的应用程序的一部分目前允许用户使用 UIDatePicker 安排约会。他们按下一个按钮,我的后端对日期进行一些处理以存储约会数据,然后我使用以下代码发送推送:
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 小时内”
提前致谢!
最佳答案
来自解析文档:
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 应用程序调用的函数。 由于 CloudCode 使用 Javascript SDK,您可以制作类似的东西:
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 - 解析 iOS - 在特定时间发送推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33811696/