ios - Setting dynamic button titles in iOS8 local notifications -


i have followed examples here , elsewhere setting 1 or 2 button local notifications , have working fine. examples fine if need canned buttons accept/delete/etc, need need set button titles happening in app @ time. game , needs generic engine. need able set button titles match needs @ time. have 2 categories can 1 button or 2 button notification. seems actions , categories need setup when register notification. title on uimutableusernotificationcategory shown "read only". know can done. example game "spy watch" can played 90% of time notifications.

is there anyway set titles when scheduling notification? have passed dictionaries data need process response.

this appdelegate side

nsstring * const notificationcategoryident1  = @"1button"; nsstring * const notificationcategoryident2  = @"2button"; nsstring * const notificationactiononeident = @"action_one"; nsstring * const notificationactiontwoident = @"action_two";  - (void)registerfornotification {  uimutableusernotificationaction *action1; action1 = [[uimutableusernotificationaction alloc] init]; [action1 setactivationmode:uiusernotificationactivationmodebackground]; [action1 settitle:@"button 1"]; [action1 setidentifier:notificationactiononeident]; [action1 setdestructive:no]; [action1 setauthenticationrequired:no];  uimutableusernotificationaction *action2; action2 = [[uimutableusernotificationaction alloc] init]; [action2 setactivationmode:uiusernotificationactivationmodebackground]; [action2 settitle:@"button 2"]; [action2 setidentifier:notificationactiontwoident]; [action2 setdestructive:no]; [action2 setauthenticationrequired:no];  uimutableusernotificationcategory *actioncategory2; actioncategory2 = [[uimutableusernotificationcategory alloc] init]; [actioncategory2 setidentifier:notificationcategoryident2]; [actioncategory2 setactions:@[action1, action2]                 forcontext:uiusernotificationactioncontextdefault];  uimutableusernotificationcategory *actioncategory1; actioncategory1 = [[uimutableusernotificationcategory alloc] init]; [actioncategory1 setidentifier:notificationcategoryident1]; [actioncategory1 setactions:@[action1]                 forcontext:uiusernotificationactioncontextdefault];  nsset *categories = [nsset setwithobjects:actioncategory1, actioncategory2, nil]; uiusernotificationtype types = (uiusernotificationtypealert|                                 uiusernotificationtypesound|                                 uiusernotificationtypebadge);  uiusernotificationsettings *settings; settings = [uiusernotificationsettings settingsfortypes:types                                              categories:categories];  [[uiapplication sharedapplication] registerusernotificationsettings:settings]; } 

here how set notification in view controller

uilocalnotification* localnotification2 = [[uilocalnotification alloc] init]; localnotification2.firedate = [nsdate datewithtimeintervalsincenow:30]; localnotification2.alertbody = @"alert body2"; localnotification2.timezone = [nstimezone defaulttimezone]; localnotification2.soundname = uilocalnotificationdefaultsoundname; localnotification2.category = @"2button"; //localnotification.userinfo = infodict; [[uiapplication sharedapplication] schedulelocalnotification:localnotification2]; 


Comments