Initial commit
This commit is contained in:
8
ios/.gitignore
vendored
Normal file
8
ios/.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
.DS_Store
|
||||
.build
|
||||
/Packages
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/configuration/registries.json
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
||||
8
ios/Sources/SocketsPlugin/Sockets.swift
Normal file
8
ios/Sources/SocketsPlugin/Sockets.swift
Normal file
@@ -0,0 +1,8 @@
|
||||
import Foundation
|
||||
|
||||
@objc public class Sockets: NSObject {
|
||||
@objc public func echo(_ value: String) -> String {
|
||||
print(value)
|
||||
return value
|
||||
}
|
||||
}
|
||||
23
ios/Sources/SocketsPlugin/SocketsPlugin.swift
Normal file
23
ios/Sources/SocketsPlugin/SocketsPlugin.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
import Foundation
|
||||
import Capacitor
|
||||
|
||||
/**
|
||||
* Please read the Capacitor iOS Plugin Development Guide
|
||||
* here: https://capacitorjs.com/docs/plugins/ios
|
||||
*/
|
||||
@objc(SocketsPlugin)
|
||||
public class SocketsPlugin: CAPPlugin, CAPBridgedPlugin {
|
||||
public let identifier = "SocketsPlugin"
|
||||
public let jsName = "Sockets"
|
||||
public let pluginMethods: [CAPPluginMethod] = [
|
||||
CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise)
|
||||
]
|
||||
private let implementation = Sockets()
|
||||
|
||||
@objc func echo(_ call: CAPPluginCall) {
|
||||
let value = call.getString("value") ?? ""
|
||||
call.resolve([
|
||||
"value": implementation.echo(value)
|
||||
])
|
||||
}
|
||||
}
|
||||
15
ios/Tests/SocketsPluginTests/SocketsPluginTests.swift
Normal file
15
ios/Tests/SocketsPluginTests/SocketsPluginTests.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
import XCTest
|
||||
@testable import SocketsPlugin
|
||||
|
||||
class SocketsTests: XCTestCase {
|
||||
func testEcho() {
|
||||
// This is an example of a functional test case for a plugin.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
|
||||
let implementation = Sockets()
|
||||
let value = "Hello, World!"
|
||||
let result = implementation.echo(value)
|
||||
|
||||
XCTAssertEqual(value, result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user