Is there any way to check if iOS app is in background?

后端 未结 8 963
滥情空心
滥情空心 2020-12-04 10:38

I want to check if the app is running in the background.

In:

locationManagerDidUpdateLocation {
    if(app is runing in background){
        do this
         


        
8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 10:54

    If you prefer to receive callbacks instead of "ask" about the application state, use these two methods in your AppDelegate:

    - (void)applicationDidBecomeActive:(UIApplication *)application {
        NSLog(@"app is actvie now");
    }
    
    
    - (void)applicationWillResignActive:(UIApplication *)application {
        NSLog(@"app is not actvie now");
    }
    

提交回复
热议问题