I'm trying to create an app that delivers local notifications as an Alert, not a Banner. But looks like banner is the default and I can't find a way to change it on my code. I can change it on the app notification settings and it works perfectly, but I want that configuration to be default.
This is the code I use to ask the user for permission to send notifications:
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
(By the way, does someone know why I can't set icon badge with this code?)
And this is the code I use to create the Local Notification:
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:segundosTotal];
localNotification.alertBody = timer.nome;
localNotification.soundName = @"Default-28-sec-192kbps.mp3";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
With this code I get the default Banner notification, how can I change that to the Alert one?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…