문제

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];
도움이 되었습니까?

해결책

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?

다른 팁

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. :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top