Local Notification Alert Timing - iphone

notificaiton = [[UILocalNotification alloc] init];
notificaiton.fireDate = [NSDate Date];
notificaiton.repeatInterval = 0;
notificaiton.alertBody = #"Alarm";
notificaiton.timeZone = [NSTimeZone defaultTimeZone];
notificaiton.repeatCalendar = [NSCalendar currentCalendar
notificaiton.soundName = #"Alarm.wav"
[[UIApplication sharedApplication] scheduleLocalNotification:notificaiton];
my question is ,
Local Notification alert stay only for few seconds but, is it possible, local notification alert stay for few minutes?
please any body has answer
Thanks, In Advance

No it is not possible to customize the AlertView and its timings. System does it and we don't have any control over it. We can only customize, the alertbody and title of the action button.
Configure the substance of the notification: alert, icon badge number, and sound.
The alert has a property for the message (the alertBody property) and
for the title of the action button or slider (alertAction); both of
these string values can be internationalized for the user’s current
language preference.

if you mean that you need to play notification sound more than 30 sec ??? then it is not possible.
you wrote that Local Notification alert stay only for few seconds but check proper that, this stay as per your sound file length.
and this sound file Must be maximum 30 sec in length.
if you will try to give soundName more than 30 sec. then it will play default sound in notification.
find this line
"Sounds that last longer than 30 seconds are not supported. If you specify a file with a sound that plays over 30 seconds, the default sound is played instead." into apple notification doc.

Related

Set a task for a certain date (iOS app)

Assume that I create a task today, and say that I want to be reminded of it (via a push notification) 10 days from today. Essentially, how do I constantly keep track of what day it is (even when my app isn't actively being used) to finally recognize when it becomes 10 days from today?
You don't do this.
You would schedule the notification for when it is supposed to happen like this...
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [NSDate someDateInTheFuture];
notification.alertBody = #"This is your alert. Do something";
notification.alertAction = #"Alert";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
The notification will then fire when it gets to the date that you set. You don't have to check for it yourself in the app. It just happens.

Display UIAlertView on certain date?

I was wondering how I'd make a UIAlertView display on a certain date, for example, users download the iPhone application and then on the 12th August, a predetermined UIAlertView displays? How could I do this?
Thanks!
You should take a look at the UILocalNotification API. It allows you to create and schedule local notification for your application, which will then be fired on the desired date, using a badge/popover/sound (same settings as for the remote notification API).
For your case you should specifically take a look at the fire date. Sample code would look moreless like this:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertBody = #"Your message here";
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:60*60];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
This will fire a local notification with a "Your message here" text in one hour.

How do I increase the value of applicationIconBadgeNumber during app doesn't run?

How do I increase the applicationIconBadgeNumber by localNotification?
Is it possible to increase the applicationIconBadgeNumber to add [ 1 ] every day by localNotification?
If localNotification doesn't work, how can I change applicationIconBadgeNumber?
It was done by AppName:Count it!
http://itunes.apple.com/app/id443809931?mt=8&ign-mpt=uo%3D4
I asked a question by e-mail to the developer of this application seven months ago.
However, a reply did not come.
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = startDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.repeatInterval = NSDayCalendarUnit;
//I don't know the follow code.I want to increase BadgeNumber during repeatInterval
localNotif.applicationIconBadgeNumber = 1++;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
Local notifications can set the application icon badge number. Obviously, the app has to run to schedule the local notification, but does not need to be running to receive it.
The other option, of course, is to use remote notifications.
You can try to use [UIApplication setKeepAliveTimeout:handler:] to execute a function every X seconds (at least 600). In that function you can increase the number.
The setKeepAliveTimeout require to be a VOIP application, so i'm not sure if apple can approve you anyway.

iPhone: How to get notification center to detect date?

I just wrote an application that depends largely on the ability to notify you when a deadline is approaching. It allows the user to type in a specific date in a UITextField (not using a date picker.) I would rather not go through the hassle of setting up push notifications, iOS 5's notification center will work great. But, I'm unsure of how to get the notification center to detect the entered in dates.
I put this code in my didFinishLaunchingWithOptions: method in my view controller:
UILocalNotification *dateNotif = [[UILocalNotification alloc] init];
localNotif.fireDate=[NSDate date];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = #"Event starts in 20 minutes!";
localNotif.alertAction = #"Show me";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication]presentLocalNotificationNow:dateNotif];
[localNotif release];
But I'm not sure where to go from here at all, I'm still really new to this. Any help would be great, thank you!
You need to create a UILocalNotification, set the fireDate appropriately (and set whatever text you want the user to see), then pass it to UIApplication's scheduleLocalNotification:.
The only things you'll need to deal with beyond that are that if your app is already running when the notification fires then the notification centre won't do anything and your application delegate will get a didReceiveLocalNotification:. If the app isn't running but the user chooses to launch it from the alert then you'll get the local notification handed back to your didFinishLaunchingWithOptions:, allowing you to do something relevant.

How to disable UILocalNotification in iPhone for some time?

I have implemented one reminder iphone applicaion in which I have used local notification for reminder.
In this application their one functionality alert on/off.
So when user set on then user get notification and if its off then user can get notification.
I have done googling but not got sucess.
Can you give me idea for that is it possible or not.
Thanks in advance
Do you have other notifications in your appln.
If you don't have other notification in your app than,
Do one thing,
When you set OFF
- cancel all the notification
- calculate the time difference of current time & your notification firing time. set this in to some variable.
when you set it ON
- reschedule your Notification based on the time which you have saved earlier.
I am considering that you know how UISwitch works, according to switch position
UILocalNotification *localNotif;
//if switch is on
localNotif = [[UILocalNotification alloc] init];
//else if localNotif is not equal to null then
localNotif = nil;
You can start a timer which continuously check switch position and do the above stuff that depends on your coding.