2

I'm trying to create a UISwitch so user can choose not to get push sounds from inside the app. Is it possible? i've tried to register again without sound -

+ (void)registerToNotificationWithoutSound
{
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
    {
        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    }
    else
    {
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         (UIUserNotificationTypeBadge | UIUserNotificationTypeAlert)];
    }
}

and all is does is disable the users ability to toggle between sound on/off in the iphone settings, but still remembers what the user chosen when the ability to toggle was available.

for example - if the user enables the push sound from the iphone settings and than disable it from the app - he now cant see or use ,the notification sound toggle switch, on the iphone settings but still get sound when receiving push.

thanks

ozd
  • 1,194
  • 10
  • 34
  • That's what Settings.app is for. Imagine if every app had push settings buried within its own settings screen. – Filip Radelic Jan 27 '15 at 11:01
  • notification settings like instagram and facebook have? i can imagine that. – ozd Jan 28 '15 at 06:02
  • shhhhh... we don't want to ruin it to the 500 million people that do like it. anyway this is what the client wants so i need to do it even if its wrong. anyone have an answer? – ozd Feb 03 '15 at 06:33
  • did you figure out a way to do it ? – Neva Nov 17 '15 at 15:05
  • No. I end up with a solution of not SENDING sound to users that doesn't want sound - when invoking the push. (instead of turning off the sound on the device). did you find something? – ozd Nov 24 '15 at 04:48

1 Answers1

7

It's not possible from the client side (iOS app). But, you can remove the sound key in the payload you send from your server side (backend) and the push notification will be silent.

With default sound:

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

With NO sound:

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

6rod9
  • 1,407
  • 12
  • 29