Skip to content

Commit

Permalink
Fix blockNumber type in iso15693 commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Oct 30, 2023
1 parent 582c693 commit 08f7257
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ios/Classes/SwiftFlutterNfcKitPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ public class SwiftFlutterNfcKitPlugin: NSObject, FlutterPlugin, NFCTagReaderSess
}
} else if call.method == "readBlock" {
let arguments = call.arguments as! [String : Any?]
let blockNumber = arguments["index"] as! Int


if case let .iso15693(tag) = tag {
let rawFlags = (arguments["iso15693Flags"] as? UInt8) ?? 0
let extendedMode = (arguments["iso15693ExtendedMode"] as? Bool) ?? false
Expand All @@ -174,18 +173,19 @@ public class SwiftFlutterNfcKitPlugin: NSObject, FlutterPlugin, NFCTagReaderSess
}
}
if !extendedMode {
let blockNumber = arguments["index"] as! UInt8
tag.readSingleBlock(requestFlags: RequestFlag(rawValue: rawFlags), blockNumber: blockNumber, completionHandler: handler)
} else {
let blockNumber = arguments["index"] as! Int
tag.extendedReadSingleBlock(requestFlags: RequestFlag(rawValue: rawFlags), blockNumber: blockNumber, completionHandler: handler)
}
} else {
result(FlutterError(code: "405", message: "readBlock not supported on this type of card", details: nil))
}
} else if call.method == "writeBlock" {
let arguments = call.arguments as! [String : Any?]
let blockNumber = arguments["index"] as! Int
let data = (arguments["data"] as! FlutterStandardTypedData).data

if case let .iso15693(tag) = tag {
let rawFlags = (arguments["iso15693Flags"] as? UInt8) ?? 0
let extendedMode = (arguments["iso15693ExtendedMode"] as? Bool) ?? false
Expand All @@ -197,8 +197,10 @@ public class SwiftFlutterNfcKitPlugin: NSObject, FlutterPlugin, NFCTagReaderSess
}
}
if !extendedMode {
let blockNumber = arguments["index"] as! UInt8
tag.writeSingleBlock(requestFlags: RequestFlag(rawValue: rawFlags), blockNumber: blockNumber, dataBlock: data, completionHandler: handler)
} else {
let blockNumber = arguments["index"] as! Int
tag.extendedWriteSingleBlock(requestFlags: RequestFlag(rawValue: rawFlags), blockNumber: blockNumber, dataBlock: data, completionHandler: handler)
}
} else {
Expand Down

0 comments on commit 08f7257

Please sign in to comment.