ios - How to get notification when app closed? -
i'm using signalr app notification, when app running on background mode, app got notification, when close app can't notification. how can notification when close app ?
thanking answer me in advance :
please find below sample code more information:
- (void)application:(uiapplication *)application didreceivelocalnotification:(uilocalnotification *)notification{ nslog(@"notifi %@ , %@",notification.alertbody,notification.alerttitle); uiapplicationstate state = [application applicationstate]; if (state == uiapplicationstateactive) { uialertcontroller * alert= [uialertcontroller alertcontrollerwithtitle:@"title" message:@"message" preferredstyle:uialertcontrollerstylealert]; uialertaction* yesbutton = [uialertaction actionwithtitle:@"yes, please" style:uialertactionstyledefault handler:^(uialertaction * action) { //handel yes please button action here }]; uialertaction* nobutton = [uialertaction actionwithtitle:@"no, thanks" style:uialertactionstyledefault handler:^(uialertaction * action) { //handel no, button }]; [alert addaction:yesbutton]; [alert addaction:nobutton]; [self.window.rootviewcontroller presentviewcontroller:alert animated:yes completion:nil]; } // request reload table view data // set icon badge number 0 application.applicationiconbadgenumber = 0; }
Comments
Post a Comment