Ios 当我的应用程序在后台或前台时,我希望通过本地通知获得通知

Ios 当我的应用程序在后台或前台时,我希望通过本地通知获得通知,ios,objective-c,uilocalnotification,Ios,Objective C,Uilocalnotification,我的抽屉菜单上有一个祈祷按钮,一按它就会打开 祈祷器控件,以及在祈祷器控件中 我有5个祈祷计时,我创建了一个UI本地通知方法,并在firedate和sound中启动了这些计时。现在我的问题是 我应该在哪里调用通知方法 “我想要的是,当我的应用程序在后台、前台时,我的本地通知方法应该调用,它应该像服务一样持续运行,这样每当firedate上出现这5个祈祷时间时,它就应该通过UI本地通知横幅(在前台时)提醒我,如果应用程序在后台,它应该通知我” 我是Stackoverflow的初学者,可能我提问的方

我的抽屉菜单上有一个祈祷按钮,一按它就会打开 祈祷器控件,以及在祈祷器控件中 我有5个祈祷计时,我创建了一个UI本地通知方法,并在firedate和sound中启动了这些计时。现在我的问题是

  • 我应该在哪里调用通知方法
  • “我想要的是,当我的应用程序在后台、前台时,我的本地通知方法应该调用,它应该像服务一样持续运行,这样每当firedate上出现这5个祈祷时间时,它就应该通过UI本地通知横幅(在前台时)提醒我,如果应用程序在后台,它应该通知我”

    我是Stackoverflow的初学者,可能我提问的方式不对,但我试着提问

    对不起,我犯了错误

    欢迎回复


    提前感谢。

    使用这些应用程序委派方法

    func applicationDidEnterBackground(application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }
    
    func applicationWillEnterForeground(application: UIApplication) {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }
    

    您可以计划在应用程序位于后台时显示本地通知,并且可以每天或每周在同一时间重复此通知。当应用程序位于前台时,您可以通过
    didReceiveLocalNotification
    application delegate方法处理通知。当应用程序位于后台时,您不需要执行此操作接收对代码的任何通知,除非用户点击该通知banner@Paulw11请看一下这个链接,我上传了一些图片来清楚地解释它。@Paulw11 1st image:-我在ViewController.m2中编写了一个方法。我在ViewController.h3中声明了。在App delega的didReceiveLocalNotification中调用了该方法我走对了吗?