son UILocalNotification personnalisé
-
10-10-2019 - |
Question
J'ai cherché une solution pendant des heures .. avec absolument aucune chance.
Je crée une notification locale:
UILocalNotification *notif = [[cls alloc] init];
[dateComp setDay:j+1];
[dateComp setHour:[[time objectAtIndex:0] integerValue]+offset];
[dateComp setMinute:[[time objectAtIndex:1] integerValue]];
NSLog(@"Year: %i, Month: %i, Day: %i, Time:%i:%i\n",[dateComp year], [dateComp month],
[dateComp day], [dateComp hour], [dateComp minute]);
notif.fireDate = [gregorian dateFromComponents:dateComp];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = [names objectAtIndex: k];
notif.soundName = @"fireburn.caf";
Notez que le nom de son ...
J'ai essayé de mettre 10 sons (aiff, wav, etc ... cafs), mais la notification pops juste avec le son par défaut: /
Je le fichier "fireburn.caf" dans le dossier Ressources.
Pourquoi est-il ne joue pas mon son ?????
Merci.
La solution
RÉPONSE:
Rien de mal avec le code ..
Il est juste que l'iPhone stupide n'a pas annulé les anciennes notifications que je fait avec le son par défaut - _ -;
Quand je nettoyais le projet, supprimé l'application du téléphone et le téléphone, puis redémarrés il a travaillé ..
quelqu'un l'espoir trouve cela utile.
Autres conseils
nettoyez-vous les anciennes notifications avec
UIApplication* app = [UIApplication sharedApplication];
NSArray* oldNotifications = [app scheduledLocalNotifications];
// Clear out the old notification before scheduling a new one.
[app cancelAllLocalNotifications];
Essayez ceci:
notif.soundName = [strSoundFileName copy];