Skip to content

How Schedule More than 64 local notification in day #1

@Prashant961992

Description

@Prashant961992

I user following Code but Fire only 63 Notification, so How can fire More than 64 Notification in day.

for (int i=0; i<=100; i++) {
MUMutableNotificationContent *mutableContent = [[MUMutableNotificationContent alloc] init];
mutableContent.body = [NSString stringWithFormat:@"body%d",i];
mutableContent.categoryIdentifier = @"category-identifier";
mutableContent.userInfo = @{@"key1": @"value1", @"key2": @"value2"};
mutableContent.sound = [MUNotificationSound defaultSound];
mutableContent.badge = @0;

        NSString *selectedDataandTime = [NSString stringWithFormat:@"30-08-2017 11:18 AM"];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
        [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
        [dateFormatter setDateFormat:@"dd-MM-yyyy hh:mm a"];
        
        NSDate *dateIs = [dateFormatter dateFromString:selectedDataandTime];;
        NSDate *mofifiedDate;
        mofifiedDate=[dateIs dateByAddingTimeInterval:60];
        
        NSCalendar *calendar = [NSCalendar currentCalendar];
        calendar.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
        [calendar setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
        NSDateComponents *components = [calendar components:(NSCalendarUnitYear | NSCalendarUnitMonth |  NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond) fromDate:mofifiedDate];
        NSInteger day = [components day];
        NSInteger month = [components month];
        NSInteger year = [components year];
        NSInteger hour = [components hour];
        NSInteger minute = [components minute];
        //        NSInteger second = [[datewithsecond substringFromIndex: [datewithsecond length] - 2] integerValue];
        // //Deliver the notification at sprcific time everyday
        NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
        dateComponents.day = day;
        dateComponents.month = month;
        dateComponents.year = year;
        dateComponents.hour = hour;
        dateComponents.minute = minute;
        //  dateComponents.second = second;
        NSLog(@"Fire Notification Time : \n %@",dateComponents);
        
    
        MUCalendarNotificationTrigger *trigger = nil;
        if (IS_IOS10_OR_GREATER) {
            trigger = [MUCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents repeats:false];
        }
        else {
            trigger = [MUCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents repeats:false];
        }

        MUNotificationRequest *mnf = [MUNotificationRequest requestWithIdentifier:[[NSUUID UUID] UUIDString] content:mutableContent trigger:trigger];
        
        [[MUUserNotificationCenter currentNotificationCenter] addNotificationRequest:mnf withCompletionHandler:^(NSError * _Nullable error) {
            NSLog(@"addNotificationRequest erro: %@", error);
        }];
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions