如何在iOS上使用Firebase取消Nest ETA?

时间:2016-08-30 08:56:59

标签: ios firebase nest-api

根据nest API文档:

“要取消eta,请发送estimated_arrival_window_begin = 0.检查您是否在此调用中发送整数(0),而不是字符串(”0“),否则调用将失败。”

请参阅https://developers.nest.com/documentation/cloud/eta-reference/

我的代码基于使用Firebase的iOS NestDK示例。

我使用addSubscriptionToURL方法设置如下:

[[FirebaseManager sharedManager] addSubscriptionToURL:[NSString stringWithFormat:@"structures/%@/eta", structureId] withBlock:^(FDataSnapshot *snapshot) {}];

然后我可以成功拨打电话为特定旅行设置一个eta窗口。

然而,我似乎无法取消同一行程的eta。如果我只是指定trip_idestimated_arrival_window_begin属性,则会收到一条错误消息,指出缺少estimated_arrival_window_end字段。

NSMutableDictionary *values = [[NSMutableDictionary alloc] init];
[values setValue:[_tripId UUIDString] forKey:@"trip_id"];
[values setValue:[NSNumber numberWithInt:0] forKey:@"estimated_arrival_window_begin"];
[[FirebaseManager sharedManager] setValues:values forURL:[NSString stringWithFormat:@"structures/%@/eta", structureId]];

我还尝试将estimated_arrival_window_end设置为0但我收到一条错误消息,指出estimated_arrival_window_begin已过去。它似乎将0值解释为时间的开始。好吧,1970年的某个时候!

我在这里做错了什么?!

谢谢!

1 个答案:

答案 0 :(得分:0)

您是否使用使用Nest Home Simulator创建的虚拟设备的Nest帐户?使用虚拟设备与真实设备之间似乎存在错误。请尝试使用具有真实设备的Nest帐户。