Iphone 如何同时发出多个通知?

Iphone 如何同时发出多个通知?,iphone,ios,objective-c,xcode,uilocalnotification,Iphone,Ios,Objective C,Xcode,Uilocalnotification,我们是否可以同时触发多个uilocalnotification(例如,对于3个项目),例如:当应用程序位于后台/前台时,通知设置为在下午5:00触发..我应该收到3个通知。应该一个接一个地触发。它仅触发上次设置的通知。我已经添加了代码 - (UILocalNotification *)scheduleNotification :(int)remedyID { [[UIApplication sharedApplication] cancelAllLocalNot

我们是否可以同时触发多个uilocalnotification(例如,对于3个项目),例如:当应用程序位于后台/前台时,通知设置为在下午5:00触发..我应该收到3个通知。应该一个接一个地触发。它仅触发上次设置的通知。我已经添加了代码

    - (UILocalNotification *)scheduleNotification :(int)remedyID
    {

        [[UIApplication sharedApplication] cancelAllLocalNotifications];
        Class cls = NSClassFromString(@"UILocalNotification");
    if (cls != nil)
        {
            NSString *descriptionBody;
            NSInteger frequency;
            UILocalNotification *notif = [[cls alloc] init];

            notif.timeZone = [NSTimeZone defaultTimeZone];
             for (int i=0; i<remedyArray.count; i++)
            {
                int arrayid = [[[remedyArray objectAtIndex:i] objectForKey:@"RemedyID"] intValue];
                if (arrayid == remedyID)
                {
                    descriptionBody=[[remedyArray objectAtIndex:i] objectForKey:@"RemedyTxtDic"];
                    frequency=[[[remedyArray objectAtIndex:i] objectForKey:@"RemedyFrequency"] integerValue];
                   break;
                }
            }
            NSArray *notificationFireDates = [self fireDatesForFrequency:frequency];
            for (NSDate *fireDate in notificationFireDates)      
  {
                Class cls = NSClassFromString(@"UILocalNotification");
                if (cls != nil)
                {

                    UILocalNotification *notif = [[cls alloc] init];                
                    notif.timeZone = [NSTimeZone defaultTimeZone];                
                    notif.repeatInterval = NSDayCalendarUnit;
                    notif.alertBody = [NSString stringWithString:descriptionBody];

                    notif.alertAction = @"Show me";
                    notif.soundName = UILocalNotificationDefaultSoundName;
                    notif.applicationIconBadgeNumber = 1;
                    notif.fireDate = fireDate;                

                    NSDictionary *userDict = [NSDictionary dictionaryWithObject:notif.alertBody
    forKey:@"kRemindMeNotificationDataKey"];

                    notif.userInfo = userDict;                
                    [[UIApplication sharedApplication] scheduleLocalNotification:notif];

                }
            }     

            return notif;
        }
        else
        {
            return nil;
        }

    }
-(UILocalNotification*)scheduleNotification:(int)remedyID
{
[[UIApplication sharedApplication]取消所有本地通知];
类cls=NSClassFromString(@“UILocalNotification”);
如果(cls!=零)
{
NSString*描述体;
NSInteger频率;
UILocalNotification*notif=[[cls alloc]init];
notif.timeZone=[NSTimeZone defaultTimeZone];

对于(inti=0;i,如果您是说这样调用代码:

   [something scheduleNotification:remedyOne];
   [something scheduleNotification:remedyTwo];
   [something scheduleNotification:remedyThree];
然后,重写你的代码。因为你的代码

[[UIApplication sharedApplication] cancelAllLocalNotifications];
在scheduleNotification的第一行中:方法


所以这就是问题所在。

“同时一个接一个”听起来很矛盾……我的意思是,如果要触发3个通知,它应该像队列一样一个接一个地出现在通知栏中