【问题标题】:localNotification issues本地通知问题
【发布时间】:2013-03-07 18:04:53
【问题描述】:

一旦进程完成,我会发送本地通知,它运行良好。

这是我的 didReceiveLocalNotification 代码:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{

    CounterViewController *counterVC = [CounterViewController sharedInstance];
    [counterVC notificationArrived];
}

但是当 iPhone 被锁定时,这些行不会被调用……我该怎么做才能让它们在后台运行?

【问题讨论】:

    标签: iphone xcode cocoa uilocalnotification


    【解决方案1】:

    有两种接收本地通知的方法,一种是您已经实现,在应用程序运行时调用,第二种是在应用程序运行后台调用的 didFinishLaunchingWithOptions 中,您添加了一些用于接收本地通知的代码... ..

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // Override point for customization after application launch.
    
    // Add the view controller's view to the window and display.
    
    
    application.applicationIconBadgeNumber = 0;
    
    // Handle launching from a notification
    UILocalNotification *localNotif =
    [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    if (localNotif) {
        NSLog(@"Recieved Notification %@",localNotif);
    }
    
    return YES;
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多