No sound when sending push notifications via Parse

for some reason, I canโ€™t get my push notifications in order to make the default sound, or update the icon number when I receive them. Here is my code below. Do you think something is wrong with my code? Or is there a configuration issue that I don't know about? 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!"); } }]; 
+1
source share
3 answers

The same thing happened to me, but I am using the PHP SDK, and the correct way is to submit this in this form. In $ data you need to write what you send to NSDictionary user information.

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

Try the following:

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

From my experience with push notifications, not Parse, not including the audio key / value in the push payload, make push quiet. Try adding a sound with some random value to the dictionary, as shown below, and try it. In addition, there is a more convenient / cleaner way to create an NSDictionary:

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

Source: https://habr.com/ru/post/1205189/


All Articles