No Sound in ios 8 Parse push [duplicate]

2019-06-22 00:18发布

问题:

This question already has an answer here:

  • No sound in Parse push notification for ios8 2 answers

This is weird, after updating my app to support iOS 8 push notifications sent through Parse (using the Parse dashboard) the push notifications wont make any sound.

I found this duplicatie on Stackoverflow but the answer posted wasn't working for me: No sound in Parse push notification for ios8

  • I already checked the notification center and messages and sounds are enabled.
  • Created a new clean build of the app
  • Checked if other push messages make sounds on the app
  • Used the Parse rest api and set the sound to default.

None of the things I tried worked.

Updated my app using the Parse code:

// Register for Push Notitications, if running iOS 8
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                    UIUserNotificationTypeBadge |
                                                    UIUserNotificationTypeSound);
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                             categories:nil];
    [application registerUserNotificationSettings:settings];
    [application registerForRemoteNotifications];

} else {
    // Register for Push Notifications before iOS 8
    [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                     UIRemoteNotificationTypeAlert |
                                                     UIRemoteNotificationTypeSound)];
}

EDIT: I found an excisting bug report on Facebook dev: https://developers.facebook.com/bugs/719233564823090/

回答1:

You can send your push notifications in JSON format rather than the text format in the web console like so:

  {"aps":{"alert":"This is a Test","sound":"default"}}

It's a workaround until Parse fixes this bug.