是否可以在播放器 2 完成时使用 Parse 中的“用户”标识符从设备 (player2) 向另一台设备 (player1) 发送推送通知?就像这样:
玩家 1 开始游戏,并发送他的分数
玩家 2 开始游戏,检查玩家 1 是否完成,如果完成,玩家 2 使用玩家 1 的“用户”标识符向玩家 1 发送通知?
最佳答案
推送通知发送到设备,而不是用户。通过安装表(PFInstallation 对象)跟踪设备。您需要在 Parse 中的安装表中添加一列,以便它跟踪当前与该安装(设备)关联的 PFUser。然后您可以发送一条推送消息,以当前用户为“玩家 1”的安装为目标
示例 -
每当您的用户“登录”到您的游戏时,您需要更新相关安装 -
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation[@"currentPlayer"]=[PFUser currentUser];
[PFInstallation saveInBackground];
然后发送消息
PFQUery *pushQuery=[PFInstallation query];
[pushQuery whereKey:@"currentPlayer" equalTo:self.opponent]; // self.opponent is a PFUser
[PFPush sendPushMessageToQueryInBackground:pushQuery
withMessage:@"It's your turn"];
关于ios - player2 可以使用 Parse 从设备向 player1 发送通知吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27537947/