使用startMonitoringEventWithType:错误:在努力检测wifi SSID更改 [英] using startMonitoringEventWithType: error: in the effort to detect wifi SSID change

查看:653
本文介绍了使用startMonitoringEventWithType:错误:在努力检测wifi SSID更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

苹果似乎在Yosemite和CoreWLAN框架中引入了相当大的变化。我想使用其新的API,引用头文件:

  / *! 
* @method
*
* @param类型
* CWEventType值。
*
* @param错误
*通过引用传递的NSError对象,如果发生错误,返回时将包含错误。
*此参数是可选的。
*
* @result
*指示是否发生错误的BOOL值。 YES表示没有发生错误。
*
* @abstract
*注册特定的Wi-Fi事件通知。
*
* @discussion
*需要< i> com.apple.wifi.events< / i>权利。
* /
- (BOOL)startMonitoringEventWithType:(CWEventType)type error:(out NSError **)error NS_AVAILABLE_MAC(10_10);

并将CWEventType设置为: CWEventTypeSSIDDidChange p>

它说它需要授权,但我不能在我的mac上运行它。错误讯息是:


应用程式意外退出。来自调试器的消息:由于
代码签名错误而终止。


而且我的权利文件)是这样的:

 <?xml version =1.0encoding =UTF-8?& 
<!DOCTYPE plist PUBLIC - // Apple // DTD PLIST 1.0 // ENhttp://www.apple.com/DTDs/PropertyList-1.0.dtd\">
< plist version =1.0>
< dict>
< key> com.apple.wifi.events< / key>
< true />
< / dict>
< / plist>

,我在目标的构建设置中设置代码签名路径。说到这里,如果我排除本地授权文件,应用程序运行,但不按预期的行为。正在研究的API返回一个具有以下描述的错误对象:

 错误Domain = com.apple.wifi.request.error代码= 4操作无法完成(com.apple.wifi.request.error错误4.)


$ b b

这绝对是一个心灵扭曲者,或者至少我希望它是否则我是一个白痴。我有一个特定的App ID在我的应用程序在会员中心,以及一个特定的开发配置文件(虽然我不应该,因为我使用通配符dev配置文件)。



提前感谢。

解决方案

似乎目前(2015年7月31日) c $ c> CWWiFiClient :未正确授予权利。这甚至扩展到非沙箱应用程序。有关详细信息,请参阅Apple开发人员论坛上的此问题



因此,我们可能必须暂时使用已弃用的API。 syammala提供了有关如何使用已过时的API的良好示例


Apple seems to introduce quite a change with Yosemite and CoreWLAN framework. I would like to use its new API, quoting the header file:

/*!
 * @method
 *
 * @param type
 * A CWEventType value.
 *
 * @param error
 * An NSError object passed by reference, which upon return will contain the error if an error occurs.
 * This parameter is optional.
 *
 * @result
 * A BOOL value indicating whether or not an error occurred. YES indicates no error occurred.
 *
 * @abstract 
 * Register for specific Wi-Fi event notifications.
 * 
 * @discussion
 * Requires the <i>com.apple.wifi.events</i> entitlement.
 */
- (BOOL)startMonitoringEventWithType:(CWEventType)type error:(out NSError **)error NS_AVAILABLE_MAC(10_10);

and setting CWEventType to: CWEventTypeSSIDDidChange

It says it requires entitlement, but I am not being able to run it on my mac. The error message is:

The app quit unexpectedly. Message from debugger: Terminated due to code signing error.

And my entitlements file (where I suspect the problem to be) is like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.wifi.events</key>
    <true/>
</dict>
</plist>

and I am setting the code signing path in the build setting for the target. And speaking of which, if I exclude the local entitlements file, the app runs but doesn't behave as expected. The API under study returns an error object with following description:

Error Domain=com.apple.wifi.request.error Code=4 "The operation couldn’t be completed. (com.apple.wifi.request.error error 4.)"

It is definitely a mind twister, or at least I hope it is otherwise I am a total idiot. I have a specific App ID for my app in the member center, as well as a specific development profile (although I shouldn't have to since I am using a wildcard dev profile).

Thanks in advance.

解决方案

It seems that there is currently (31st of July 2015) a bug in CWWiFiClient: entitlements are not properly granted. This even extends to non-sandboxed apps. See this question on the Apple developer forums for more information.

As a result, we may have to resort to the deprecated API for the time being. syammala provides a good example of how to use the deprecated API.

这篇关于使用startMonitoringEventWithType:错误:在努力检测wifi SSID更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆