0

我正在开发一个应用程序,它使用 iOS 的 UILocalNotifications 来提醒用户他们需要完成操作。我能够创建我的通知并让它们正常触发。但是,当返回应用程序时,我遇到了问题。在第一次触发通知后,我的“应用程序:didRecieveLocalNotification”每次都会运行,并带有第一个通知数据。我可以注销队列中的所有通知,即使队列为空,它仍然会运行通知块。有没有其他人遇到过这个问题或知道如何解决它。我在下面包含了我的 didRecieveLocalNotification 代码。

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
    if (notification) {
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
        [(UITabBarController *)self.window.rootViewController setSelectedIndex:1];
        UINavigationController *nav = [[(UITabBarController *)self.window.rootViewController viewControllers] objectAtIndex:1];
        IMTUpdateRewardViewController *rvc = [storyboard instantiateViewControllerWithIdentifier:@"updateReward"];
        [rvc loadPushNotification:notification];
        [nav pushViewController:rvc animated:NO];
    }
}
4

1 回答 1

1

我遇到了类似的问题。最终罪魁祸首是我的一个错误,它与生成事件提醒有关。如果从后台返回时,有事件已经开始,则生成本地通知,并立即触发。简而言之,当你遇到这样的事情时,在你的 UILocalNotification 生成方法中放置一个小的调试打印输出

于 2013-10-15T08:20:57.747 回答