Why do my local notifications have no default sound in iOS 7?

My application uses a geo object and sends a notification.

By default, sounds are disabled in the settings - notifications for the application.

iOS 7 to be exact.

Does anyone know how to fix this?

Here is the code responsible for this:

UILocalNotification *localNotif = [[UILocalNotification alloc] init]; localNotif.fireDate = [NSDate dateWithTimeInterval:5 sinceDate:[NSDate date]]; localNotif.timeZone = [NSTimeZone defaultTimeZone]; localNotif.alertBody = [NSString stringWithFormat:@"You are near %@. Don't forget to check in!",place.name]; localNotif.soundName = UILocalNotificationDefaultSoundName; localNotif.applicationIconBadgeNumber = 0; [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 
+6
source share
2 answers

If the sound is muted for your application in the Settings app, your notification will not play sound. The user does not allow you to do this.

If the sound is not muted in the Settings app, this code that you posted should work.

Also, if the user sets the call to turn off, the sound will not play.

+2
source

Is applicationIconBadgeNumber set to

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions ?

Comment on this code and try again ..... I do not understand, but I have the same problem. After I commented on this line, my application is working correctly.

0
source

Source: https://habr.com/ru/post/955706/


All Articles