如何获取所有UILocalNotification解雇的userinfo?

时间:2015-10-14 05:34:30

标签: ios objective-c

我正在使用本地通知开发iOS闹钟应用。我收到3个通知。当我点击通知时,我可以从该通知中获取数据。如何通过选择其中一个来获取所有3个通知中的数据。以下是我的代码 -

   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
     UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

        NSLog(@"DEMO");
        NSDictionary *dict = [localNotif userInfo];
        //        id obj = [dict objectForKey:@"TESTKEY"];
        NSLog(@"Recieved Notification1234 %@",dict);

        if (localNotif)
        {
            // code here.
            NSLog(@"DEMODATA");
            NSDictionary *dict = [localNotif userInfo];
    //        id obj = [dict objectForKey:@"TESTKEY"];
            NSLog(@"Recieved Notification1234 %@",dict);
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(),
                           ^{
                               NSLog(@"DEMODATAlanunching");
    localNotif.applicationIconBadgeNumber -= 1;
                               UIAlertView *alet=[[UIAlertView alloc] initWithTitle:@"" message:@"app not56 running" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                               [alet show];
     [[NSNotificationCenter defaultCenter] postNotificationName:@"notifMainController" object:localNotif.alertTitle];
                           });
        }
      }



      - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
    {
     NSDictionary *dict = [notification userInfo];
      dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(),
                       ^{
     [[NSNotificationCenter defaultCenter] postNotificationName:@"notifMainController" object:notification.alertTitle];
                       });
    }

0 个答案:

没有答案