通过Parse发送推送通知时没有声音

无论出于何种原因,我无法让我的推送通知发出默认声音,也无法在收到徽章时更新徽章号码。 这是我的代码如下。 你认为我的代码有问题吗? 还是有configuration问题,我不知道? 谢谢你的帮助!

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和正确的方式来发送这种forms。 在$ data中,您需要编写要发送给NSDictionary用户信息的内容。

  $data = array("alert" => "Your message", "badge" => "Increment", "sound" => "default"); $query = ParseInstallation::query(); $query->equalTo("deviceToken", $devicetoken); ParsePush::send(array( "where" => $query, "data" => $data )); 

尝试这个:

 PFPush *push = [[PFPush alloc] init]; [push setQuery:pushQuery]; NSDictionary *data = @{ @"badge": @"Increment", @"alert": message, @"sound": @"default" }; [push setData:data]; [push sendPushInBackground]; 

从我的推送通知的经验,而不是与parsing,不包括在推动有效载荷的声音键/值将推动沉默。 尝试添加一些随机值的声音像下面的字典,并尝试一下。 另外,还有更好的方法来创build一个NSDictionary:

 NSDictionary *data = @{ @"badge": @"Increment", @"alert": message, @"sound": @"nothing" };