相关疑难解决方法(0)

以编程方式检测是否启用了iOS密码

而不是直接在我的应用程序中构建密码,并可能要求用户输入密码两次(一次为设备,另一次为我的应用程序); 我以为我可能会聪明地做自己并做一些事情:

if (device has passcode)
    continue into my app
else
    make user enter my app passcode
Run Code Online (Sandbox Code Playgroud)

我不想设置设备密码,我不想强​​制屏幕锁定,不加密任何东西 - 我真正想要的只是一个API来检测设备密码是否生效.就像是:

BOOL notReally = [UIDevice isUserSlightlyMoreSecureBecauseTheySetDeviceLockOn];
Run Code Online (Sandbox Code Playgroud)

或者如果我感到幸运的话:

BOOL isPasscodeEnabled = [UIDevice isPasscodeEnabled];
BOOL isSimplePasscode = [UIDevice isSimplePasscode];
NSInteger minutes = [UIDevice requirePasscodeAfter];
Run Code Online (Sandbox Code Playgroud)

我猜不是基于这个问题(但是已经有几年了)"以编程方式检查设置包中的iPhone密码 "或者这可能就是答案; " 锁定解锁事件iphone "这不是我想要的,但可能"事后".

parental-control ios screen-lock

20
推荐指数
2
解决办法
2万
查看次数

如何检测iPhone上的屏幕锁定/解锁事件?

如何检测iPhone上的屏幕锁定/解锁事件?当用户解锁时,我想从我的iPhone应用程序显示通知提醒.(就像在Android中用于屏幕解锁的广播接收器一样.)

events objective-c unlock ios

15
推荐指数
2
解决办法
3万
查看次数

当iOS设备进入睡眠模式时(当屏幕变黑时),有没有可以检测到该事件?

我想检测两个事件:

  1. 设备被锁定/解锁.
  2. 设备进入睡眠状态,屏幕变黑.

我能够在这里实现的第一个: 有没有办法检查iOS设备是否被锁定/解锁?

现在我想检测第二个事件,有什么方法可以做到吗?

iphone-privateapi ios sleep-mode

13
推荐指数
1
解决办法
1万
查看次数

检测iPhone屏幕是否打开/关闭

有没有办法检测iPhone的屏幕是打开还是关闭?例如,按下手机的屏幕锁定按钮.

我一直在使用(void)applicationWillResignActive:(UIApplication *)application;这些事件做准备(大部分都可以正常工作),但这种方法也会因来电,短信等被触发.

据我所知,没有文件化的方法来确定这一点.

我一直在玩一些解决方法,比如检查屏幕分辨率是否改变,检查方向是否未知,或获得设备的亮度.什么都没有消失.

有没有人有这方面的创意/解决方案?

iphone ios4

11
推荐指数
1
解决办法
5123
查看次数

怎么知道iPhone是否被锁定了?

如果自上次输入密码超过60分钟,或者用户在锁定设备后进入应用程序,我的应用程序需要提示输入密码.

问题是知道设备何时被锁定.如果用户只是在应用程序之间切换,则应用程序不需要提示输入密码,除非自上次密码提示以来已经过了60分钟.如果他们锁定设备,即使它不到60分钟也会再次提示.

applicationWillResignActive这样的通知没有帮助,因为我无法确定应用程序是否因为设备被锁定或用户切换到另一个应用程序而退出活动状态.

在搜索中,我发现帖子说我可以注册以观察UIApplicationProtectedDataWillBecomeUnavailable通知.

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(protectedDataWillBecomeUnavailable:)
           name:UIApplicationProtectedDataWillBecomeUnavailable object:nil];
Run Code Online (Sandbox Code Playgroud)

当我收到此通知时,我设置了一个标志,以便在下次应用程序变为活动状态时提示输入用户密码.但我的测试表明,除非设备设置了密码,否则不会发送此通知.

我已编写测试代码来观察所有通知,但我没有看到任何其他通知表明设备已被锁定.

还有其他方法可以知道设备何时被锁定?

ios

10
推荐指数
1
解决办法
3454
查看次数

从iOS服务检测屏幕开/关

我正在开发一个在后台作为服务运行的网络监视器应用程序.屏幕打开或关闭时是否可以收到通知/电话?

它通过使用以下代码存在于Android中:

private void registerScreenOnOffReceiver()
{
   IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
   filter.addAction(Intent.ACTION_SCREEN_OFF);
   registerReceiver(screenOnOffReceiver, filter);
}
Run Code Online (Sandbox Code Playgroud)

然后在打开/关闭屏幕时调用screenOnOffReceiver.iOS有类似的解决方案吗?

编辑: 到目前为止我发现的最好的是UIApplicationProtectedDataWillBecomeUnavailable(检测iPhone屏幕是否打开/关闭),但它要求用户在设备上启用数据保护(密码保护).

notifications objective-c broadcast jailbreak ios

10
推荐指数
1
解决办法
1万
查看次数

屏幕锁定时启用iPhone加速度计

显然,当屏幕被锁定时,可以让处理器继续处理,如下所示:

在睡眠模式下运行iPhone应用程序

但是,在使用示例代码进行测试后,UIAccelerometer将在设备锁定后立即停止给出值.有没有办法强迫别的?

iphone accelerometer sleep-mode

9
推荐指数
1
解决办法
4634
查看次数

在IOS Swift中检测屏幕解锁事件

如何在iPhone上检测屏幕解锁事件?当用户解锁时,我想在我的应用中执行操作.我搜索谷歌搜索但只找到与目标C相关的代码,将其更改为快速但不起作用.
关注此博客:http: //kidtechblogs.blogspot.com/2014/07/how-to-detect-screen-lockunlock-events.html.
任何帮助如何在swift中检测到它.下面是代码更改为swift ..

func displayStatusChanged(center: CFNotificationCenter, observer: Void, name: CFString, object: Void, userInfo: CFDictionaryRef) {
        // the "com.apple.springboard.lockcomplete" notification will always come after the "com.apple.springboard.lockstate" notification
        let lockState = (name as String)
        print("Darwin notification NAME = \(name)")
        if (lockState == "com.apple.springboard.lockcomplete") {
            print("DEVICE LOCKED")
        }
        else {
            print("LOCK STATUS CHANGED")
        }
    }

func registerforDeviceLockNotification() {
        //Screen lock notifications
        CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),     //center
                nil,     // observer
                displayStatusChanged,     // callback
                CFSTR("com.apple.springboard.lockcomplete"),     // event name
                nil,     // object
                .deliverImmediately)
        CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), …
Run Code Online (Sandbox Code Playgroud)

ios swift

6
推荐指数
2
解决办法
5911
查看次数

iPhone Objective-c检测屏幕锁定

我是使用Objective-c制作iPhone App的新手

我想制作在iPhone屏幕锁定时发送通知的应用程序(按下锁定按钮)如何制作此应用程序?

我正在尝试使用"applicationWillSuspend",但是

/*----------------------------------------*/
- (void)applicationWillSuspend
{
     NSLog(@"WillSuspend");
}
/*----------------------------------------*/
Run Code Online (Sandbox Code Playgroud)

此代码不起作用

我不确定何时调用applicationWillSuspend

拜托,给我一些知识

#import "AppDelegate.h"
#import <notify.h>

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    // iOS8 Notification permit
    if ([UIApplication
         instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
        [[UIApplication sharedApplication]
         registerUserNotificationSettings:[UIUserNotificationSettings
                                           settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeSound
                                           categories:nil]];
    }
    return YES;

    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");
                                 } else {
                                     NSLog(@"lock device");
                                 } …
Run Code Online (Sandbox Code Playgroud)

iphone darwin objective-c ios appdelegate

5
推荐指数
1
解决办法
5657
查看次数

iOS:检查手机是否已锁定

有没有办法检查手机是否锁定?或者我是否收到手机将被锁定的通知?

我的应用程序在后台运行,继续播放音频,所以applicationWillResignActive:不是我真正想要的.

iphone ios

4
推荐指数
2
解决办法
4092
查看次数

如何在iPhone上打开应用程序解锁

我正在尝试创建一个应用程序,每次用户解锁手机时弹出的应用程序就像第二个密码屏幕一样.

用户解锁手机 - >自定义安全应用程序打开 - >自定义安全应用程序关闭并将用户推送到主屏幕

这是否可以捕获手机解锁事件并打开您的应用程序?

谢谢!

iphone xcode ios ios5 ios6

1
推荐指数
1
解决办法
1225
查看次数