ios - Storing remote notifications locally -


i'm trying store pushed notifications in core data , display them user. in fact did implement didreceiveremotenotification: , it's working should:

-(void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo {     nslog(@"%@", userinfo);      notification *notify = [nsentitydescription insertnewobjectforentityforname:@"notification" inmanagedobjectcontext:self.managedobjectcontext];     notify.timestamp = [nsdate date];     notify.alert = [[userinfo valueforkeypath:@"aps"] valueforkeypath:@"alert"];      nserror *error;     if (![self.managedobjectcontext save:&error]) {         nslog(@"couldn't save persistant store.");     } } 

but when put code inside didfinishlaunchingwithoptions: in condition statement:

if (launchoptions != nil)     {         nsdictionary *dictionary = [launchoptions objectforkey:uiapplicationlaunchoptionsremotenotificationkey];         if (dictionary != nil)         {             nslog(@"launched push notification: %@", dictionary);              notification *notify = [nsentitydescription insertnewobjectforentityforname:@"notification" inmanagedobjectcontext:self.managedobjectcontext];             notify.timestamp = [nsdate date];             notify.alert = [[dictionary valueforkeypath:@"aps"] valueforkeypath:@"alert"];              nserror *error;             if (![self.managedobjectcontext save:&error]) {                 nslog(@"couldn't save persistant store.");             }         }     } 

i nothing... i've tried creating uialertview , showing proper aler aps when try saving persistant store , diplay in masterviewcontroller nothing happens.

maybe know why? because of sort of lifecycle issues i'm interrupting?

edit

i've tried putting uialertview when saving successful inside didfinishlaunchingwithoptions: , showing guess saved correctly nsfetchedresultcontroller doesn't show notifications... why?

you can save notification when app in running state only.if app in background or closed,push receives can't access , save payload information because none of delegate method execute during time.you can implement of server side , can save pushed notifications.pass notification list using api call.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -