user3896162
user3896162

Reputation: 59

Xcode - how to disable Remote notification sound by code when the application in background

i know we could disable Notification sound from the "Notification Center" of the device, does anybody know how to disable Remote notification sound using Xcode for notifications received when the application is in background? i've tried to call

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeSound];

but it only remove the option to disable the Sound from "Notification Center" but the notification still play sound

Upvotes: 1

Views: 1543

Answers (1)

Rafał Sroka
Rafał Sroka

Reputation: 40038

  1. Don't include sound in the notification payload.
  2. Don't register for sound notification type. Don't include UIRemoteNotificationTypeSound in:

    [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound]; 
    

Upvotes: 1

Related Questions