Hausala
Hausala

Reputation: 11

Stop to play Push Notification sound as I receive PushNotification Payload, (or When DidreceiveNotification method of App Delegate is Called)

I am new in iOS development, and I am working on an iOS app in which some options are available for user to get pushNotification, such as users can select "Do not Disturb", "AnyTime" "time b/w"...something like this. So If user choose "Do not Disturb" then I do not have to play sound and alert. So please give me solution of that.Is this possible or not in iOS App development. Please tell me.

Thanks in advance...

Upvotes: 1

Views: 39

Answers (1)

Anuraj
Anuraj

Reputation: 1240

If you don't require sound for the push notification, Don't give sound object in push payload.

If the user has chosen "Do not Disturb", indicate the server sending push notification to remove sound from the payload.

{
    "aps":{"alert":"Hello","category":"your_category_key"}
}

Other wise include sound.

{
"aps":{"alert":"Hello","sound":"default","category":"your_category_key"}
}

Upvotes: 2

Related Questions