通过 Parse 发送推送通知时没有声音 [英] No sound when sending push notifications through Parse
本文介绍了通过 Parse 发送推送通知时没有声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无论出于何种原因,我都无法在收到推送通知时发出默认声音或更新徽章编号.下面是我的代码.你认为我的代码有问题吗?还是存在我不知道的配置问题?感谢您的帮助!
for whatever reason I cannot get my push notifications to make the default sound nor update the badge number when I receive them. Here's my code below. Do you think it's something wrong with my code? Or is there a configuration issue that I'm not aware of? Thanks for your help!
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:@"installationUser" containedIn:recipients];
// Send push notification to our query
PFPush *push = [[PFPush alloc] init];
[push setQuery:pushQuery];
NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
message, @"alert",
@"Increment", @"badge",
nil];
[push setData:data];
[push setMessage:[NSString stringWithFormat:@"%@ sent you a photo!", currentUser.username]];
[push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if(!error)
{
NSLog(@"Push notification sent!");
}
}];
推荐答案
我也遇到了同样的情况,但我使用的是 PHP SDK,正确的发送方式是这种形式.在 $data 中,您需要将要发送到 NSDictionary 用户信息的内容写入.
The same was happening to me, but i using the PHP SDK and the correct way to send this is in this form. In the $data you need to write the things you are sending to the NSDictionary userinfo.
$data = array("alert" => "Your message", "badge" => "Increment", "sound" => "default");
$query = ParseInstallation::query();
$query->equalTo("deviceToken", $devicetoken);
ParsePush::send(array(
"where" => $query,
"data" => $data
));
这篇关于通过 Parse 发送推送通知时没有声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文