Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 我如何跟踪像';力矩';应用程序有什么功能?_Ios_Core Location_Cllocation - Fatal编程技术网

Ios 我如何跟踪像';力矩';应用程序有什么功能?

Ios 我如何跟踪像';力矩';应用程序有什么功能?,ios,core-location,cllocation,Ios,Core Location,Cllocation,如何跟踪iPhone的总使用量,即使我们的应用程序在后台运行(未强制终止)。最近我遇到了一个应用程序,即 即使此应用程序在后台运行,它也会跟踪您的iPhone使用情况。实际上,他们正在使用位置服务来获取执行时间。我的问题是,当他们得到执行时间时,他们如何确定用户的iPhone屏幕是否锁定或解锁 我有代码来检查屏幕是锁定还是解锁 -(void)registerAppforDetectLockState { int notify_token; notify_register_dis

如何跟踪iPhone的总使用量,即使我们的应用程序在后台运行(未强制终止)。最近我遇到了一个应用程序,即 即使此应用程序在后台运行,它也会跟踪您的iPhone使用情况。实际上,他们正在使用位置服务来获取执行时间。我的问题是,当他们得到执行时间时,他们如何确定用户的iPhone屏幕是否锁定或解锁

我有代码来检查屏幕是锁定还是解锁

-(void)registerAppforDetectLockState {

    int notify_token;
    notify_register_dispatch("com.apple.springboard.lockstate", &notify_token,dispatch_get_main_queue(), ^(int token) {

        uint64_t state = UINT64_MAX;
        notify_get_state(token, &state);

        if(state == 0) {
            NSLog(@"unlock device");

            UIAlertView *errorAlert = [[UIAlertView alloc]
                                       initWithTitle:@"unlock device" message:@"test" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [errorAlert show];


        } else {
            NSLog(@"lock device");

            UIAlertView *errorAlert = [[UIAlertView alloc]
                                       initWithTitle:@"lock device" message:@"test" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [errorAlert show];

        }

    });
}

但此代码仅在应用程序在前台运行时有效。

您的代码仅在应用程序在前台运行时有效,因为当应用程序进入后台时,它不会被调用,您必须使用其中一个来唤醒您的应用程序才能执行您的代码

后台模式,链接未打开请尝试此链接。。您可以从项目设置的“功能”选项卡声明后台模式。启用背景模式选项会将UIBackgroundModes键添加到应用程序的Info.plist文件中。选择一个或多个复选框会将相应的背景模式值添加到该键。好的,但我认为这不会有帮助。背景模式是获取应用程序的执行时间,使用位置更新,我得到了应用程序的执行时间,所以不需要更改背景mode@Saurabh是的,您可以这样做,因为这取决于您想要跟踪的用例和您的实现,而MDM只是一个分销渠道