提交 9d0d8e78 编写于 作者: lizhongyi_'s avatar lizhongyi_

fix: uni-wifiinformation 增加配置文件

上级 4d88aae7
......@@ -8,35 +8,35 @@
<script>
// import { getCurrentWifiInfo, requestLocationPromise } from '@/uni_modules/uni-wifiinformation/utssdk/app-ios/index.uts';
import { getCurrentWifiInfo, requestLocationPromise } from '@/uni_modules/uni-wifiinformation';
export default {
methods:{
getLocationPromise() {
// requestLocationPromise((res):void => {
// console.log(res)
// uni.showToast({
// title: res["message"],
// icon: 'none'
// })
// })
requestLocationPromise(function(res){
console.log(res)
uni.showToast({
title: res["message"],
icon: 'none'
})
})
},
getWifiInfo() {
/* iOS12之后获取wifi信息需要获取系统定位权限,否则获取到的wifi信息为空 */
// requestLocationPromise((res):void => {
// if (res["success"] == true) {
// let wifiInfo = getCurrentWifiInfo()
// if (wifiInfo != null) {
// console.log(wifiInfo)
// uni.showToast({
// title: "当前wifi信息获取成功",
// icon: 'none'
// })
// }
// }
// })
requestLocationPromise(function(res) {
if (res["success"] == true) {
let wifiInfo = getCurrentWifiInfo()
if (wifiInfo != null) {
console.log(wifiInfo)
uni.showToast({
title: "当前wifi信息获取成功",
icon: 'none'
})
}
}
})
},
}
......
<?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>NSLocationWhenInUseUsageDescription</key>
<string>使用期间获取位置权限</string>
</dict>
</plist>
\ No newline at end of file
{
"frameworks": [
"CoreLocation",
"SystemConfiguration"
],
"deploymentTarget": "9.0",
"validArchitectures": [
"arm64", "armv7" ]
}
\ No newline at end of file
import { CLLocationManager, CLAuthorizationStatus, CLLocationManagerDelegate } from 'CoreLocation';
import { CLLocationManager, CLAuthorizationStatus, CLLocationManagerDelegate } from 'CoreLocation'
import { CaptiveNetwork, kCNNetworkInfoKeySSID, kCNNetworkInfoKeyBSSID } from 'SystemConfiguration.CaptiveNetwork';
import { NSArray, NSDictionary } from 'Foundation';
import { CFString } from 'CoreFoundation';
......@@ -19,9 +19,9 @@ class CurrentWifiInfo {
class LocationPromiseService implements CLLocationManagerDelegate {
static promiseCompletionHandler: UTSCallback[] = []
manager?: CLLocationManager = null
manager?: CLLocationManager
constructor(manager: CLLocationManager | null = null) {
constructor(manager?: CLLocationManager) {
this.manager = manager
}
......@@ -47,6 +47,22 @@ class LocationPromiseService implements CLLocationManagerDelegate {
}
}
locationManagerDidChangeAuthorization(manager: CLLocationManager) {
}
locationManagerDidPauseLocationUpdates(manager: CLLocationManager) {
}
locationManagerDidResumeLocationUpdates(manager: CLLocationManager) {
}
locationManagerShouldDisplayHeadingCalibration(manager: CLLocationManager): boolean {
return true
}
requestPromise(completion: UTSCallback) {
let status: CLAuthorizationStatus = CLLocationManager.authorizationStatus()
if (status == CLAuthorizationStatus.notDetermined) {
......@@ -65,7 +81,7 @@ class LocationPromiseService implements CLLocationManagerDelegate {
}
}
const locationPromiseService: LocationPromiseService = new LocationPromiseService()
const locationPromiseService: LocationPromiseService = new LocationPromiseService(null)
......@@ -107,3 +123,4 @@ export function getCurrentWifiInfo (): CurrentWifiInfo | null {
}
return null
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册