Tutorial details

Local Notifications | App Code for Sale | Preview

Local Notifications | iOS Tutorial

How to add local notifications in your apps

Overview PAGE TOP

Reference: http://www.geekylemon.com/xcode-local-notifications

In this tutorial i will be showing you how to add local notifications in your apps

Features:

  • 1 Sound File

This feature is great for reminding users of your applicationt to return to the app or just some random info you want to give them hours after leaving your application

What To Do! PAGE TOP

By placing the code in the app delegate you can trigger the notification when the application has been opened and closed by the user and work hours after the apps has been used

AppDelegate.m PAGE TOP

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
NSDate *AlarmTime = [[NSDate date] dateByAddingTimeInterval:5];
UIApplication *app = [UIApplication sharedApplication];
UILocalNotification *notifyAlarm = [[UILocalNotification alloc] init];
if (notifyAlarm) {
notifyAlarm.fireDate = AlarmTime;
notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];
notifyAlarm.repeatInterval = 0;
notifyAlarm.soundName = @"reminder.wav";
notifyAlarm.alertBody = @"This Tutorial Is Awesome";
[app scheduleLocalNotification:notifyAlarm];
}
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
UIApplication *app = [UIApplication sharedApplication];
NSArray *oldNotifications = [app scheduledLocalNotifications];
if ([oldNotifications count] > 0) {
[app cancelAllLocalNotifications];
}
}

Reference PAGE TOP

http://www.geekylemon.com/xcode-local-notifications

0 Comments Leave a comment

Please login in order to leave a comment.

Newest first
!

Sign-in to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.