【发布时间】:2014-09-01 12:36:03
【问题描述】:
我使用Parse 发送和接收推送通知。我已经仔细阅读了教程并成功实现了它。 现在我需要在用户选择的特定里程内向用户发送通知。
例如:如果用户选择100,那么通知应该发送给所有安装了我的应用程序并且距离用户(正在广播通知的用户)100英里以内的用户当前位置。
我在 Parse 的网站上找到了相同的代码 sn-p,但如果我使用以下代码中注释的第二个查询,我没有收到任何通知
如果我使用第二个查询,则不会调用方法 didReceiveRemoteNotification
.只有当我使用第一个查询时,我才能成功收到通知。
我对推送通知和解析比较陌生。如果我遗漏了一些愚蠢的东西,请告诉我,以便我可以修复它。我已经围绕这个问题讨论了很长时间,所以请大家帮忙。
PFGeoPoint *myLoc = [PFGeoPoint geoPointWithLatitude:myLatitude longitude:myLongitude];
PFQuery *userQuery = [PFUser query];
[userQuery whereKey:@"location"
nearGeoPoint:myLoc
withinMiles:100];
PFQuery *myQuery = [PFInstallation query];
[myQuery whereKey:@"deviceType" equalTo:@"ios"];
//[myQuery whereKey:@"user" matchesQuery:userQuery];
NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
txt.text, @"alert",
@"1", @"badge",
@"sound.caf", @"sound",
nil];
PFPush *push = [[PFPush alloc] init];
[push setQuery:myQuery];
[push setData:data];
[push sendPushInBackground];
【问题讨论】:
-
'location' 在用户表中是一个地理点正确吗?而且您在安装表中有一个“用户”列?
-
在 Location 列中,您输入的纬度或经度共享该值
-
@Jacob :恐怕我的后端没有表。它只是我看到并按原样实现的查询。
-
@Maul : 很抱歉我从来不知道餐桌上的东西...
-
您使用解析权限而不是注册过程意味着它会在解析中创建用户表。如果您想构建通知过程,则必须进入解析设置并检查启用客户端推送是否已启用,并且您必须上传启用推送的证书
标签: ios ios7 push-notification parse-platform