Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sound is not played in push notifications

Tags:

ios

ios7

I am using iOS 7 and my push notifications do not play sounds.

Strangely, I found there is no setting for sound in the Preference > Notification Center for my app. Following is the screenshots of Notification center for my app: enter image description here

And following is that for Skype:

enter image description here

You see, there is no 'Sounds' section for my app.

Could anyone help?


Update:

Now I have registered sound in my app. The Notification Center now looks like: enter image description here

and my notification has sounds. Looks good.

But after I enter the setting of my app, there is initially a 'Sounds' section like Skype, but then the Preference app crashed, and after that, there is no more 'Sounds', just like below: enter image description here

Might it be a bug of Apple?

like image 568
HanXu Avatar asked Jan 28 '26 23:01

HanXu


1 Answers

You're not registered for audio push notifications in your app. Just register for it like this in your App Delegate:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //Whatever you have already in your app delegate...

    // Let device know you're going to be sending one of these types of notifications.
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
        (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

    return YES;
}

The 5 types are:

  1. UIRemoteNotificationTypeBadge
  2. UIRemoteNotificationTypeSound
  3. UIRemoteNotificationTypeAlert
  4. UIRemoteNotificationTypeNone
  5. UIRemoteNotificationTypeNewsstandContentAvailability

Here's the documentation: Registering for Remote Notifications

Hope that helps!

like image 154
sridvijay Avatar answered Jan 30 '26 17:01

sridvijay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!