Use iOS UILocalNotification : Tricks & Limitations
When i used UILocalNotification for my ‘Salat Time Offline‘ App, i came to know some interesting limitations about UILocalNotification of iOS introduced from iOS4.
1. The big big limitation is once you schedule UiLocalNotification, you have no way to handle it until user enters your app. Notification only triggers on scheduled time. Its methods can’t be override until it enters the app.
2. When app is switched off, notification will not work
3. When app is in silent mode, you can’t change mode for notification.
4. If you want to use any custom sound file as notification sound , it MUST have duration of less than or equal 30 secs and file format of .aif .caf & .wav. Sound must have to be in main bundle.
5. You can NOT control the notification audio to behave like ‘Increase sound volume from low to high’ or first vibrate then play sound.
6. You can’t schedule dynamic time of notification. If you need it, there our some ways, other developers suggested, but all of those depends on user access of the app. Otherwise those will not work.
The worst and the only solution is to use loop for making different local notifications for each different time alarm.
7. If you create UILocalNotification and uninstalls the app, the notifications will not be deleted !!
Yes, its true. Apple keeps it for 24 hours at-least in case user uninstalls it accidentally.
Best practice for developers in that case is to check first time install and cancel all existing notifications.
***************Piece of Code *************************
if(![[NSUserDefaults standardUserDefaults]boolForKey:@”firstInstall”])
{
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
[[NSUserDefaults standardUserDefaults]setBool:TRUE forKey:@”firstInstall”];