Saad
Saad

Reputation: 8947

Schedual Event using UILocalNotification

I want to add a custom action against UILocalNotification. This will look something like this

When I add a local notification schedualed after 3 hrz. App is not active now. And time comes for notification. There will be an alert view or custom view which will ask user to "Proceed", "Remind Later","Cancel". and Different actions against this. Can any one suggest how may I do this.

Upvotes: 0

Views: 76

Answers (2)

Wain
Wain

Reputation: 119031

The best you could do is to show a standard notification to the user (you have no control over this), then, when the app is opened from the notification you can present a custom UI / alert / sheet with options for what the user wants to do.

Bear in mind that the user might not trigger the notification ever, or it could be a long time after the alert was shown.

Consider offering options to the user when they create the user such as reminders if they don't open the app from the notification (by creating multiple / recurring notifications).

Upvotes: 1

Grzegorz Krukowski
Grzegorz Krukowski

Reputation: 19802

Quick code snippet is:

UILocalNotification *notification = [[[UILocalNotification alloc] init] autorelease];
notification.fireDate = [[NSDate date] dateByAddingTimeInterval:60];
notification.alertBody = @"60 seconds from now";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];

More options you can check here:

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction.html

However you cannot modify a view and how notification will be displayed. User controls how they will be displayed or if he wants to disable it.

Upvotes: 0

Related Questions