Question

I am developing an iphone app in which i am using UILocalNotifications. When notification occurs, notification banner is displaying but there is no sound. i.e sound in disabled(off) from NotificationCenter. How can i enable(On) notification sound by default without going to settings. Thanks is advance

I am using

UILocalNotification *notification = [[UILocalNotification alloc]init];
[notification setAlertBody:alertBody];
[notification setFireDate:thedate2];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication]scheduleLocalNotification:notification];
Was it helpful?

Solution

It's absolutely not possible to override the global Notification Center settings programatically.

If it were, it would lead to chaos where apps ignore peoples preferences.

Imagine you're in an interview or meeting and some stupid app makes a ridiculous noise - even though you had your notifications on silent, how annoying would that be?

OTHER TIPS

Try this one:

    UILocalNotification *localNotification1 = [[UILocalNotification alloc] init];
    localNotification1.fireDate = thedate2;
    localNotification1.alertBody = alertBody;
    localNotification1.repeatInterval = NSWeekCalendarUnit;
    localNotification1.soundName = @"sound.caf";
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification1];

Use a sound with .caf format. I think this will help you. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top