Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my local notifications not having sound on by default in iOS 7?

My app uses geofencing and sends a notification.

By default, sounds are off in Settings - Notifications for the app.

iOS 7 to be precise.

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];
like image 596
Anthony Glyadchenko Avatar asked Oct 10 '13 18:10

Anthony Glyadchenko


1 Answers

If the sound is turned off for your app in the Settings app, then your notification will not play any sound. The user does not allow you to do that.

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

Also if the user set the ringer switch off, then there will be no sound played.

like image 150
Enrico Susatyo Avatar answered Oct 04 '22 15:10

Enrico Susatyo