ios - Multiple UNUserNotifications not firing -


i'm setting multiple unusernotifications below,

- (void)viewdidload {     [super viewdidload];     notifcount = 0;     unusernotificationcenter *center = [unusernotificationcenter currentnotificationcenter];     [center requestauthorizationwithoptions:(unauthorizationoptionbadge | unauthorizationoptionsound | unauthorizationoptionalert)                           completionhandler:^(bool granted, nserror * _nullable error) {                               if (!error) {                                   nslog(@"request succeeded!");                                    [self set10notif];                                }                           }]; } 

in set10notif method, i'm setting multiple(8 testing) notifications time 10 seconds current time.

-(void) set10notif {     notifcount = notifcount+1;     if (system_version_greater_than_or_equal_to(@"10.0") && notifcount < 10)     {         // create actions       nscalendar *calendar = [[nscalendar alloc] initwithcalendaridentifier:nscalendaridentifiergregorian];        [calendar settimezone:[nstimezone localtimezone]];         nsdate *fired = [[nsdate date] datebyaddingtimeinterval:notifcount*10];         nsstring *firestr = [self returnstringfromdate:fired withformat:@"hh/mm/ss dd/mm/yyyy"];         nsdatecomponents *components = [calendar components:nscalendarunityear|nscalendarunitmonth|nscalendarunitday|nscalendarunithour|nscalendarunitminute|nscalendarunitsecond|nscalendarunittimezone fromdate:fired];        unmutablenotificationcontent *objnotificationcontent = [[unmutablenotificationcontent alloc] init];     objnotificationcontent.title = [nsstring localizedusernotificationstringforkey:@"notif!" arguments:nil];     objnotificationcontent.body = [nsstring localizedusernotificationstringforkey:firestr                                                                         arguments:nil];     objnotificationcontent.sound = [unnotificationsound defaultsound];        uncalendarnotificationtrigger *trigger = [uncalendarnotificationtrigger triggerwithdatematchingcomponents:components repeats:no];        unnotificationrequest *request = [unnotificationrequest requestwithidentifier:@"prayer"                                                                           content:objnotificationcontent trigger:trigger];       unusernotificationcenter *usercenter = [unusernotificationcenter currentnotificationcenter];       [usercenter addnotificationrequest:request withcompletionhandler:^(nserror * _nullable error) {         if (!error) {              nslog(@"local notification succeeded");         }         else {             nslog(@"local notification failed");         }         [self set10notif];        }];    #endif     } } 

all local notifications set. 1 notification got fired in device, that's last one.

why can't multiple notifications not firing? did wrong?

give different "requestwithidentifier" , "time delay" each notification , try, may works you.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -