@cappitolian/local-ip 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CappitolianLocalIp.podspec +17 -17
- package/Package.swift +27 -27
- package/README.md +67 -67
- package/android/build.gradle +58 -58
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/cappitolian/plugins/localip/LocalIp.java +37 -37
- package/android/src/main/java/com/cappitolian/plugins/localip/LocalIpPlugin.java +50 -50
- package/dist/esm/definitions.d.ts +9 -9
- package/dist/esm/definitions.js +4 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +11 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/plugin.cjs.js +7 -7
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +7 -7
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/LocalIpPlugin/LocalIp.swift +39 -39
- package/ios/Sources/LocalIpPlugin/LocalIpPlugin.swift +47 -47
- package/ios/Tests/LocalIpPluginPluginTests/LocalIpPluginTests.swift +15 -15
- package/package.json +80 -80
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
require 'json'
|
|
2
|
-
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
-
|
|
5
|
-
Pod::Spec.new do |s|
|
|
6
|
-
s.name = 'CappitolianLocalIp'
|
|
7
|
-
s.version = package['version']
|
|
8
|
-
s.summary = package['description']
|
|
9
|
-
s.license = package['license']
|
|
10
|
-
s.homepage = package['repository']['url']
|
|
11
|
-
s.author = package['author']
|
|
12
|
-
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
-
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '14.0'
|
|
15
|
-
s.dependency 'Capacitor'
|
|
16
|
-
s.swift_version = '5.1'
|
|
17
|
-
end
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CappitolianLocalIp'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/Package.swift
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
// swift-tools-version: 5.9
|
|
2
|
-
import PackageDescription
|
|
3
|
-
|
|
4
|
-
let package = Package(
|
|
5
|
-
name: "CappitolianLocalIp",
|
|
6
|
-
platforms: [.iOS(.v14)],
|
|
7
|
-
products: [
|
|
8
|
-
.library(
|
|
9
|
-
name: "CappitolianLocalIp",
|
|
10
|
-
targets: ["LocalIpPlugin"])
|
|
11
|
-
],
|
|
12
|
-
dependencies: [
|
|
13
|
-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
-
],
|
|
15
|
-
targets: [
|
|
16
|
-
.target(
|
|
17
|
-
name: "LocalIpPlugin",
|
|
18
|
-
dependencies: [
|
|
19
|
-
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
-
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
-
],
|
|
22
|
-
path: "ios/Sources/LocalIpPlugin"),
|
|
23
|
-
.testTarget(
|
|
24
|
-
name: "LocalIpTests",
|
|
25
|
-
dependencies: ["LocalIpPlugin"],
|
|
26
|
-
path: "ios/Tests/LocalIpTests")
|
|
27
|
-
]
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "CappitolianLocalIp",
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "CappitolianLocalIp",
|
|
10
|
+
targets: ["LocalIpPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "LocalIpPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/LocalIpPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "LocalIpTests",
|
|
25
|
+
dependencies: ["LocalIpPlugin"],
|
|
26
|
+
path: "ios/Tests/LocalIpTests")
|
|
27
|
+
]
|
|
28
28
|
)
|
package/README.md
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
# @cappitolian/local-ip
|
|
2
|
-
|
|
3
|
-
A Capacitor plugin to retrieve the device's local IP address.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
- Get the local IP address of your device on iOS, Android, and Web.
|
|
10
|
-
- Simple API, returns an object with the IP address.
|
|
11
|
-
- Tested with **Capacitor 7** and **Ionic 7**.
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install @cappitolian/local-ip
|
|
19
|
-
npx cap sync
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
|
|
26
|
-
### Import
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
import LocalIp from '@cappitolian/local-ip';
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### Get Local IP
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
LocalIp.getLocalIp().then(result => {
|
|
36
|
-
console.log('Device Local IP:', result.ip);
|
|
37
|
-
});
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
- The plugin returns a Promise that resolves to an object like: `{ ip: string }`.
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Platforms
|
|
45
|
-
|
|
46
|
-
- **iOS** (Swift)
|
|
47
|
-
- **Android** (Java)
|
|
48
|
-
- **Web** (returns `"0.0.0.0"` as placeholder)
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Requirements
|
|
53
|
-
|
|
54
|
-
- [Capacitor 7](https://capacitorjs.com/)
|
|
55
|
-
- [Ionic 7](https://ionicframework.com/) (optional, but tested)
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## License
|
|
60
|
-
|
|
61
|
-
MIT
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Support
|
|
66
|
-
|
|
67
|
-
If you have any issues or feature requests, please open an issue on the repository.
|
|
1
|
+
# @cappitolian/local-ip
|
|
2
|
+
|
|
3
|
+
A Capacitor plugin to retrieve the device's local IP address.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Get the local IP address of your device on iOS, Android, and Web.
|
|
10
|
+
- Simple API, returns an object with the IP address.
|
|
11
|
+
- Tested with **Capacitor 7** and **Ionic 7**.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @cappitolian/local-ip
|
|
19
|
+
npx cap sync
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Import
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import LocalIp from '@cappitolian/local-ip';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Get Local IP
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
LocalIp.getLocalIp().then(result => {
|
|
36
|
+
console.log('Device Local IP:', result.ip);
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- The plugin returns a Promise that resolves to an object like: `{ ip: string }`.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Platforms
|
|
45
|
+
|
|
46
|
+
- **iOS** (Swift)
|
|
47
|
+
- **Android** (Java)
|
|
48
|
+
- **Web** (returns `"0.0.0.0"` as placeholder)
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Requirements
|
|
53
|
+
|
|
54
|
+
- [Capacitor 7](https://capacitorjs.com/)
|
|
55
|
+
- [Ionic 7](https://ionicframework.com/) (optional, but tested)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Support
|
|
66
|
+
|
|
67
|
+
If you have any issues or feature requests, please open an issue on the repository.
|
package/android/build.gradle
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
ext {
|
|
2
|
-
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
-
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
buildscript {
|
|
9
|
-
repositories {
|
|
10
|
-
google()
|
|
11
|
-
mavenCentral()
|
|
12
|
-
}
|
|
13
|
-
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
apply plugin: 'com.android.library'
|
|
19
|
-
|
|
20
|
-
android {
|
|
21
|
-
namespace "com.cappitolian.plugins.localip"
|
|
22
|
-
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
-
defaultConfig {
|
|
24
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
-
versionCode 1
|
|
27
|
-
versionName "1.0"
|
|
28
|
-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
-
}
|
|
30
|
-
buildTypes {
|
|
31
|
-
release {
|
|
32
|
-
minifyEnabled false
|
|
33
|
-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
lintOptions {
|
|
37
|
-
abortOnError false
|
|
38
|
-
}
|
|
39
|
-
compileOptions {
|
|
40
|
-
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
-
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
repositories {
|
|
46
|
-
google()
|
|
47
|
-
mavenCentral()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
dependencies {
|
|
52
|
-
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
-
implementation project(':capacitor-android')
|
|
54
|
-
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
-
testImplementation "junit:junit:$junitVersion"
|
|
56
|
-
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
-
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
-
}
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.cappitolian.plugins.localip"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
-
</manifest>
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
</manifest>
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
// package com.cappitolian.plugins.localip;
|
|
2
|
-
|
|
3
|
-
// import android.util.Log;
|
|
4
|
-
|
|
5
|
-
// public class LocalIp {
|
|
6
|
-
|
|
7
|
-
// public String echo(String value) {
|
|
8
|
-
// Log.i("Echo", value);
|
|
9
|
-
// return value;
|
|
10
|
-
// }
|
|
11
|
-
// }
|
|
12
|
-
|
|
13
|
-
package com.cappitolian.plugins.localip;
|
|
14
|
-
|
|
15
|
-
import java.net.Inet4Address;
|
|
16
|
-
import java.net.NetworkInterface;
|
|
17
|
-
import java.util.Enumeration;
|
|
18
|
-
|
|
19
|
-
public class LocalIp {
|
|
20
|
-
public String getLocalIp() throws Exception {
|
|
21
|
-
String localIp = null;
|
|
22
|
-
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
|
23
|
-
while (interfaces.hasMoreElements()) {
|
|
24
|
-
NetworkInterface intf = interfaces.nextElement();
|
|
25
|
-
Enumeration<java.net.InetAddress> addrs = intf.getInetAddresses();
|
|
26
|
-
while (addrs.hasMoreElements()) {
|
|
27
|
-
java.net.InetAddress addr = addrs.nextElement();
|
|
28
|
-
if (!addr.isLoopbackAddress() && addr instanceof Inet4Address) {
|
|
29
|
-
localIp = addr.getHostAddress();
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (localIp != null) break;
|
|
34
|
-
}
|
|
35
|
-
return localIp;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
// package com.cappitolian.plugins.localip;
|
|
2
|
+
|
|
3
|
+
// import android.util.Log;
|
|
4
|
+
|
|
5
|
+
// public class LocalIp {
|
|
6
|
+
|
|
7
|
+
// public String echo(String value) {
|
|
8
|
+
// Log.i("Echo", value);
|
|
9
|
+
// return value;
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
12
|
+
|
|
13
|
+
package com.cappitolian.plugins.localip;
|
|
14
|
+
|
|
15
|
+
import java.net.Inet4Address;
|
|
16
|
+
import java.net.NetworkInterface;
|
|
17
|
+
import java.util.Enumeration;
|
|
18
|
+
|
|
19
|
+
public class LocalIp {
|
|
20
|
+
public String getLocalIp() throws Exception {
|
|
21
|
+
String localIp = null;
|
|
22
|
+
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
|
23
|
+
while (interfaces.hasMoreElements()) {
|
|
24
|
+
NetworkInterface intf = interfaces.nextElement();
|
|
25
|
+
Enumeration<java.net.InetAddress> addrs = intf.getInetAddresses();
|
|
26
|
+
while (addrs.hasMoreElements()) {
|
|
27
|
+
java.net.InetAddress addr = addrs.nextElement();
|
|
28
|
+
if (!addr.isLoopbackAddress() && addr instanceof Inet4Address) {
|
|
29
|
+
localIp = addr.getHostAddress();
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (localIp != null) break;
|
|
34
|
+
}
|
|
35
|
+
return localIp;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
// package com.cappitolian.plugins.localip;
|
|
2
|
-
|
|
3
|
-
// import com.getcapacitor.JSObject;
|
|
4
|
-
// import com.getcapacitor.Plugin;
|
|
5
|
-
// import com.getcapacitor.PluginCall;
|
|
6
|
-
// import com.getcapacitor.PluginMethod;
|
|
7
|
-
// import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
-
|
|
9
|
-
// @CapacitorPlugin(name = "LocalIp")
|
|
10
|
-
// public class LocalIpPlugin extends Plugin {
|
|
11
|
-
|
|
12
|
-
// private LocalIp implementation = new LocalIp();
|
|
13
|
-
|
|
14
|
-
// @PluginMethod
|
|
15
|
-
// public void echo(PluginCall call) {
|
|
16
|
-
// String value = call.getString("value");
|
|
17
|
-
|
|
18
|
-
// JSObject ret = new JSObject();
|
|
19
|
-
// ret.put("value", implementation.echo(value));
|
|
20
|
-
// call.resolve(ret);
|
|
21
|
-
// }
|
|
22
|
-
// }
|
|
23
|
-
|
|
24
|
-
package com.cappitolian.plugins.localip;
|
|
25
|
-
|
|
26
|
-
import com.getcapacitor.Plugin;
|
|
27
|
-
import com.getcapacitor.PluginCall;
|
|
28
|
-
import com.getcapacitor.JSObject;
|
|
29
|
-
import com.getcapacitor.PluginMethod;
|
|
30
|
-
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
31
|
-
|
|
32
|
-
@CapacitorPlugin(name = "LocalIp")
|
|
33
|
-
public class LocalIpPlugin extends Plugin {
|
|
34
|
-
private LocalIp implementation = new LocalIp();
|
|
35
|
-
|
|
36
|
-
@PluginMethod
|
|
37
|
-
public void getLocalIp(PluginCall call) {
|
|
38
|
-
try {
|
|
39
|
-
String localIp = implementation.getLocalIp();
|
|
40
|
-
if (localIp != null) {
|
|
41
|
-
JSObject ret = new JSObject();
|
|
42
|
-
ret.put("ip", localIp);
|
|
43
|
-
call.resolve(ret);
|
|
44
|
-
} else {
|
|
45
|
-
call.reject("Local IP address not found");
|
|
46
|
-
}
|
|
47
|
-
} catch (Exception e) {
|
|
48
|
-
call.reject("Error retrieving IP: " + e.getMessage());
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
// package com.cappitolian.plugins.localip;
|
|
2
|
+
|
|
3
|
+
// import com.getcapacitor.JSObject;
|
|
4
|
+
// import com.getcapacitor.Plugin;
|
|
5
|
+
// import com.getcapacitor.PluginCall;
|
|
6
|
+
// import com.getcapacitor.PluginMethod;
|
|
7
|
+
// import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
|
|
9
|
+
// @CapacitorPlugin(name = "LocalIp")
|
|
10
|
+
// public class LocalIpPlugin extends Plugin {
|
|
11
|
+
|
|
12
|
+
// private LocalIp implementation = new LocalIp();
|
|
13
|
+
|
|
14
|
+
// @PluginMethod
|
|
15
|
+
// public void echo(PluginCall call) {
|
|
16
|
+
// String value = call.getString("value");
|
|
17
|
+
|
|
18
|
+
// JSObject ret = new JSObject();
|
|
19
|
+
// ret.put("value", implementation.echo(value));
|
|
20
|
+
// call.resolve(ret);
|
|
21
|
+
// }
|
|
22
|
+
// }
|
|
23
|
+
|
|
24
|
+
package com.cappitolian.plugins.localip;
|
|
25
|
+
|
|
26
|
+
import com.getcapacitor.Plugin;
|
|
27
|
+
import com.getcapacitor.PluginCall;
|
|
28
|
+
import com.getcapacitor.JSObject;
|
|
29
|
+
import com.getcapacitor.PluginMethod;
|
|
30
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
31
|
+
|
|
32
|
+
@CapacitorPlugin(name = "LocalIp")
|
|
33
|
+
public class LocalIpPlugin extends Plugin {
|
|
34
|
+
private LocalIp implementation = new LocalIp();
|
|
35
|
+
|
|
36
|
+
@PluginMethod
|
|
37
|
+
public void getLocalIp(PluginCall call) {
|
|
38
|
+
try {
|
|
39
|
+
String localIp = implementation.getLocalIp();
|
|
40
|
+
if (localIp != null) {
|
|
41
|
+
JSObject ret = new JSObject();
|
|
42
|
+
ret.put("ip", localIp);
|
|
43
|
+
call.resolve(ret);
|
|
44
|
+
} else {
|
|
45
|
+
call.reject("Local IP address not found");
|
|
46
|
+
}
|
|
47
|
+
} catch (Exception e) {
|
|
48
|
+
call.reject("Error retrieving IP: " + e.getMessage());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
51
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export interface LocalIpPlugin {
|
|
2
|
-
/**
|
|
3
|
-
* Gets the local IP address of the device.
|
|
4
|
-
* @returns A promise resolving with an object containing the IP address.
|
|
5
|
-
*/
|
|
6
|
-
getLocalIp(): Promise<{
|
|
7
|
-
ip: string;
|
|
8
|
-
}>;
|
|
9
|
-
}
|
|
1
|
+
export interface LocalIpPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Gets the local IP address of the device.
|
|
4
|
+
* @returns A promise resolving with an object containing the IP address.
|
|
5
|
+
*/
|
|
6
|
+
getLocalIp(): Promise<{
|
|
7
|
+
ip: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
package/dist/esm/definitions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// export interface LocalIpPlugin {
|
|
2
|
-
// echo(options: { value: string }): Promise<{ value: string }>;
|
|
3
|
-
// }
|
|
4
|
-
export {};
|
|
1
|
+
// export interface LocalIpPlugin {
|
|
2
|
+
// echo(options: { value: string }): Promise<{ value: string }>;
|
|
3
|
+
// }
|
|
4
|
+
export {};
|
|
5
5
|
//# sourceMappingURL=definitions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,kEAAkE;AAClE,IAAI","sourcesContent":["// export interface LocalIpPlugin {\n// echo(options: { value: string }): Promise<{ value: string }>;\n// }\n\nexport interface LocalIpPlugin {\n /**\n * Gets the local IP address of the device.\n * @returns A promise resolving with an object containing the IP address.\n */\n getLocalIp(): Promise<{ ip: string }>;\n}"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,kEAAkE;AAClE,IAAI","sourcesContent":["// export interface LocalIpPlugin {\r\n// echo(options: { value: string }): Promise<{ value: string }>;\r\n// }\r\n\r\nexport interface LocalIpPlugin {\r\n /**\r\n * Gets the local IP address of the device.\r\n * @returns A promise resolving with an object containing the IP address.\r\n */\r\n getLocalIp(): Promise<{ ip: string }>;\r\n}"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LocalIpPlugin } from './definitions';
|
|
2
|
-
declare const LocalIp: LocalIpPlugin;
|
|
3
|
-
export * from './definitions';
|
|
4
|
-
export default LocalIp;
|
|
1
|
+
import type { LocalIpPlugin } from './definitions';
|
|
2
|
+
declare const LocalIp: LocalIpPlugin;
|
|
3
|
+
export * from './definitions';
|
|
4
|
+
export default LocalIp;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// import { registerPlugin } from '@capacitor/core';
|
|
2
|
-
// import type { LocalIpPlugin } from './definitions';
|
|
3
|
-
// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {
|
|
4
|
-
// web: () => import('./web').then((m) => new m.LocalIpWeb()),
|
|
5
|
-
// });
|
|
6
|
-
// export * from './definitions';
|
|
7
|
-
// export { LocalIp };
|
|
8
|
-
import { registerPlugin } from '@capacitor/core';
|
|
9
|
-
const LocalIp = registerPlugin('LocalIp');
|
|
10
|
-
export * from './definitions';
|
|
11
|
-
export default LocalIp;
|
|
1
|
+
// import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
// import type { LocalIpPlugin } from './definitions';
|
|
3
|
+
// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {
|
|
4
|
+
// web: () => import('./web').then((m) => new m.LocalIpWeb()),
|
|
5
|
+
// });
|
|
6
|
+
// export * from './definitions';
|
|
7
|
+
// export { LocalIp };
|
|
8
|
+
import { registerPlugin } from '@capacitor/core';
|
|
9
|
+
const LocalIp = registerPlugin('LocalIp');
|
|
10
|
+
export * from './definitions';
|
|
11
|
+
export default LocalIp;
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAEpD,sDAAsD;AAEtD,6DAA6D;AAC7D,gEAAgE;AAChE,MAAM;AAEN,iCAAiC;AACjC,sBAAsB;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,OAAO,GAAG,cAAc,CAAgB,SAAS,CAAC,CAAC;AAEzD,cAAc,eAAe,CAAC;AAC9B,eAAe,OAAO,CAAC","sourcesContent":["// import { registerPlugin } from '@capacitor/core';\n\n// import type { LocalIpPlugin } from './definitions';\n\n// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {\n// web: () => import('./web').then((m) => new m.LocalIpWeb()),\n// });\n\n// export * from './definitions';\n// export { LocalIp };\n\nimport { registerPlugin } from '@capacitor/core';\nimport type { LocalIpPlugin } from './definitions';\n\nconst LocalIp = registerPlugin<LocalIpPlugin>('LocalIp');\n\nexport * from './definitions';\nexport default LocalIp;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAEpD,sDAAsD;AAEtD,6DAA6D;AAC7D,gEAAgE;AAChE,MAAM;AAEN,iCAAiC;AACjC,sBAAsB;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,OAAO,GAAG,cAAc,CAAgB,SAAS,CAAC,CAAC;AAEzD,cAAc,eAAe,CAAC;AAC9B,eAAe,OAAO,CAAC","sourcesContent":["// import { registerPlugin } from '@capacitor/core';\r\n\r\n// import type { LocalIpPlugin } from './definitions';\r\n\r\n// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {\r\n// web: () => import('./web').then((m) => new m.LocalIpWeb()),\r\n// });\r\n\r\n// export * from './definitions';\r\n// export { LocalIp };\r\n\r\nimport { registerPlugin } from '@capacitor/core';\r\nimport type { LocalIpPlugin } from './definitions';\r\n\r\nconst LocalIp = registerPlugin<LocalIpPlugin>('LocalIp');\r\n\r\nexport * from './definitions';\r\nexport default LocalIp;\r\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@capacitor/core');
|
|
4
4
|
|
|
5
|
-
// import { registerPlugin } from '@capacitor/core';
|
|
6
|
-
// import type { LocalIpPlugin } from './definitions';
|
|
7
|
-
// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {
|
|
8
|
-
// web: () => import('./web').then((m) => new m.LocalIpWeb()),
|
|
9
|
-
// });
|
|
10
|
-
// export * from './definitions';
|
|
11
|
-
// export { LocalIp };
|
|
5
|
+
// import { registerPlugin } from '@capacitor/core';
|
|
6
|
+
// import type { LocalIpPlugin } from './definitions';
|
|
7
|
+
// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {
|
|
8
|
+
// web: () => import('./web').then((m) => new m.LocalIpWeb()),
|
|
9
|
+
// });
|
|
10
|
+
// export * from './definitions';
|
|
11
|
+
// export { LocalIp };
|
|
12
12
|
const LocalIp = core.registerPlugin('LocalIp');
|
|
13
13
|
|
|
14
14
|
module.exports = LocalIp;
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js"],"sourcesContent":["// import { registerPlugin } from '@capacitor/core';\n// import type { LocalIpPlugin } from './definitions';\n// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {\n// web: () => import('./web').then((m) => new m.LocalIpWeb()),\n// });\n// export * from './definitions';\n// export { LocalIp };\nimport { registerPlugin } from '@capacitor/core';\nconst LocalIp = registerPlugin('LocalIp');\nexport * from './definitions';\nexport default LocalIp;\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEK,MAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js"],"sourcesContent":["// import { registerPlugin } from '@capacitor/core';\r\n// import type { LocalIpPlugin } from './definitions';\r\n// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {\r\n// web: () => import('./web').then((m) => new m.LocalIpWeb()),\r\n// });\r\n// export * from './definitions';\r\n// export { LocalIp };\r\nimport { registerPlugin } from '@capacitor/core';\r\nconst LocalIp = registerPlugin('LocalIp');\r\nexport * from './definitions';\r\nexport default LocalIp;\r\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEK,MAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var capacitorLocalIpPlugin = (function (core) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
// import { registerPlugin } from '@capacitor/core';
|
|
5
|
-
// import type { LocalIpPlugin } from './definitions';
|
|
6
|
-
// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {
|
|
7
|
-
// web: () => import('./web').then((m) => new m.LocalIpWeb()),
|
|
8
|
-
// });
|
|
9
|
-
// export * from './definitions';
|
|
10
|
-
// export { LocalIp };
|
|
4
|
+
// import { registerPlugin } from '@capacitor/core';
|
|
5
|
+
// import type { LocalIpPlugin } from './definitions';
|
|
6
|
+
// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {
|
|
7
|
+
// web: () => import('./web').then((m) => new m.LocalIpWeb()),
|
|
8
|
+
// });
|
|
9
|
+
// export * from './definitions';
|
|
10
|
+
// export { LocalIp };
|
|
11
11
|
const LocalIp = core.registerPlugin('LocalIp');
|
|
12
12
|
|
|
13
13
|
return LocalIp;
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js"],"sourcesContent":["// import { registerPlugin } from '@capacitor/core';\n// import type { LocalIpPlugin } from './definitions';\n// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {\n// web: () => import('./web').then((m) => new m.LocalIpWeb()),\n// });\n// export * from './definitions';\n// export { LocalIp };\nimport { registerPlugin } from '@capacitor/core';\nconst LocalIp = registerPlugin('LocalIp');\nexport * from './definitions';\nexport default LocalIp;\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;CAAA;CACA;CACA;CACA;CACA;CACA;CACA;AAEK,OAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js"],"sourcesContent":["// import { registerPlugin } from '@capacitor/core';\r\n// import type { LocalIpPlugin } from './definitions';\r\n// const LocalIp = registerPlugin<LocalIpPlugin>('LocalIp', {\r\n// web: () => import('./web').then((m) => new m.LocalIpWeb()),\r\n// });\r\n// export * from './definitions';\r\n// export { LocalIp };\r\nimport { registerPlugin } from '@capacitor/core';\r\nconst LocalIp = registerPlugin('LocalIp');\r\nexport * from './definitions';\r\nexport default LocalIp;\r\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;CAAA;CACA;CACA;CACA;CACA;CACA;CACA;AAEK,OAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS;;;;;;;;"}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
// import Foundation
|
|
2
|
-
|
|
3
|
-
// @objc public class LocalIp: NSObject {
|
|
4
|
-
// @objc public func echo(_ value: String) -> String {
|
|
5
|
-
// print(value)
|
|
6
|
-
// return value
|
|
7
|
-
// }
|
|
8
|
-
// }
|
|
9
|
-
|
|
10
|
-
import Foundation
|
|
11
|
-
|
|
12
|
-
@objc public class LocalIp: NSObject {
|
|
13
|
-
@objc public func getLocalIp() -> String? {
|
|
14
|
-
var address: String?
|
|
15
|
-
|
|
16
|
-
var ifaddr: UnsafeMutablePointer<ifaddrs>?
|
|
17
|
-
if getifaddrs(&ifaddr) == 0 {
|
|
18
|
-
var ptr = ifaddr
|
|
19
|
-
while ptr != nil {
|
|
20
|
-
defer { ptr = ptr?.pointee.ifa_next }
|
|
21
|
-
guard let interface = ptr?.pointee else { continue }
|
|
22
|
-
let addrFamily = interface.ifa_addr.pointee.sa_family
|
|
23
|
-
if addrFamily == UInt8(AF_INET) {
|
|
24
|
-
if let name = String(validatingUTF8: interface.ifa_name),
|
|
25
|
-
name == "en0" { // WiFi interface
|
|
26
|
-
var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
|
|
27
|
-
getnameinfo(interface.ifa_addr, socklen_t(interface.ifa_addr.pointee.sa_len),
|
|
28
|
-
&hostname, socklen_t(hostname.count),
|
|
29
|
-
nil, socklen_t(0), NI_NUMERICHOST)
|
|
30
|
-
address = String(cString: hostname)
|
|
31
|
-
break
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
freeifaddrs(ifaddr)
|
|
36
|
-
}
|
|
37
|
-
return address
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
// import Foundation
|
|
2
|
+
|
|
3
|
+
// @objc public class LocalIp: NSObject {
|
|
4
|
+
// @objc public func echo(_ value: String) -> String {
|
|
5
|
+
// print(value)
|
|
6
|
+
// return value
|
|
7
|
+
// }
|
|
8
|
+
// }
|
|
9
|
+
|
|
10
|
+
import Foundation
|
|
11
|
+
|
|
12
|
+
@objc public class LocalIp: NSObject {
|
|
13
|
+
@objc public func getLocalIp() -> String? {
|
|
14
|
+
var address: String?
|
|
15
|
+
|
|
16
|
+
var ifaddr: UnsafeMutablePointer<ifaddrs>?
|
|
17
|
+
if getifaddrs(&ifaddr) == 0 {
|
|
18
|
+
var ptr = ifaddr
|
|
19
|
+
while ptr != nil {
|
|
20
|
+
defer { ptr = ptr?.pointee.ifa_next }
|
|
21
|
+
guard let interface = ptr?.pointee else { continue }
|
|
22
|
+
let addrFamily = interface.ifa_addr.pointee.sa_family
|
|
23
|
+
if addrFamily == UInt8(AF_INET) {
|
|
24
|
+
if let name = String(validatingUTF8: interface.ifa_name),
|
|
25
|
+
name == "en0" { // WiFi interface
|
|
26
|
+
var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
|
|
27
|
+
getnameinfo(interface.ifa_addr, socklen_t(interface.ifa_addr.pointee.sa_len),
|
|
28
|
+
&hostname, socklen_t(hostname.count),
|
|
29
|
+
nil, socklen_t(0), NI_NUMERICHOST)
|
|
30
|
+
address = String(cString: hostname)
|
|
31
|
+
break
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
freeifaddrs(ifaddr)
|
|
36
|
+
}
|
|
37
|
+
return address
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
// import Foundation
|
|
2
|
-
// import Capacitor
|
|
3
|
-
|
|
4
|
-
// /**
|
|
5
|
-
// * Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
-
// * here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
-
// */
|
|
8
|
-
// @objc(LocalIpPlugin)
|
|
9
|
-
// public class LocalIpPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
-
// public let identifier = "LocalIpPlugin"
|
|
11
|
-
// public let jsName = "LocalIp"
|
|
12
|
-
// public let pluginMethods: [CAPPluginMethod] = [
|
|
13
|
-
// CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise)
|
|
14
|
-
// ]
|
|
15
|
-
// private let implementation = LocalIp()
|
|
16
|
-
|
|
17
|
-
// @objc func echo(_ call: CAPPluginCall) {
|
|
18
|
-
// let value = call.getString("value") ?? ""
|
|
19
|
-
// call.resolve([
|
|
20
|
-
// "value": implementation.echo(value)
|
|
21
|
-
// ])
|
|
22
|
-
// }
|
|
23
|
-
// }
|
|
24
|
-
|
|
25
|
-
import Foundation
|
|
26
|
-
import Capacitor
|
|
27
|
-
|
|
28
|
-
@objc(LocalIpPlugin)
|
|
29
|
-
public class LocalIpPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
30
|
-
public let identifier = "LocalIpPlugin"
|
|
31
|
-
public let jsName = "LocalIp"
|
|
32
|
-
public let pluginMethods: [CAPPluginMethod] = [
|
|
33
|
-
CAPPluginMethod(name: "getLocalIp", returnType: CAPPluginReturnPromise)
|
|
34
|
-
]
|
|
35
|
-
private let implementation = LocalIp()
|
|
36
|
-
|
|
37
|
-
@objc func getLocalIp(_ call: CAPPluginCall) {
|
|
38
|
-
print("LocalIpPlugin.getLocalIp called!")
|
|
39
|
-
if let ip = implementation.getLocalIp() {
|
|
40
|
-
call.resolve([
|
|
41
|
-
"ip": ip
|
|
42
|
-
])
|
|
43
|
-
} else {
|
|
44
|
-
call.reject("Unable to determine local IP address")
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
// import Foundation
|
|
2
|
+
// import Capacitor
|
|
3
|
+
|
|
4
|
+
// /**
|
|
5
|
+
// * Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
// * here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
// */
|
|
8
|
+
// @objc(LocalIpPlugin)
|
|
9
|
+
// public class LocalIpPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
+
// public let identifier = "LocalIpPlugin"
|
|
11
|
+
// public let jsName = "LocalIp"
|
|
12
|
+
// public let pluginMethods: [CAPPluginMethod] = [
|
|
13
|
+
// CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise)
|
|
14
|
+
// ]
|
|
15
|
+
// private let implementation = LocalIp()
|
|
16
|
+
|
|
17
|
+
// @objc func echo(_ call: CAPPluginCall) {
|
|
18
|
+
// let value = call.getString("value") ?? ""
|
|
19
|
+
// call.resolve([
|
|
20
|
+
// "value": implementation.echo(value)
|
|
21
|
+
// ])
|
|
22
|
+
// }
|
|
23
|
+
// }
|
|
24
|
+
|
|
25
|
+
import Foundation
|
|
26
|
+
import Capacitor
|
|
27
|
+
|
|
28
|
+
@objc(LocalIpPlugin)
|
|
29
|
+
public class LocalIpPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
30
|
+
public let identifier = "LocalIpPlugin"
|
|
31
|
+
public let jsName = "LocalIp"
|
|
32
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
33
|
+
CAPPluginMethod(name: "getLocalIp", returnType: CAPPluginReturnPromise)
|
|
34
|
+
]
|
|
35
|
+
private let implementation = LocalIp()
|
|
36
|
+
|
|
37
|
+
@objc func getLocalIp(_ call: CAPPluginCall) {
|
|
38
|
+
print("LocalIpPlugin.getLocalIp called!")
|
|
39
|
+
if let ip = implementation.getLocalIp() {
|
|
40
|
+
call.resolve([
|
|
41
|
+
"ip": ip
|
|
42
|
+
])
|
|
43
|
+
} else {
|
|
44
|
+
call.reject("Unable to determine local IP address")
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import XCTest
|
|
2
|
-
@testable import LocalIpPlugin
|
|
3
|
-
|
|
4
|
-
class LocalIpTests: XCTestCase {
|
|
5
|
-
func testEcho() {
|
|
6
|
-
// This is an example of a functional test case for a plugin.
|
|
7
|
-
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
|
8
|
-
|
|
9
|
-
let implementation = LocalIp()
|
|
10
|
-
let value = "Hello, World!"
|
|
11
|
-
let result = implementation.echo(value)
|
|
12
|
-
|
|
13
|
-
XCTAssertEqual(value, result)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import XCTest
|
|
2
|
+
@testable import LocalIpPlugin
|
|
3
|
+
|
|
4
|
+
class LocalIpTests: XCTestCase {
|
|
5
|
+
func testEcho() {
|
|
6
|
+
// This is an example of a functional test case for a plugin.
|
|
7
|
+
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
|
8
|
+
|
|
9
|
+
let implementation = LocalIp()
|
|
10
|
+
let value = "Hello, World!"
|
|
11
|
+
let result = implementation.echo(value)
|
|
12
|
+
|
|
13
|
+
XCTAssertEqual(value, result)
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@cappitolian/local-ip",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Retrieve local IP address from native device",
|
|
5
|
-
"main": "dist/plugin.cjs.js",
|
|
6
|
-
"module": "dist/esm/index.js",
|
|
7
|
-
"types": "dist/esm/index.d.ts",
|
|
8
|
-
"unpkg": "dist/plugin.js",
|
|
9
|
-
"files": [
|
|
10
|
-
"android/src/main/",
|
|
11
|
-
"android/build.gradle",
|
|
12
|
-
"dist/",
|
|
13
|
-
"ios/Sources",
|
|
14
|
-
"ios/Tests",
|
|
15
|
-
"Package.swift",
|
|
16
|
-
"CappitolianLocalIp.podspec"
|
|
17
|
-
],
|
|
18
|
-
"author": "Cappitolian",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/alessandrycruz1987/local-ip.git"
|
|
23
|
-
},
|
|
24
|
-
"bugs": {
|
|
25
|
-
"url": "https://github.com/alessandrycruz1987/local-ip/issues"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"capacitor",
|
|
29
|
-
"plugin",
|
|
30
|
-
"native"
|
|
31
|
-
],
|
|
32
|
-
"scripts": {
|
|
33
|
-
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
34
|
-
"verify:ios": "xcodebuild -scheme CappitolianLocalIp -destination generic/platform=iOS",
|
|
35
|
-
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
36
|
-
"verify:web": "npm run build",
|
|
37
|
-
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
38
|
-
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
39
|
-
"eslint": "eslint . --ext ts",
|
|
40
|
-
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
41
|
-
"swiftlint": "node-swiftlint",
|
|
42
|
-
"docgen": "docgen --api LocalIpPlugin --output-readme README.md --output-json dist/docs.json",
|
|
43
|
-
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
44
|
-
"clean": "rimraf ./dist",
|
|
45
|
-
"watch": "tsc --watch",
|
|
46
|
-
"prepublishOnly": "npm run build"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@capacitor/android": "^7.0.0",
|
|
50
|
-
"@capacitor/core": "^7.0.0",
|
|
51
|
-
"@capacitor/docgen": "^0.3.0",
|
|
52
|
-
"@capacitor/ios": "^7.0.0",
|
|
53
|
-
"@ionic/eslint-config": "^0.4.0",
|
|
54
|
-
"@ionic/prettier-config": "^4.0.0",
|
|
55
|
-
"@ionic/swiftlint-config": "^2.0.0",
|
|
56
|
-
"eslint": "^8.57.0",
|
|
57
|
-
"prettier": "^3.4.2",
|
|
58
|
-
"prettier-plugin-java": "^2.6.6",
|
|
59
|
-
"rimraf": "^6.0.1",
|
|
60
|
-
"rollup": "^4.30.1",
|
|
61
|
-
"swiftlint": "^2.0.0",
|
|
62
|
-
"typescript": "~4.1.5"
|
|
63
|
-
},
|
|
64
|
-
"peerDependencies": {
|
|
65
|
-
"@capacitor/core": ">=7.0.0"
|
|
66
|
-
},
|
|
67
|
-
"prettier": "@ionic/prettier-config",
|
|
68
|
-
"swiftlint": "@ionic/swiftlint-config",
|
|
69
|
-
"eslintConfig": {
|
|
70
|
-
"extends": "@ionic/eslint-config/recommended"
|
|
71
|
-
},
|
|
72
|
-
"capacitor": {
|
|
73
|
-
"ios": {
|
|
74
|
-
"src": "ios"
|
|
75
|
-
},
|
|
76
|
-
"android": {
|
|
77
|
-
"src": "android"
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@cappitolian/local-ip",
|
|
3
|
+
"version": "0.0.12",
|
|
4
|
+
"description": "Retrieve local IP address from native device",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Sources",
|
|
14
|
+
"ios/Tests",
|
|
15
|
+
"Package.swift",
|
|
16
|
+
"CappitolianLocalIp.podspec"
|
|
17
|
+
],
|
|
18
|
+
"author": "Cappitolian",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/alessandrycruz1987/local-ip.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/alessandrycruz1987/local-ip/issues"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"capacitor",
|
|
29
|
+
"plugin",
|
|
30
|
+
"native"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
34
|
+
"verify:ios": "xcodebuild -scheme CappitolianLocalIp -destination generic/platform=iOS",
|
|
35
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
36
|
+
"verify:web": "npm run build",
|
|
37
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
38
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
39
|
+
"eslint": "eslint . --ext ts",
|
|
40
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
41
|
+
"swiftlint": "node-swiftlint",
|
|
42
|
+
"docgen": "docgen --api LocalIpPlugin --output-readme README.md --output-json dist/docs.json",
|
|
43
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
44
|
+
"clean": "rimraf ./dist",
|
|
45
|
+
"watch": "tsc --watch",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@capacitor/android": "^7.0.0",
|
|
50
|
+
"@capacitor/core": "^7.0.0",
|
|
51
|
+
"@capacitor/docgen": "^0.3.0",
|
|
52
|
+
"@capacitor/ios": "^7.0.0",
|
|
53
|
+
"@ionic/eslint-config": "^0.4.0",
|
|
54
|
+
"@ionic/prettier-config": "^4.0.0",
|
|
55
|
+
"@ionic/swiftlint-config": "^2.0.0",
|
|
56
|
+
"eslint": "^8.57.0",
|
|
57
|
+
"prettier": "^3.4.2",
|
|
58
|
+
"prettier-plugin-java": "^2.6.6",
|
|
59
|
+
"rimraf": "^6.0.1",
|
|
60
|
+
"rollup": "^4.30.1",
|
|
61
|
+
"swiftlint": "^2.0.0",
|
|
62
|
+
"typescript": "~4.1.5"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@capacitor/core": ">=7.0.0"
|
|
66
|
+
},
|
|
67
|
+
"prettier": "@ionic/prettier-config",
|
|
68
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
69
|
+
"eslintConfig": {
|
|
70
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
71
|
+
},
|
|
72
|
+
"capacitor": {
|
|
73
|
+
"ios": {
|
|
74
|
+
"src": "ios"
|
|
75
|
+
},
|
|
76
|
+
"android": {
|
|
77
|
+
"src": "android"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|