简体   繁体   中英

iPhone Development - Detect User activity

Can someone please tell me if the following is possible when building an iPhone application.

I simply want small application that does the following:

  1. Detects if the phone is being used so is the screen awake?
  2. Detect for active internet connection.

Are there easy libraries to use to work out this information.

- Detects if the phone is being used so is the screen awake?

It is not possible as it will violate the privacy of the user. Unless you are talking about detect if your app is being used actively on foreground, background, suspended mode and etc, then it is a Yes.

Example of code:-

UIApplicationState state = [[UIApplication sharedApplication] applicationState];  
if (state == UIApplicationStateBackground || state == UIApplicationStateInactive){
    //Do Something
}
else{
    //Do Other thing
}

- Detect for active internet connection.

Yes, it is possible, I am using this https://github.com/tonymillion/Reachability

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM