we creating app reminds user tasks. user can choose recieve reminder on following bases:
one time, daily, weekly, weekly (on specific week day), every 2 weeks, once month
the reminders should custom popup in app and/or popup if application closed. question is, best way go setting reminders these?
the way i'm thinking doing load phone's sqlite database , checking reminders each time app starts up, , if reminder is, let's daily one, app automatically set next reminder. have no idea how i'm going rest yet.
thanks
i in app using nslocalnotification
uilocalnotification *localnotification = [[uilocalnotification alloc] init]; if (localnotification == nil) return; localnotification.firedate = datetoremindon; localnotification.timezone = [nstimezone defaulttimezone]; // details localnotification.alertbody = @"alert message"; // set button title localnotification.alertaction = @"view"; localnotification.soundname = uilocalnotificationdefaultsoundname; // custom data notification use later nsdictionary *infodict = [nsdictionary dictionarywithobject:reminderid forkey:@"remindid"]; localnotification.userinfo = infodict; // schedule notification [[uiapplication sharedapplication] schedulelocalnotification:localnotification];
this create local notification , can store information might need in user info dictionary , available when received or opened.
use method in appdelegate check if app opened local notification.
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // handle launching notification uilocalnotification *localnotification = [launchoptions objectforkey:uiapplicationlaunchoptionslocalnotificationkey]; if (localnotification) { //handle local notification } }
and use method in app delegate catch when local notification received while app open
- (void)application:(uiapplication *)app didreceivelocalnotification:(uilocalnotification *)notif { // handle notification when app running }
Comments
Post a Comment