提交 6c36de1e 编写于 作者: lizhongyi_'s avatar lizhongyi_

fix: uni-usercapturescreen iOS 更新

上级 47afda52
......@@ -3,7 +3,7 @@ import { CGRect } from "CoreFoundation";
import { UIApplication, UIView, UITextField, UIScreen, UIDevice } from "UIKit"
import { UTSiOS } from "DCloudUTSFoundation"
import { DispatchQueue } from 'Dispatch';
import { SetUserCaptureScreenOptions, UserCaptureScreenResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, OnUserCaptureScreenResult } from "../interface.uts"
import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, OnUserCaptureScreenResult, SetUserCaptureScreenSuccess, SetUserCaptureScreenFail } from "../interface.uts"
/**
* 定义监听截屏事件工具类
......@@ -26,11 +26,8 @@ class CaptureScreenTool {
// target-action 的方法前需要添加 @objc 前缀
@objc static userDidTakeScreenshot() {
// 回调
const res: OnUserCaptureScreenResult = {
errCode: 0,
errSubject: "uni-usercapturescreen",
errMsg: "onUserCaptureScreen: ok",
path: null
const res: OnUserCaptureScreenCallbackResult = {
}
this.listener?.(res)
}
......@@ -38,14 +35,7 @@ class CaptureScreenTool {
// 移除监听事件
static removeListen(callback : UserCaptureScreenCallback | null) {
this.listener = null
NotificationCenter.default.removeObserver(this)
const res: OnUserCaptureScreenResult = {
errCode: 0,
errSubject: "uni-usercapturescreen",
errMsg: "offUserCaptureScreen: ok",
path: null
}
callback?.(res)
NotificationCenter.default.removeObserver(this)
}
static createSecureView() : UIView | null {
......@@ -81,10 +71,7 @@ class CaptureScreenTool {
rootView!.frame = rect
}
}
let res: UserCaptureScreenResult = {
errCode: 0,
errSubject: "uni-usercapturescreen",
errMsg: "setUserCaptureScreen:ok"
let res: SetUserCaptureScreenSuccess = {
}
option.success?.(res)
option.complete?.(res)
......@@ -106,10 +93,7 @@ class CaptureScreenTool {
}
this.secureView = null
}
let res: UserCaptureScreenResult = {
errCode: 0,
errSubject: "uni-usercapturescreen",
errMsg: "setUserCaptureScreen:ok"
let res: SetUserCaptureScreenSuccess = {
}
option.success?.(res)
option.complete?.(res)
......@@ -136,7 +120,7 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (callback :
*/
export const setUserCaptureScreen : SetUserCaptureScreen = function (options : SetUserCaptureScreenOptions) {
if (UIDevice.current.systemVersion < "13.0") {
let res: UserCaptureScreenResult = {
let res: SetUserCaptureScreenFail = {
errCode: 12001,
errSubject: "uni-usercapturescreen",
errMsg: "setUserCaptureScreen:system not support"
......@@ -145,7 +129,7 @@ export const setUserCaptureScreen : SetUserCaptureScreen = function (options : S
options.complete?.(res);
} else if (UIDevice.current.systemVersion == "15.1") {
let res: UserCaptureScreenResult = {
let res: SetUserCaptureScreenFail = {
errCode: 12010,
errSubject: "uni-usercapturescreen",
errMsg: "setUserCaptureScreen:system internal error"
......
export type OnUserCaptureScreenCallbackResult = {
/**
* 错误码
* 0:成功
* -1:permission denied(仅Android返回)
*/
errCode ?: number,
/**
* 错误的详细信息
*/
errMsg ?: string,
/**
* 截屏文件路径(仅Android返回)
*/
......@@ -19,7 +9,7 @@ export type OnUserCaptureScreenCallbackResult = {
/**
* uni.onUserCaptureScreen/uni.offUserCaptureScreen回调函数定义
*/
export type UserCaptureScreenCallback = (res : OnUserCaptureScreenResult) => void
export type UserCaptureScreenCallback = (res : OnUserCaptureScreenCallbackResult) => void
/**
......
......@@ -3,8 +3,59 @@ import { CaptiveNetwork, kCNNetworkInfoKeySSID, kCNNetworkInfoKeyBSSID } from 'S
import { NSArray, NSDictionary } from 'Foundation';
import { CFString } from 'CoreFoundation';
import { UIDevice } from 'UIKit';
import { UniWifiResult, GetConnectedWifiOptions, WifiConnectOption, WifiOption, UniWifiInfo, UniWifiCallback, StartWifi, StopWifi, GetWifiList, GetConnectedWifi, OnGetWifiList, OnWifiConnectedWithPartialInfo, OnOffWifiConnectedWithPartialInfo, OnWifiConnected, ConnectWifi, OffGetWifiList, OffWifiConnected, SetWifiList } from "../interface.uts"
/**
* Wifi 函数通用入参封装
*/
type WifiOption = {
success?: (res: UniWifiResult) => void;
fail?: (res: UniWifiResult) => void;
complete?: (res: UniWifiResult) => void;
};
/**
* Wifi 链接参数封装
*/
type WifiConnectOption = {
SSID?: string;
BSSID?: string;
password?: string;
maunal?: boolean;
partialInfo?: boolean; //ios不生效
success?: (res: UniWifiResult) => void;
fail?: (res: UniWifiResult) => void;
complete?: (res: UniWifiResult) => void;
}
/**
* 获取当前链接的wifi信息
*/
type GetConnectedWifiOptions = {
partialInfo?: boolean
success?: (res: UniWifiResult) => void
fail?: (res: UniWifiResult) => void
complete?: (res: UniWifiResult) => void
}
/*
* 对外暴露的wifi信息
*/
type UniWifiInfo = {
SSID: string;
BSSID: string;
secure: boolean;
signalStrength: number;
frequency: number;
}
type UniWifiResult = {
errCode : number,
errSubject : string,
errMsg : string,
wifi: UniWifiInfo | null
}
type UniWifiCallback = () => void
/*
......@@ -153,8 +204,7 @@ class UniWiFiModuleGloabInfo {
/*
* 初始化wifi模块
*/
export const startWifi : StartWifi = function (option : WifiOption) {
export function startWifi(option: WifiOption) {
UniWiFiModuleGloabInfo.alreadyStartWifi = true
let res: UniWifiResult = {
errSubject: "uni-startWifi",
......@@ -169,7 +219,7 @@ export const startWifi : StartWifi = function (option : WifiOption) {
/*
* 停止wifi模块
*/
export const stopWifi : StopWifi = function (option : WifiOption) {
export function stopWifi(option: WifiOption) {
UniWiFiModuleGloabInfo.alreadyStartWifi = false
LocationPromiseService.promiseCompletionHandler = []
let res: UniWifiResult = {
......@@ -185,7 +235,7 @@ export const stopWifi : StopWifi = function (option : WifiOption) {
/*
* 获取wifi列表, 在调用之前需要引导用户跳转到系统设置-WIFI设置页面,系统搜索周边wifi后app才能接收到回调
*/
export const getWifiList : GetWifiList = function (option : WifiOption) {
export function getWifiList(option: WifiOption) {
let res: UniWifiResult = {
errSubject: "uni-getWifiList",
errCode: 12001,
......@@ -199,22 +249,22 @@ export const getWifiList : GetWifiList = function (option : WifiOption) {
/* 获取wifi列表的回调
* note: 请在getWifiList方法的回调里调用该方法
*/
export const onGetWifiList : OnGetWifiList = function (callback: UniWifiCallback) {
export function onGetWifiList(callback: UniWifiCallback) {
}
/*
* 注销获取wifi列表的回调
*/
export const offGetWifiList : OffGetWifiList = function (callback: UniWifiCallback) {
export function offGetWifiList(callback: UniWifiCallback) {
}
/*
* 获取当前连接的wifi信息
*/
export const getConnectedWifi : GetConnectedWifi = function (option: GetConnectedWifiOptions) {
export function getConnectedWifi(option: GetConnectedWifiOptions) {
if (UniWiFiModuleGloabInfo.alreadyStartWifi == false) {
let res: UniWifiResult = {
errSubject: "uni-getConnectedWifi",
......@@ -249,7 +299,7 @@ export const getConnectedWifi : GetConnectedWifi = function (option: GetConnecte
/*
* 连接wifi
*/
export const connectWifi : ConnectWifi = function (option: WifiConnectOption) {
export function connectWifi(option: WifiConnectOption) {
let res: UniWifiResult = {
errSubject: "uni-connectWifi",
errCode: 12001,
......@@ -264,36 +314,35 @@ export const connectWifi : ConnectWifi = function (option: WifiConnectOption) {
/*
* 连上wifi事件的监听函数
*/
export const onWifiConnected : OnWifiConnected = function (callback: UniWifiCallback) {
export function onWifiConnected(callback: UniWifiCallback) {
}
/*
* 连上wifi事件的监听函数, wifiInfo仅包含ssid
*/
export const onWifiConnectedWithPartialInfo : OnWifiConnectedWithPartialInfo = function (callback: UniWifiCallback) {
export function onWifiConnectedWithPartialInfo(callback: UniWifiCallback) {
}
/*
* 移除连接上wifi的事件的监听函数,不传此参数则移除所有监听函数。
*/
export const offWifiConnected : OffWifiConnected = function (callback: UniWifiCallback | null) {
}
export function offWifiConnected(callback: UniWifiCallback | null) {
}
/*
* 移除连接上wifi的事件的监听函数,不传此参数则移除所有监听函数。
*/
export const onOffWifiConnectedWithPartialInfo : OnOffWifiConnectedWithPartialInfo = function (callback: UniWifiCallback | null) {
export function onOffWifiConnectedWithPartialInfo(callback: UniWifiCallback | null) {
}
/*
* 设置 wifiList 中 AP 的相关信息。在 onGetWifiList 回调后调用,iOS特有接口。
*/
export const setWifiList : SetWifiList = function (option: WifiOption) {
export function setWifiList(option: WifiOption) {
let res: UniWifiResult = {
errSubject: "uni-setWifiList",
errCode: 12001,
......
/**
* Wifi 函数通用入参封装
*/
export type WifiOption = {
success?: (res: UniWifiResult) => void;
fail?: (res: UniWifiResult) => void;
complete?: (res: UniWifiResult) => void;
};
/**
* Wifi 链接参数封装
*/
export type WifiConnectOption = {
SSID?: string;
BSSID?: string;
password?: string;
maunal?: boolean;
partialInfo?: boolean; //ios不生效
success?: (res: UniWifiResult) => void;
fail?: (res: UniWifiResult) => void;
complete?: (res: UniWifiResult) => void;
}
/**
* 获取当前链接的wifi信息
*/
export type GetConnectedWifiOptions = {
partialInfo?: boolean
success?: (res: UniWifiResult) => void
fail?: (res: UniWifiResult) => void
complete?: (res: UniWifiResult) => void
}
/*
* 对外暴露的wifi信息
*/
export type UniWifiInfo = {
SSID: string;
BSSID: string;
secure: boolean;
signalStrength: number;
frequency: number;
}
export type UniWifiResult = {
errCode : number,
errSubject : string,
errMsg : string,
wifi: UniWifiInfo | null
}
export type UniWifiCallback = () => void
export type StartWifi = (option: WifiOption) => void
export type StopWifi = (option: WifiOption) => void
export type GetWifiList = (option: WifiOption) => void
export type OnGetWifiList = (callback: UniWifiCallback) => void
export type OffGetWifiList = (callback: UniWifiCallback) => void
export type GetConnectedWifi = (option: GetConnectedWifiOptions) => void
export type ConnectWifi = (option: WifiConnectOption) => void
export type OnWifiConnected = (callback: UniWifiCallback) => void
export type OnWifiConnectedWithPartialInfo = (callback: UniWifiCallback) => void
export type OffWifiConnected = (callback: UniWifiCallback | null) => void
export type OnOffWifiConnectedWithPartialInfo = (callback: UniWifiCallback | null) => void
export type SetWifiList = (option: WifiOption) => void
interface uni {
startWifi : StartWifi,
stopWifi : StopWifi,
getWifiList : GetWifiList,
onGetWifiList : OnGetWifiList,
offGetWifiList : OffGetWifiList,
getConnectedWifi : GetConnectedWifi,
onWifiConnected : OnWifiConnected,
onWifiConnectedWithPartialInfo : OnWifiConnectedWithPartialInfo,
offWifiConnected : OffWifiConnected,
onOffWifiConnectedWithPartialInfo : OnOffWifiConnectedWithPartialInfo,
setWifiList : SetWifiList,
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册