├── .watchmanconfig
├── example
├── .watchmanconfig
├── jest.config.js
├── .eslintrc.js
├── app.json
├── .prettierrc.js
├── android
│ ├── app
│ │ ├── debug.keystore
│ │ ├── src
│ │ │ ├── main
│ │ │ │ ├── res
│ │ │ │ │ ├── values
│ │ │ │ │ │ ├── strings.xml
│ │ │ │ │ │ └── styles.xml
│ │ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ │ └── drawable
│ │ │ │ │ │ └── rn_edit_text_material.xml
│ │ │ │ ├── java
│ │ │ │ │ └── com
│ │ │ │ │ │ └── nitronetworkinfoexample
│ │ │ │ │ │ ├── MainApplication.kt
│ │ │ │ │ │ └── MainActivity.kt
│ │ │ │ └── AndroidManifest.xml
│ │ │ └── debug
│ │ │ │ └── AndroidManifest.xml
│ │ ├── proguard-rules.pro
│ │ └── build.gradle
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── settings.gradle
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradlew.bat
│ └── gradlew
├── ios
│ ├── NitroNetworkInfoExample
│ │ ├── Images.xcassets
│ │ │ ├── Contents.json
│ │ │ └── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ ├── PrivacyInfo.xcprivacy
│ │ ├── AppDelegate.swift
│ │ ├── Info.plist
│ │ └── LaunchScreen.storyboard
│ ├── NitroNetworkInfoExample.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── .xcode.env
│ ├── Podfile
│ └── NitroNetworkInfoExample.xcodeproj
│ │ ├── xcshareddata
│ │ └── xcschemes
│ │ │ └── NitroNetworkInfoExample.xcscheme
│ │ └── project.pbxproj
├── index.js
├── tsconfig.json
├── react-native.config.js
├── metro.config.js
├── babel.config.js
├── Gemfile
├── App.tsx
├── package.json
├── .gitignore
├── Gemfile.lock
└── README.md
├── bunfig.toml
├── nitrogen
└── generated
│ ├── .gitattributes
│ ├── ios
│ ├── c++
│ │ ├── HybridNitroNetworkInfoSpecSwift.cpp
│ │ └── HybridNitroNetworkInfoSpecSwift.hpp
│ ├── NitroNetworkInfoAutolinking.mm
│ ├── NitroNetworkInfoAutolinking.swift
│ ├── swift
│ │ ├── NitroNetworkStatusInfo.swift
│ │ ├── ConnectionType.swift
│ │ ├── Func_void.swift
│ │ ├── Func_void_NitroNetworkStatusInfo.swift
│ │ ├── HybridNitroNetworkInfoSpec.swift
│ │ └── HybridNitroNetworkInfoSpec_cxx.swift
│ ├── NitroNetworkInfo+autolinking.rb
│ ├── NitroNetworkInfo-Swift-Cxx-Umbrella.hpp
│ ├── NitroNetworkInfo-Swift-Cxx-Bridge.cpp
│ └── NitroNetworkInfo-Swift-Cxx-Bridge.hpp
│ ├── android
│ ├── kotlin
│ │ └── com
│ │ │ └── margelo
│ │ │ └── nitro
│ │ │ └── nitronetworkinfo
│ │ │ ├── ConnectionType.kt
│ │ │ ├── NitroNetworkStatusInfo.kt
│ │ │ ├── NitroNetworkInfoOnLoad.kt
│ │ │ ├── HybridNitroNetworkInfoSpec.kt
│ │ │ ├── Func_void.kt
│ │ │ └── Func_void_NitroNetworkStatusInfo.kt
│ ├── NitroNetworkInfo+autolinking.gradle
│ ├── NitroNetworkInfoOnLoad.hpp
│ ├── NitroNetworkInfoOnLoad.cpp
│ ├── c++
│ │ ├── JFunc_void.hpp
│ │ ├── JHybridNitroNetworkInfoSpec.hpp
│ │ ├── JNitroNetworkStatusInfo.hpp
│ │ ├── JConnectionType.hpp
│ │ ├── JFunc_void_NitroNetworkStatusInfo.hpp
│ │ └── JHybridNitroNetworkInfoSpec.cpp
│ └── NitroNetworkInfo+autolinking.cmake
│ └── shared
│ └── c++
│ ├── HybridNitroNetworkInfoSpec.cpp
│ ├── HybridNitroNetworkInfoSpec.hpp
│ ├── NitroNetworkStatusInfo.hpp
│ └── ConnectionType.hpp
├── babel.config.js
├── ios
├── Bridge.h
├── HybridNitroNetworkInfo.swift
└── NitroNetworkInfoImpl.swift
├── android
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── cpp
│ │ └── cpp-adapter.cpp
│ │ └── java
│ │ └── com
│ │ └── nitronetworkinfo
│ │ ├── NitroNetworkInfoPackage.java
│ │ ├── HybridNitroNetworkInfo.kt
│ │ └── NitroNetworkInfoImpl.kt
├── gradle.properties
├── CMakeLists.txt
└── build.gradle
├── src
├── types.ts
├── index.ts
└── specs
│ └── nitro-network-info.nitro.ts
├── nitro.json
├── post-script.js
├── tsconfig.json
├── .gitignore
├── .github
├── dependabot.yml
└── workflows
│ ├── android-build.yml
│ ├── release.yml
│ └── ios-build.yml
├── NitroNetworkInfo.podspec
├── release.config.js
├── package.json
├── README.md
└── CHANGELOG.md
/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/example/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/bunfig.toml:
--------------------------------------------------------------------------------
1 | [install]
2 | linker = "hoisted"
3 |
--------------------------------------------------------------------------------
/nitrogen/generated/.gitattributes:
--------------------------------------------------------------------------------
1 | ** linguist-generated=true
2 |
--------------------------------------------------------------------------------
/example/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | preset: 'react-native',
3 | };
4 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:@react-native/babel-preset'],
3 | }
4 |
--------------------------------------------------------------------------------
/example/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: '@react-native',
4 | };
5 |
--------------------------------------------------------------------------------
/example/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "NitroNetworkInfoExample",
3 | "displayName": "NitroNetworkInfoExample"
4 | }
5 |
--------------------------------------------------------------------------------
/example/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | arrowParens: 'avoid',
3 | singleQuote: true,
4 | trailingComma: 'all',
5 | };
6 |
--------------------------------------------------------------------------------
/example/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/debug.keystore
--------------------------------------------------------------------------------
/ios/Bridge.h:
--------------------------------------------------------------------------------
1 | //
2 | // Bridge.h
3 | // nitro-network-info
4 | //
5 | // Created by Patrick Kabwe on 5/3/2025
6 | //
7 |
8 | #pragma once
9 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NitroNetworkInfoExample
3 |
4 |
--------------------------------------------------------------------------------
/example/ios/NitroNetworkInfoExample/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickkabwe/react-native-nitro-network-info/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/src/main/cpp/cpp-adapter.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "NitroNetworkInfoOnLoad.hpp"
3 |
4 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
5 | return margelo::nitro::nitronetworkinfo::initialize(vm);
6 | }
7 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | NitroNetworkInfo_kotlinVersion=2.0.21
2 | NitroNetworkInfo_minSdkVersion=23
3 | NitroNetworkInfo_targetSdkVersion=34
4 | NitroNetworkInfo_compileSdkVersion=34
5 | NitroNetworkInfo_ndkVersion=27.1.12297006
6 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import {AppRegistry} from 'react-native';
6 | import App from './App';
7 | import {name as appName} from './app.json';
8 |
9 | AppRegistry.registerComponent(appName, () => App);
10 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
--------------------------------------------------------------------------------
/src/types.ts:
--------------------------------------------------------------------------------
1 |
2 | export type ConnectionType = 'unknown' | 'ethernet' | 'wifi' | 'cellular'
3 |
4 | export type NitroNetworkStatusInfo = {
5 | isConnected: boolean
6 | connectionType: ConnectionType
7 | }
8 |
9 |
10 | export type NetworkInfoListener = (networkInfo: NitroNetworkStatusInfo) => void
--------------------------------------------------------------------------------
/example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@react-native/typescript-config",
3 | "include": ["**/*.ts", "**/*.tsx"],
4 | "exclude": ["**/node_modules", "**/Pods"],
5 | "compilerOptions": {
6 | "strict": true,
7 | "baseUrl": ".",
8 | "paths": {
9 | "react-native-nitro-network-info": ["../src"]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/example/ios/NitroNetworkInfoExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import { NitroModules } from 'react-native-nitro-modules'
2 | import type { NitroNetworkInfo as NitroNetworkInfoSpec } from './specs/nitro-network-info.nitro'
3 | export type * from './types'
4 |
5 | const NitroNetworkInfo =
6 | NitroModules.createHybridObject('NitroNetworkInfo')
7 |
8 | export default NitroNetworkInfo
9 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement { includeBuild("../../node_modules/@react-native/gradle-plugin") }
2 | plugins { id("com.facebook.react.settings") }
3 | extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
4 | rootProject.name = 'NitroNetworkInfoExample'
5 | include ':app'
6 | includeBuild('../../node_modules/@react-native/gradle-plugin')
7 |
--------------------------------------------------------------------------------
/src/specs/nitro-network-info.nitro.ts:
--------------------------------------------------------------------------------
1 | import { type HybridObject } from 'react-native-nitro-modules'
2 | import type { ConnectionType, NetworkInfoListener } from '../types'
3 |
4 | export interface NitroNetworkInfo extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
5 | readonly isConnected: boolean
6 | readonly connectionType: ConnectionType
7 | addListener(listener: NetworkInfoListener): () => void
8 | }
--------------------------------------------------------------------------------
/example/react-native.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 | const pkg = require('../package.json')
3 |
4 | /**
5 | * @type {import('@react-native-community/cli-types').Config}
6 | */
7 | module.exports = {
8 | project: {
9 | ios: {
10 | automaticPodsInstallation: true,
11 | },
12 | },
13 | dependencies: {
14 | [pkg.name]: {
15 | root: path.join(__dirname, '..'),
16 | },
17 | },
18 | }
19 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/c++/HybridNitroNetworkInfoSpecSwift.cpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// HybridNitroNetworkInfoSpecSwift.cpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #include "HybridNitroNetworkInfoSpecSwift.hpp"
9 |
10 | namespace margelo::nitro::nitronetworkinfo {
11 | } // namespace margelo::nitro::nitronetworkinfo
12 |
--------------------------------------------------------------------------------
/example/metro.config.js:
--------------------------------------------------------------------------------
1 | const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
2 | const path = require('path');
3 | const root = path.resolve(__dirname, '..');
4 |
5 | /**
6 | * Metro configuration
7 | * https://facebook.github.io/metro/docs/configuration
8 | *
9 | * @type {import('metro-config').MetroConfig}
10 | */
11 | const config = {
12 | watchFolders: [root],
13 | };
14 |
15 | module.exports = mergeConfig(getDefaultConfig(__dirname), config);
--------------------------------------------------------------------------------
/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/example/babel.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const pak = require('../package.json');
3 |
4 | module.exports = api => {
5 | api.cache(true);
6 | return {
7 | presets: ['module:@react-native/babel-preset'],
8 | plugins: [
9 | [
10 | 'module-resolver',
11 | {
12 | extensions: ['.js', '.ts', '.json', '.jsx', '.tsx'],
13 | alias: {
14 | [pak.name]: path.join(__dirname, '../', pak.source),
15 | },
16 | },
17 | ],
18 | ],
19 | };
20 | };
--------------------------------------------------------------------------------
/example/ios/.xcode.env:
--------------------------------------------------------------------------------
1 | # This `.xcode.env` file is versioned and is used to source the environment
2 | # used when running script phases inside Xcode.
3 | # To customize your local environment, you can create an `.xcode.env.local`
4 | # file that is not versioned.
5 |
6 | # NODE_BINARY variable contains the PATH to the node executable.
7 | #
8 | # Customize the NODE_BINARY variable here.
9 | # For example, to use nvm with brew, add the following line
10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use
11 | export NODE_BINARY=$(command -v node)
12 |
--------------------------------------------------------------------------------
/nitro.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://nitro.margelo.com/nitro.schema.json",
3 | "cxxNamespace": [
4 | "nitronetworkinfo"
5 | ],
6 | "ios": {
7 | "iosModuleName": "NitroNetworkInfo"
8 | },
9 | "android": {
10 | "androidNamespace": [
11 | "nitronetworkinfo"
12 | ],
13 | "androidCxxLibName": "NitroNetworkInfo"
14 | },
15 | "autolinking": {
16 | "NitroNetworkInfo": {
17 | "swift": "HybridNitroNetworkInfo",
18 | "kotlin": "HybridNitroNetworkInfo"
19 | }
20 | },
21 | "ignorePaths": [
22 | "**/node_modules"
23 | ]
24 | }
--------------------------------------------------------------------------------
/example/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4 | ruby ">= 2.6.10"
5 |
6 | # Exclude problematic versions of cocoapods and activesupport that causes build failures.
7 | gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8 | gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9 | gem 'xcodeproj', '< 1.28.0'
10 | gem 'concurrent-ruby', '< 1.3.6'
11 |
12 | # Ruby 3.4.0 has removed some libraries from the standard library.
13 | gem 'bigdecimal'
14 | gem 'logger'
15 | gem 'benchmark'
16 | gem 'mutex_m'
17 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | buildToolsVersion = "36.0.0"
4 | minSdkVersion = 24
5 | compileSdkVersion = 36
6 | targetSdkVersion = 36
7 | ndkVersion = "27.1.12297006"
8 | kotlinVersion = "2.1.20"
9 | }
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | dependencies {
15 | classpath("com.android.tools.build:gradle")
16 | classpath("com.facebook.react:react-native-gradle-plugin")
17 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
18 | }
19 | }
20 |
21 | apply plugin: "com.facebook.react.rootproject"
22 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/kotlin/com/margelo/nitro/nitronetworkinfo/ConnectionType.kt:
--------------------------------------------------------------------------------
1 | ///
2 | /// ConnectionType.kt
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | package com.margelo.nitro.nitronetworkinfo
9 |
10 | import androidx.annotation.Keep
11 | import com.facebook.proguard.annotations.DoNotStrip
12 |
13 | /**
14 | * Represents the JavaScript enum/union "ConnectionType".
15 | */
16 | @DoNotStrip
17 | @Keep
18 | enum class ConnectionType(@DoNotStrip @Keep val value: Int) {
19 | UNKNOWN(0),
20 | ETHERNET(1),
21 | WIFI(2),
22 | CELLULAR(3);
23 | }
24 |
--------------------------------------------------------------------------------
/android/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(NitroNetworkInfo)
2 | cmake_minimum_required(VERSION 3.9.0)
3 |
4 | set (PACKAGE_NAME NitroNetworkInfo)
5 | set (CMAKE_VERBOSE_MAKEFILE ON)
6 | set (CMAKE_CXX_STANDARD 20)
7 |
8 | # Define C++ library and add all sources
9 | add_library(${PACKAGE_NAME} SHARED
10 | src/main/cpp/cpp-adapter.cpp
11 | )
12 |
13 | # Add Nitrogen specs :)
14 | include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroNetworkInfo+autolinking.cmake)
15 |
16 | # Set up local includes
17 | include_directories(
18 | "src/main/cpp"
19 | "../cpp"
20 | )
21 |
22 | find_library(LOG_LIB log)
23 |
24 | # Link all libraries together
25 | target_link_libraries(
26 | ${PACKAGE_NAME}
27 | ${LOG_LIB}
28 | android # <-- Android core
29 | )
30 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/NitroNetworkInfo+autolinking.gradle:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkInfo+autolinking.gradle
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | /// This is a Gradle file that adds all files generated by Nitrogen
9 | /// to the current Gradle project.
10 | ///
11 | /// To use it, add this to your build.gradle:
12 | /// ```gradle
13 | /// apply from: '../nitrogen/generated/android/NitroNetworkInfo+autolinking.gradle'
14 | /// ```
15 |
16 | logger.warn("[NitroModules] 🔥 NitroNetworkInfo is boosted by nitro!")
17 |
18 | android {
19 | sourceSets {
20 | main {
21 | java.srcDirs += [
22 | // Nitrogen files
23 | "${project.projectDir}/../nitrogen/generated/android/kotlin"
24 | ]
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/post-script.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file This script is auto-generated by create-nitro-module and should not be edited.
3 | *
4 | * @description This script applies a workaround for Android by modifying the 'OnLoad.cpp' file.
5 | * It reads the file content and removes the 'margelo/nitro/' string from it. This enables support for custom package names.
6 | *
7 | * @module create-nitro-module
8 | */
9 | const path = require('node:path')
10 | const { writeFile, readFile } = require('node:fs/promises')
11 |
12 | const androidWorkaround = async () => {
13 | const androidOnLoadFile = path.join(
14 | process.cwd(),
15 | 'nitrogen/generated/android',
16 | 'NitroNetworkInfoOnLoad.cpp'
17 | )
18 |
19 |
20 | const str = await readFile(androidOnLoadFile, { encoding: 'utf8' })
21 | await writeFile(androidOnLoadFile, str.replace(/margelo\/nitro\//g, ''))
22 | }
23 | androidWorkaround()
--------------------------------------------------------------------------------
/nitrogen/generated/android/NitroNetworkInfoOnLoad.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkInfoOnLoad.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #include
9 | #include
10 |
11 | namespace margelo::nitro::nitronetworkinfo {
12 |
13 | /**
14 | * Initializes the native (C++) part of NitroNetworkInfo, and autolinks all Hybrid Objects.
15 | * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
16 | * Example:
17 | * ```cpp (cpp-adapter.cpp)
18 | * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
19 | * return margelo::nitro::nitronetworkinfo::initialize(vm);
20 | * }
21 | * ```
22 | */
23 | int initialize(JavaVM* vm);
24 |
25 | } // namespace margelo::nitro::nitronetworkinfo
26 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/nitronetworkinfoexample/MainApplication.kt:
--------------------------------------------------------------------------------
1 | package com.nitronetworkinfoexample
2 |
3 | import android.app.Application
4 | import com.facebook.react.PackageList
5 | import com.facebook.react.ReactApplication
6 | import com.facebook.react.ReactHost
7 | import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
8 | import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
9 |
10 | class MainApplication : Application(), ReactApplication {
11 |
12 | override val reactHost: ReactHost by lazy {
13 | getDefaultReactHost(
14 | context = applicationContext,
15 | packageList =
16 | PackageList(this).packages.apply {
17 | // Packages that cannot be autolinked yet can be added manually here, for example:
18 | // add(MyReactNativePackage())
19 | },
20 | )
21 | }
22 |
23 | override fun onCreate() {
24 | super.onCreate()
25 | loadReactNative(this)
26 | }
27 | }
--------------------------------------------------------------------------------
/nitrogen/generated/shared/c++/HybridNitroNetworkInfoSpec.cpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// HybridNitroNetworkInfoSpec.cpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #include "HybridNitroNetworkInfoSpec.hpp"
9 |
10 | namespace margelo::nitro::nitronetworkinfo {
11 |
12 | void HybridNitroNetworkInfoSpec::loadHybridMethods() {
13 | // load base methods/properties
14 | HybridObject::loadHybridMethods();
15 | // load custom methods/properties
16 | registerHybrids(this, [](Prototype& prototype) {
17 | prototype.registerHybridGetter("isConnected", &HybridNitroNetworkInfoSpec::getIsConnected);
18 | prototype.registerHybridGetter("connectionType", &HybridNitroNetworkInfoSpec::getConnectionType);
19 | prototype.registerHybridMethod("addListener", &HybridNitroNetworkInfoSpec::addListener);
20 | });
21 | }
22 |
23 | } // namespace margelo::nitro::nitronetworkinfo
24 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/nitronetworkinfoexample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.nitronetworkinfoexample
2 |
3 | import com.facebook.react.ReactActivity
4 | import com.facebook.react.ReactActivityDelegate
5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
6 | import com.facebook.react.defaults.DefaultReactActivityDelegate
7 |
8 | class MainActivity : ReactActivity() {
9 |
10 | /**
11 | * Returns the name of the main component registered from JavaScript. This is used to schedule
12 | * rendering of the component.
13 | */
14 | override fun getMainComponentName(): String = "NitroNetworkInfoExample"
15 |
16 | /**
17 | * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
18 | * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
19 | */
20 | override fun createReactActivityDelegate(): ReactActivityDelegate =
21 | DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
22 | }
23 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Resolve react_native_pods.rb with node to allow for hoisting
2 | require Pod::Executable.execute_command('node', ['-p',
3 | 'require.resolve(
4 | "react-native/scripts/react_native_pods.rb",
5 | {paths: [process.argv[1]]},
6 | )', __dir__]).strip
7 |
8 | platform :ios, min_ios_version_supported
9 | prepare_react_native_project!
10 |
11 | linkage = ENV['USE_FRAMEWORKS']
12 | if linkage != nil
13 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
14 | use_frameworks! :linkage => linkage.to_sym
15 | end
16 |
17 | target 'NitroNetworkInfoExample' do
18 | config = use_native_modules!
19 |
20 | use_react_native!(
21 | :path => config[:reactNativePath],
22 | # An absolute path to your application root.
23 | :app_path => "#{Pod::Config.instance.installation_root}/.."
24 | )
25 |
26 | post_install do |installer|
27 | react_native_post_install(
28 | installer,
29 | config[:reactNativePath],
30 | :mac_catalyst_enabled => false,
31 | # :ccache_enabled => true,
32 | )
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/NitroNetworkInfoAutolinking.mm:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkInfoAutolinking.mm
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #import
9 | #import
10 | #import "NitroNetworkInfo-Swift-Cxx-Umbrella.hpp"
11 | #import
12 |
13 | #include "HybridNitroNetworkInfoSpecSwift.hpp"
14 |
15 | @interface NitroNetworkInfoAutolinking : NSObject
16 | @end
17 |
18 | @implementation NitroNetworkInfoAutolinking
19 |
20 | + (void) load {
21 | using namespace margelo::nitro;
22 | using namespace margelo::nitro::nitronetworkinfo;
23 |
24 | HybridObjectRegistry::registerHybridObjectConstructor(
25 | "NitroNetworkInfo",
26 | []() -> std::shared_ptr {
27 | std::shared_ptr hybridObject = NitroNetworkInfo::NitroNetworkInfoAutolinking::createNitroNetworkInfo();
28 | return hybridObject;
29 | }
30 | );
31 | }
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "allowUnreachableCode": false,
5 | "allowUnusedLabels": false,
6 | "esModuleInterop": true,
7 | "forceConsistentCasingInFileNames": true,
8 | "jsx": "react",
9 | "lib": ["esnext"],
10 | "module": "esnext",
11 | "moduleResolution": "node",
12 | "noEmit": false,
13 | "noFallthroughCasesInSwitch": true,
14 | "noImplicitReturns": true,
15 | "noImplicitUseStrict": false,
16 | "noStrictGenericChecks": false,
17 | "noUncheckedIndexedAccess": true,
18 | "noUnusedLocals": true,
19 | "noUnusedParameters": true,
20 | "resolveJsonModule": true,
21 | "skipLibCheck": true,
22 | "strict": true,
23 | "target": "esnext",
24 | "verbatimModuleSyntax": true
25 | },
26 | "exclude": [
27 | "**/node_modules",
28 | "**/lib",
29 | "**/.eslintrc.js",
30 | "**/.prettierrc.js",
31 | "**/jest.config.js",
32 | "**/babel.config.js",
33 | "**/metro.config.js",
34 | "**/tsconfig.json"
35 | ],
36 | "include": ["src/**/*", "nitrogen/**/*.json"]
37 | }
38 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # XDE
6 | .expo/
7 |
8 | # VSCode
9 | .vscode/
10 | jsconfig.json
11 |
12 | # Xcode
13 | #
14 | build/
15 | *.pbxuser
16 | !default.pbxuser
17 | *.mode1v3
18 | !default.mode1v3
19 | *.mode2v3
20 | !default.mode2v3
21 | *.perspectivev3
22 | !default.perspectivev3
23 | xcuserdata
24 | *.xccheckout
25 | *.moved-aside
26 | DerivedData
27 | *.hmap
28 | *.ipa
29 | *.xcuserstate
30 | project.xcworkspace
31 |
32 | # Android/IJ
33 | #
34 | .classpath
35 | .cxx
36 | .gradle
37 | .idea
38 | .project
39 | .settings
40 | local.properties
41 | android.iml
42 |
43 | # Cocoapods
44 | #
45 | example/ios/Pods
46 |
47 | # Ruby
48 | example/vendor/
49 |
50 | # node.js
51 | #
52 | node_modules/
53 | npm-debug.log
54 | yarn-debug.log
55 | yarn-error.log
56 |
57 | # BUCK
58 | buck-out/
59 | \.buckd/
60 | android/app/libs
61 | android/keystores/debug.keystore
62 |
63 | # Yarn
64 | .yarn/*
65 | !.yarn/patches
66 | !.yarn/plugins
67 | !.yarn/releases
68 | !.yarn/sdks
69 | !.yarn/versions
70 | .kotlin
71 |
72 | # Expo
73 | .expo/
74 |
75 | # generated by bob
76 | lib/
77 | tsconfig.tsbuildinfo
--------------------------------------------------------------------------------
/android/src/main/java/com/nitronetworkinfo/NitroNetworkInfoPackage.java:
--------------------------------------------------------------------------------
1 | package com.nitronetworkinfo;
2 |
3 | import android.util.Log;
4 | import androidx.annotation.Nullable;
5 | import androidx.annotation.NonNull;
6 |
7 | import com.facebook.react.bridge.NativeModule;
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 | import com.facebook.react.module.model.ReactModuleInfoProvider;
10 | import com.facebook.react.TurboReactPackage;
11 | import com.margelo.nitro.core.HybridObject;
12 | import com.margelo.nitro.nitronetworkinfo.NitroNetworkInfoOnLoad;
13 |
14 | import java.util.HashMap;
15 | import java.util.function.Supplier;
16 |
17 | public class NitroNetworkInfoPackage extends TurboReactPackage {
18 | @Nullable
19 | @Override
20 | public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactContext) {
21 | return null;
22 | }
23 |
24 | @NonNull
25 | @Override
26 | public ReactModuleInfoProvider getReactModuleInfoProvider() {
27 | return HashMap::new;
28 | }
29 |
30 | static {
31 | NitroNetworkInfoOnLoad.initializeNative();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/kotlin/com/margelo/nitro/nitronetworkinfo/NitroNetworkStatusInfo.kt:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkStatusInfo.kt
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | package com.margelo.nitro.nitronetworkinfo
9 |
10 | import androidx.annotation.Keep
11 | import com.facebook.proguard.annotations.DoNotStrip
12 |
13 |
14 | /**
15 | * Represents the JavaScript object/struct "NitroNetworkStatusInfo".
16 | */
17 | @DoNotStrip
18 | @Keep
19 | data class NitroNetworkStatusInfo(
20 | @DoNotStrip
21 | @Keep
22 | val isConnected: Boolean,
23 | @DoNotStrip
24 | @Keep
25 | val connectionType: ConnectionType
26 | ) {
27 | private companion object {
28 | /**
29 | * Constructor called from C++
30 | */
31 | @DoNotStrip
32 | @Keep
33 | @Suppress("unused")
34 | @JvmStatic
35 | private fun fromCpp(isConnected: Boolean, connectionType: ConnectionType): NitroNetworkStatusInfo {
36 | return NitroNetworkStatusInfo(isConnected, connectionType)
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/example/ios/NitroNetworkInfoExample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ios-marketing",
45 | "scale" : "1x",
46 | "size" : "1024x1024"
47 | }
48 | ],
49 | "info" : {
50 | "author" : "xcode",
51 | "version" : 1
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/NitroNetworkInfoAutolinking.swift:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkInfoAutolinking.swift
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | public final class NitroNetworkInfoAutolinking {
9 | public typealias bridge = margelo.nitro.nitronetworkinfo.bridge.swift
10 |
11 | /**
12 | * Creates an instance of a Swift class that implements `HybridNitroNetworkInfoSpec`,
13 | * and wraps it in a Swift class that can directly interop with C++ (`HybridNitroNetworkInfoSpec_cxx`)
14 | *
15 | * This is generated by Nitrogen and will initialize the class specified
16 | * in the `"autolinking"` property of `nitro.json` (in this case, `HybridNitroNetworkInfo`).
17 | */
18 | public static func createNitroNetworkInfo() -> bridge.std__shared_ptr_HybridNitroNetworkInfoSpec_ {
19 | let hybridObject = HybridNitroNetworkInfo()
20 | return { () -> bridge.std__shared_ptr_HybridNitroNetworkInfoSpec_ in
21 | let __cxxWrapped = hybridObject.getCxxWrapper()
22 | return __cxxWrapped.getCxxPart()
23 | }()
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/example/ios/NitroNetworkInfoExample/PrivacyInfo.xcprivacy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPrivacyAccessedAPITypes
6 |
7 |
8 | NSPrivacyAccessedAPIType
9 | NSPrivacyAccessedAPICategoryFileTimestamp
10 | NSPrivacyAccessedAPITypeReasons
11 |
12 | C617.1
13 |
14 |
15 |
16 | NSPrivacyAccessedAPIType
17 | NSPrivacyAccessedAPICategoryUserDefaults
18 | NSPrivacyAccessedAPITypeReasons
19 |
20 | CA92.1
21 |
22 |
23 |
24 | NSPrivacyAccessedAPIType
25 | NSPrivacyAccessedAPICategorySystemBootTime
26 | NSPrivacyAccessedAPITypeReasons
27 |
28 | 35F9.1
29 |
30 |
31 |
32 | NSPrivacyCollectedDataTypes
33 |
34 | NSPrivacyTracking
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
14 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | enable-beta-ecosystems: true
3 | updates:
4 | - package-ecosystem: 'github-actions'
5 | directory: '/'
6 | schedule:
7 | interval: 'daily'
8 | labels:
9 | - 'dependencies'
10 |
11 | - package-ecosystem: 'gradle'
12 | directories:
13 | - '/android/'
14 | - '/example/android/'
15 | schedule:
16 | interval: 'daily'
17 | labels:
18 | - 'nitro-core'
19 | - 'nitrogen'
20 | - 'dependencies'
21 | - 'kotlin'
22 |
23 | - package-ecosystem: 'bundler'
24 | directory: '/example/'
25 | schedule:
26 | interval: 'daily'
27 | labels:
28 | - 'dependencies'
29 | - 'ruby'
30 |
31 | - package-ecosystem: 'npm'
32 | directories:
33 | - '/example/'
34 | - '/'
35 | schedule:
36 | interval: 'daily'
37 | labels:
38 | - 'nitro-core'
39 | - 'dependencies'
40 | - 'typescript'
41 | - 'nitrogen'
42 |
43 | groups:
44 | react-native-cli:
45 | patterns:
46 | - '@react-native-community/cli*'
47 | babel:
48 | patterns:
49 | - '@babel/*'
50 | react-native:
51 | patterns:
52 | - '@react-native/*'
53 |
--------------------------------------------------------------------------------
/NitroNetworkInfo.podspec:
--------------------------------------------------------------------------------
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 = "NitroNetworkInfo"
7 | s.version = package["version"]
8 | s.summary = package["description"]
9 | s.homepage = package["homepage"]
10 | s.license = package["license"]
11 | s.authors = package["author"]
12 |
13 | s.platforms = { :ios => min_ios_version_supported, :visionos => 1.0 }
14 | s.source = { :git => "https://github.com/patrickkabwe/react-native-nitro-network-info.git", :tag => "#{s.version}" }
15 |
16 | s.source_files = [
17 | # Implementation (Swift)
18 | "ios/**/*.{swift}",
19 | # Autolinking/Registration (Objective-C++)
20 | "ios/**/*.{m,mm}",
21 | # Implementation (C++ objects)
22 | "cpp/**/*.{hpp,cpp}",
23 | ]
24 |
25 | s.pod_target_xcconfig = {
26 | # C++ compiler flags, mainly for folly.
27 | "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES"
28 | }
29 |
30 | load 'nitrogen/generated/ios/NitroNetworkInfo+autolinking.rb'
31 | add_nitrogen_files(s)
32 |
33 | s.dependency 'React-jsi'
34 | s.dependency 'React-callinvoker'
35 | install_modules_dependencies(s)
36 | end
37 |
--------------------------------------------------------------------------------
/example/App.tsx:
--------------------------------------------------------------------------------
1 | import React, {useEffect, useState} from 'react';
2 | import {StyleSheet, Text, View} from 'react-native';
3 | import NitroNetworkInfo, {
4 | type NitroNetworkStatusInfo,
5 | } from 'react-native-nitro-network-info';
6 |
7 | function App(): React.JSX.Element {
8 | const [networkInfo, setNetworkInfo] = useState(
9 | null,
10 | );
11 |
12 | useEffect(() => {
13 | const unsubscribe = NitroNetworkInfo.addListener(networkInfo => {
14 | setNetworkInfo(networkInfo);
15 | });
16 |
17 | return () => {
18 | unsubscribe();
19 | };
20 | }, []);
21 |
22 | return (
23 |
24 |
25 | {NitroNetworkInfo?.isConnected ? 'Connected' : 'Disconnected'}
26 |
27 |
28 | {NitroNetworkInfo?.connectionType || 'Unknown'}
29 |
30 | {JSON.stringify(networkInfo, null, 2)}
31 |
32 | );
33 | }
34 |
35 | const styles = StyleSheet.create({
36 | container: {
37 | flex: 1,
38 | justifyContent: 'center',
39 | alignItems: 'center',
40 | },
41 | text: {
42 | fontSize: 40,
43 | color: 'green',
44 | },
45 | });
46 |
47 | export default App;
48 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/swift/NitroNetworkStatusInfo.swift:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkStatusInfo.swift
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | import NitroModules
9 |
10 | /**
11 | * Represents an instance of `NitroNetworkStatusInfo`, backed by a C++ struct.
12 | */
13 | public typealias NitroNetworkStatusInfo = margelo.nitro.nitronetworkinfo.NitroNetworkStatusInfo
14 |
15 | public extension NitroNetworkStatusInfo {
16 | private typealias bridge = margelo.nitro.nitronetworkinfo.bridge.swift
17 |
18 | /**
19 | * Create a new instance of `NitroNetworkStatusInfo`.
20 | */
21 | init(isConnected: Bool, connectionType: ConnectionType) {
22 | self.init(isConnected, connectionType)
23 | }
24 |
25 | var isConnected: Bool {
26 | @inline(__always)
27 | get {
28 | return self.__isConnected
29 | }
30 | @inline(__always)
31 | set {
32 | self.__isConnected = newValue
33 | }
34 | }
35 |
36 | var connectionType: ConnectionType {
37 | @inline(__always)
38 | get {
39 | return self.__connectionType
40 | }
41 | @inline(__always)
42 | set {
43 | self.__connectionType = newValue
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/kotlin/com/margelo/nitro/nitronetworkinfo/NitroNetworkInfoOnLoad.kt:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkInfoOnLoad.kt
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | package com.margelo.nitro.nitronetworkinfo
9 |
10 | import android.util.Log
11 |
12 | internal class NitroNetworkInfoOnLoad {
13 | companion object {
14 | private const val TAG = "NitroNetworkInfoOnLoad"
15 | private var didLoad = false
16 | /**
17 | * Initializes the native part of "NitroNetworkInfo".
18 | * This method is idempotent and can be called more than once.
19 | */
20 | @JvmStatic
21 | fun initializeNative() {
22 | if (didLoad) return
23 | try {
24 | Log.i(TAG, "Loading NitroNetworkInfo C++ library...")
25 | System.loadLibrary("NitroNetworkInfo")
26 | Log.i(TAG, "Successfully loaded NitroNetworkInfo C++ library!")
27 | didLoad = true
28 | } catch (e: Error) {
29 | Log.e(TAG, "Failed to load NitroNetworkInfo C++ library! Is it properly installed and linked? " +
30 | "Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
31 | throw e
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/swift/ConnectionType.swift:
--------------------------------------------------------------------------------
1 | ///
2 | /// ConnectionType.swift
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | /**
9 | * Represents the JS union `ConnectionType`, backed by a C++ enum.
10 | */
11 | public typealias ConnectionType = margelo.nitro.nitronetworkinfo.ConnectionType
12 |
13 | public extension ConnectionType {
14 | /**
15 | * Get a ConnectionType for the given String value, or
16 | * return `nil` if the given value was invalid/unknown.
17 | */
18 | init?(fromString string: String) {
19 | switch string {
20 | case "unknown":
21 | self = .unknown
22 | case "ethernet":
23 | self = .ethernet
24 | case "wifi":
25 | self = .wifi
26 | case "cellular":
27 | self = .cellular
28 | default:
29 | return nil
30 | }
31 | }
32 |
33 | /**
34 | * Get the String value this ConnectionType represents.
35 | */
36 | var stringValue: String {
37 | switch self {
38 | case .unknown:
39 | return "unknown"
40 | case .ethernet:
41 | return "ethernet"
42 | case .wifi:
43 | return "wifi"
44 | case .cellular:
45 | return "cellular"
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-nitro-network-info-example",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "android": "react-native run-android",
7 | "ios": "react-native run-ios --simulator='iPhone 16'",
8 | "lint": "eslint .",
9 | "start": "react-native start --reset-cache",
10 | "test": "jest",
11 | "pod": "bundle install && bundle exec pod install --project-directory=ios"
12 | },
13 | "dependencies": {
14 | "react": "19.1.1",
15 | "react-native": "0.82.1",
16 | "react-native-nitro-modules": "^0.31.2"
17 | },
18 | "devDependencies": {
19 | "@babel/core": "^7.25.2",
20 | "@babel/preset-env": "^7.25.3",
21 | "@babel/runtime": "^7.25.0",
22 | "@react-native-community/cli": "20.0.0",
23 | "@react-native-community/cli-platform-android": "20.0.0",
24 | "@react-native-community/cli-platform-ios": "20.0.0",
25 | "@react-native/babel-preset": "0.82.1",
26 | "@react-native/eslint-config": "0.82.1",
27 | "@react-native/metro-config": "0.82.1",
28 | "@react-native/typescript-config": "0.82.1",
29 | "@types/jest": "^29.5.13",
30 | "babel-plugin-module-resolver": "^5.0.2"
31 | },
32 | "engines": {
33 | "node": ">=20"
34 | }
35 | }
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 | **/.xcode.env.local
24 |
25 | # Android/IntelliJ
26 | #
27 | build/
28 | .idea
29 | .gradle
30 | local.properties
31 | *.iml
32 | *.hprof
33 | .cxx/
34 | *.keystore
35 | !debug.keystore
36 | .kotlin/
37 |
38 | # node.js
39 | #
40 | node_modules/
41 | npm-debug.log
42 | yarn-error.log
43 |
44 | # fastlane
45 | #
46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47 | # screenshots whenever they are needed.
48 | # For more information about the recommended setup visit:
49 | # https://docs.fastlane.tools/best-practices/source-control/
50 |
51 | **/fastlane/report.xml
52 | **/fastlane/Preview.html
53 | **/fastlane/screenshots
54 | **/fastlane/test_output
55 |
56 | # Bundle artifact
57 | *.jsbundle
58 |
59 | # Ruby / CocoaPods
60 | **/Pods/
61 | /vendor/bundle/
62 |
63 | # Temporary files created by Metro to check the health of the file watcher
64 | .metro-health-check*
65 |
66 | # testing
67 | /coverage
68 |
69 | # Yarn
70 | .yarn/*
71 | !.yarn/patches
72 | !.yarn/plugins
73 | !.yarn/releases
74 | !.yarn/sdks
75 | !.yarn/versions
76 |
--------------------------------------------------------------------------------
/example/ios/NitroNetworkInfoExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import React
3 | import React_RCTAppDelegate
4 | import ReactAppDependencyProvider
5 |
6 | @main
7 | class AppDelegate: UIResponder, UIApplicationDelegate {
8 | var window: UIWindow?
9 |
10 | var reactNativeDelegate: ReactNativeDelegate?
11 | var reactNativeFactory: RCTReactNativeFactory?
12 |
13 | func application(
14 | _ application: UIApplication,
15 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
16 | ) -> Bool {
17 | let delegate = ReactNativeDelegate()
18 | let factory = RCTReactNativeFactory(delegate: delegate)
19 | delegate.dependencyProvider = RCTAppDependencyProvider()
20 |
21 | reactNativeDelegate = delegate
22 | reactNativeFactory = factory
23 |
24 | window = UIWindow(frame: UIScreen.main.bounds)
25 |
26 | factory.startReactNative(
27 | withModuleName: "NitroNetworkInfoExample",
28 | in: window,
29 | launchOptions: launchOptions
30 | )
31 |
32 | return true
33 | }
34 | }
35 |
36 | class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
37 | override func sourceURL(for bridge: RCTBridge) -> URL? {
38 | self.bundleURL()
39 | }
40 |
41 | override func bundleURL() -> URL? {
42 | #if DEBUG
43 | RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
44 | #else
45 | Bundle.main.url(forResource: "main", withExtension: "jsbundle")
46 | #endif
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/android/src/main/java/com/nitronetworkinfo/HybridNitroNetworkInfo.kt:
--------------------------------------------------------------------------------
1 | package com.nitronetworkinfo
2 |
3 | import com.margelo.nitro.NitroModules
4 | import com.margelo.nitro.nitronetworkinfo.ConnectionType
5 | import com.margelo.nitro.nitronetworkinfo.HybridNitroNetworkInfoSpec
6 | import com.margelo.nitro.nitronetworkinfo.NitroNetworkStatusInfo
7 |
8 |
9 | class HybridNitroNetworkInfo: HybridNitroNetworkInfoSpec(), NetworkInfoDelegate {
10 | private val context = NitroModules.applicationContext ?: throw Exception("Context is null")
11 | private val nitroNetworkInfoImpl = NitroNetworkInfoImpl(context, this)
12 | private var networkInfoStatusListener: ((NitroNetworkStatusInfo) -> Unit)? = null
13 |
14 | override val isConnected: Boolean
15 | get() = nitroNetworkInfoImpl.getIsConnection()
16 | override val connectionType: ConnectionType
17 | get() = nitroNetworkInfoImpl.getConnectionType()
18 |
19 | override fun addListener(listener: (NitroNetworkStatusInfo) -> Unit): () -> Unit {
20 | networkInfoStatusListener = listener
21 | networkInfoStatusListener?.invoke(NitroNetworkStatusInfo(isConnected, connectionType))
22 | return {
23 | networkInfoStatusListener = null
24 | }
25 | }
26 |
27 | override fun onNetworkInfoChanged(info: NitroNetworkStatusInfo) {
28 | networkInfoStatusListener?.invoke(info)
29 | }
30 |
31 | companion object {
32 | const val TAG = "NitroNetworkInfo"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/swift/Func_void.swift:
--------------------------------------------------------------------------------
1 | ///
2 | /// Func_void.swift
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | import NitroModules
9 |
10 |
11 | /**
12 | * Wraps a Swift `() -> Void` as a class.
13 | * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14 | */
15 | public final class Func_void {
16 | public typealias bridge = margelo.nitro.nitronetworkinfo.bridge.swift
17 |
18 | private let closure: () -> Void
19 |
20 | public init(_ closure: @escaping () -> Void) {
21 | self.closure = closure
22 | }
23 |
24 | @inline(__always)
25 | public func call() -> Void {
26 | self.closure()
27 | }
28 |
29 | /**
30 | * Casts this instance to a retained unsafe raw pointer.
31 | * This acquires one additional strong reference on the object!
32 | */
33 | @inline(__always)
34 | public func toUnsafe() -> UnsafeMutableRawPointer {
35 | return Unmanaged.passRetained(self).toOpaque()
36 | }
37 |
38 | /**
39 | * Casts an unsafe pointer to a `Func_void`.
40 | * The pointer has to be a retained opaque `Unmanaged`.
41 | * This removes one strong reference from the object!
42 | */
43 | @inline(__always)
44 | public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
45 | return Unmanaged.fromOpaque(pointer).takeRetainedValue()
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/.github/workflows/android-build.yml:
--------------------------------------------------------------------------------
1 | name: Build Android
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | paths:
8 | - '.github/workflows/android-build.yml'
9 | - 'example/android/**'
10 | - 'nitrogen/generated/shared/**'
11 | - 'nitrogen/generated/android/**'
12 | - 'cpp/**'
13 | - 'android/**'
14 | - '**/bun.lock'
15 | - '**/react-native.config.js'
16 | - '**/nitro.json'
17 | pull_request:
18 | paths:
19 | - '.github/workflows/android-build.yml'
20 | - 'example/android/**'
21 | - '**/nitrogen/generated/shared/**'
22 | - '**/nitrogen/generated/android/**'
23 | - 'cpp/**'
24 | - 'android/**'
25 | - '**/bun.lock'
26 | - '**/react-native.config.js'
27 | - '**/nitro.json'
28 |
29 | jobs:
30 | build_new:
31 | name: Build Android Example App (new architecture)
32 | runs-on: ubuntu-latest
33 | steps:
34 | - uses: actions/checkout@v6
35 | - uses: oven-sh/setup-bun@v2
36 |
37 | - name: Install npm dependencies (bun)
38 | run: bun install
39 |
40 | - name: Setup JDK 17
41 | uses: actions/setup-java@v5
42 | with:
43 | distribution: 'zulu'
44 | java-version: 17
45 | java-package: jdk
46 | cache: gradle
47 |
48 | - name: Run Gradle Build for example/android/
49 | working-directory: example/android
50 | run: ./gradlew assembleDebug --no-daemon --build-cache
51 |
52 | - name: Stop Gradle Daemon
53 | working-directory: example/android
54 | run: ./gradlew --stop
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | workflow_dispatch:
5 |
6 | permissions:
7 | contents: read
8 |
9 | concurrency:
10 | group: ${{ github.workflow }}-${{ github.ref }}
11 | cancel-in-progress: true
12 |
13 | jobs:
14 | release:
15 | name: Release
16 | runs-on: ubuntu-latest
17 | permissions:
18 | contents: write
19 | issues: write
20 | pull-requests: write
21 | id-token: write
22 | steps:
23 | - name: Checkout
24 | uses: actions/checkout@v6
25 | with:
26 | fetch-depth: 0
27 | - name: Setup Bun.js
28 | uses: oven-sh/setup-bun@v2
29 | with:
30 | bun-version: latest
31 | - name: Cache bun dependencies
32 | id: bun-cache
33 | uses: actions/cache@v4
34 | with:
35 | path: ~/.bun/install/cache
36 | key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
37 | restore-keys: |
38 | ${{ runner.os }}-bun-
39 |
40 | - name: Install npm dependencies (bun)
41 | run: bun install
42 |
43 | - name: Build lib
44 | run: bun run build
45 |
46 | - name: Release
47 | env:
48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
50 | NPM_CONFIG_PROVENANCE: true
51 | GIT_AUTHOR_NAME: ${{ github.actor }}
52 | GIT_AUTHOR_EMAIL: '${{ github.actor }}@users.noreply.github.com'
53 | GIT_COMMITTER_NAME: ${{ github.actor }}
54 | GIT_COMMITTER_EMAIL: '${{ github.actor }}@users.noreply.github.com'
55 | run: bun release
56 |
--------------------------------------------------------------------------------
/ios/HybridNitroNetworkInfo.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HybridNitroNetworkInfo.swift
3 | // NitroNetworkInfo
4 | //
5 | // Created by Patrick Kabwe on 04/05/2025.
6 | //
7 |
8 | import Foundation
9 |
10 | typealias NetworkInfoListener = (NitroNetworkStatusInfo) -> Void
11 |
12 | class HybridNitroNetworkInfo: HybridNitroNetworkInfoSpec {
13 | private var nitrogenNetworkInfoImpl = NitroNetworkInfoImpl()
14 | private var networkInfoStatusListener: ((NitroNetworkStatusInfo) -> Void)? = nil
15 |
16 | var isConnected: Bool {
17 | get { nitrogenNetworkInfoImpl.getIsConnected() }
18 | }
19 |
20 | var connectionType: ConnectionType {
21 | get { nitrogenNetworkInfoImpl.getConnectionType() }
22 | }
23 |
24 | func addListener(listener: @escaping (NitroNetworkStatusInfo) -> Void) throws -> () -> Void {
25 | networkInfoStatusListener = listener
26 |
27 | DispatchQueue.main.async { [unowned self] in
28 | self.networkInfoStatusListener?(
29 | NitroNetworkStatusInfo(
30 | isConnected: isConnected,
31 | connectionType: connectionType
32 | )
33 | )
34 |
35 | self.nitrogenNetworkInfoImpl.delegate = self
36 | }
37 |
38 | return { [weak self] in
39 | self?.networkInfoStatusListener = nil
40 | }
41 | }
42 |
43 | deinit {
44 | self.nitrogenNetworkInfoImpl.unregister()
45 | }
46 | }
47 |
48 | extension HybridNitroNetworkInfo: NitroNetworkInfoDelegate {
49 | func nitroNetworkInfoDidChange(_ nitroNetworkInfo: NitroNetworkStatusInfo) {
50 | self.networkInfoStatusListener?(nitroNetworkInfo)
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/release.config.js:
--------------------------------------------------------------------------------
1 | const rules = [
2 | { type: 'feat', release: 'minor', title: '✨ Features' },
3 | { type: 'fix', release: 'patch', title: '🐛 Bug Fixes' },
4 | { type: 'perf', release: 'patch', title: '💨 Performance Improvements' },
5 | { type: 'refactor', release: 'patch', title: '🔄 Code Refactors' },
6 | { type: 'docs', release: 'patch', title: '📚 Documentation' },
7 | { type: 'chore', release: 'patch', title: '🛠️ Other changes' },
8 | ]
9 |
10 | const sortMap = Object.fromEntries(
11 | rules.map((rule, index) => [rule.title, index])
12 | )
13 |
14 | /**
15 | * @type {import('semantic-release').GlobalConfig}
16 | */
17 | module.exports = {
18 | branches: ['main', { name: 'next', prerelease: 'next' }],
19 | plugins: [
20 | [
21 | '@semantic-release/commit-analyzer',
22 | {
23 | preset: 'conventionalcommits',
24 | releaseRules: [
25 | { breaking: true, release: 'major' },
26 | { revert: true, release: 'patch' },
27 | ].concat(rules.map(({ type, release }) => ({ type, release }))),
28 | },
29 | ],
30 | [
31 | '@semantic-release/release-notes-generator',
32 | {
33 | preset: 'conventionalcommits',
34 | presetConfig: {
35 | types: rules.map(({ type, title }) => ({ type, section: title })),
36 | },
37 | writerOpts: {
38 | commitGroupsSort: (a, z) => sortMap[a.title] - sortMap[z.title],
39 | },
40 | },
41 | ],
42 | [
43 | '@semantic-release/changelog',
44 | {
45 | changelogFile: 'CHANGELOG.md',
46 | },
47 | ],
48 | '@semantic-release/npm',
49 | '@semantic-release/github',
50 | ['@semantic-release/git', { assets: ['package.json', 'CHANGELOG.md'] }],
51 | ],
52 | }
53 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/swift/Func_void_NitroNetworkStatusInfo.swift:
--------------------------------------------------------------------------------
1 | ///
2 | /// Func_void_NitroNetworkStatusInfo.swift
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | import NitroModules
9 |
10 |
11 | /**
12 | * Wraps a Swift `(_ networkInfo: NitroNetworkStatusInfo) -> Void` as a class.
13 | * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14 | */
15 | public final class Func_void_NitroNetworkStatusInfo {
16 | public typealias bridge = margelo.nitro.nitronetworkinfo.bridge.swift
17 |
18 | private let closure: (_ networkInfo: NitroNetworkStatusInfo) -> Void
19 |
20 | public init(_ closure: @escaping (_ networkInfo: NitroNetworkStatusInfo) -> Void) {
21 | self.closure = closure
22 | }
23 |
24 | @inline(__always)
25 | public func call(networkInfo: NitroNetworkStatusInfo) -> Void {
26 | self.closure(networkInfo)
27 | }
28 |
29 | /**
30 | * Casts this instance to a retained unsafe raw pointer.
31 | * This acquires one additional strong reference on the object!
32 | */
33 | @inline(__always)
34 | public func toUnsafe() -> UnsafeMutableRawPointer {
35 | return Unmanaged.passRetained(self).toOpaque()
36 | }
37 |
38 | /**
39 | * Casts an unsafe pointer to a `Func_void_NitroNetworkStatusInfo`.
40 | * The pointer has to be a retained opaque `Unmanaged`.
41 | * This removes one strong reference from the object!
42 | */
43 | @inline(__always)
44 | public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_NitroNetworkStatusInfo {
45 | return Unmanaged.fromOpaque(pointer).takeRetainedValue()
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/example/ios/NitroNetworkInfoExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CADisableMinimumFrameDurationOnPhone
6 |
7 | CFBundleDevelopmentRegion
8 | en
9 | CFBundleDisplayName
10 | NitroNetworkInfoExample
11 | CFBundleExecutable
12 | $(EXECUTABLE_NAME)
13 | CFBundleIdentifier
14 | $(PRODUCT_BUNDLE_IDENTIFIER)
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | $(PRODUCT_NAME)
19 | CFBundlePackageType
20 | APPL
21 | CFBundleShortVersionString
22 | $(MARKETING_VERSION)
23 | CFBundleSignature
24 | ????
25 | CFBundleVersion
26 | $(CURRENT_PROJECT_VERSION)
27 | LSRequiresIPhoneOS
28 |
29 | NSAppTransportSecurity
30 |
31 | NSAllowsArbitraryLoads
32 |
33 | NSAllowsLocalNetworking
34 |
35 |
36 | NSLocationWhenInUseUsageDescription
37 |
38 | RCTNewArchEnabled
39 |
40 | UILaunchStoryboardName
41 | LaunchScreen
42 | UIRequiredDeviceCapabilities
43 |
44 | arm64
45 |
46 | UISupportedInterfaceOrientations
47 |
48 | UIInterfaceOrientationPortrait
49 | UIInterfaceOrientationLandscapeLeft
50 | UIInterfaceOrientationLandscapeRight
51 |
52 | UIViewControllerBasedStatusBarAppearance
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/swift/HybridNitroNetworkInfoSpec.swift:
--------------------------------------------------------------------------------
1 | ///
2 | /// HybridNitroNetworkInfoSpec.swift
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | import Foundation
9 | import NitroModules
10 |
11 | /// See ``HybridNitroNetworkInfoSpec``
12 | public protocol HybridNitroNetworkInfoSpec_protocol: HybridObject {
13 | // Properties
14 | var isConnected: Bool { get }
15 | var connectionType: ConnectionType { get }
16 |
17 | // Methods
18 | func addListener(listener: @escaping (_ networkInfo: NitroNetworkStatusInfo) -> Void) throws -> () -> Void
19 | }
20 |
21 | /// See ``HybridNitroNetworkInfoSpec``
22 | open class HybridNitroNetworkInfoSpec_base {
23 | private weak var cxxWrapper: HybridNitroNetworkInfoSpec_cxx? = nil
24 | public init() { }
25 | public func getCxxWrapper() -> HybridNitroNetworkInfoSpec_cxx {
26 | #if DEBUG
27 | guard self is HybridNitroNetworkInfoSpec else {
28 | fatalError("`self` is not a `HybridNitroNetworkInfoSpec`! Did you accidentally inherit from `HybridNitroNetworkInfoSpec_base` instead of `HybridNitroNetworkInfoSpec`?")
29 | }
30 | #endif
31 | if let cxxWrapper = self.cxxWrapper {
32 | return cxxWrapper
33 | } else {
34 | let cxxWrapper = HybridNitroNetworkInfoSpec_cxx(self as! HybridNitroNetworkInfoSpec)
35 | self.cxxWrapper = cxxWrapper
36 | return cxxWrapper
37 | }
38 | }
39 | }
40 |
41 | /**
42 | * A Swift base-protocol representing the NitroNetworkInfo HybridObject.
43 | * Implement this protocol to create Swift-based instances of NitroNetworkInfo.
44 | * ```swift
45 | * class HybridNitroNetworkInfo : HybridNitroNetworkInfoSpec {
46 | * // ...
47 | * }
48 | * ```
49 | */
50 | public typealias HybridNitroNetworkInfoSpec = HybridNitroNetworkInfoSpec_protocol & HybridNitroNetworkInfoSpec_base
51 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/NitroNetworkInfoOnLoad.cpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkInfoOnLoad.cpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #ifndef BUILDING_NITRONETWORKINFO_WITH_GENERATED_CMAKE_PROJECT
9 | #error NitroNetworkInfoOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10 | #endif
11 |
12 | #include "NitroNetworkInfoOnLoad.hpp"
13 |
14 | #include
15 | #include
16 | #include
17 |
18 | #include "JHybridNitroNetworkInfoSpec.hpp"
19 | #include "JFunc_void.hpp"
20 | #include "JFunc_void_NitroNetworkStatusInfo.hpp"
21 | #include
22 |
23 | namespace margelo::nitro::nitronetworkinfo {
24 |
25 | int initialize(JavaVM* vm) {
26 | using namespace margelo::nitro;
27 | using namespace margelo::nitro::nitronetworkinfo;
28 | using namespace facebook;
29 |
30 | return facebook::jni::initialize(vm, [] {
31 | // Register native JNI methods
32 | margelo::nitro::nitronetworkinfo::JHybridNitroNetworkInfoSpec::registerNatives();
33 | margelo::nitro::nitronetworkinfo::JFunc_void_cxx::registerNatives();
34 | margelo::nitro::nitronetworkinfo::JFunc_void_NitroNetworkStatusInfo_cxx::registerNatives();
35 |
36 | // Register Nitro Hybrid Objects
37 | HybridObjectRegistry::registerHybridObjectConstructor(
38 | "NitroNetworkInfo",
39 | []() -> std::shared_ptr {
40 | static DefaultConstructableObject object("com/nitronetworkinfo/HybridNitroNetworkInfo");
41 | auto instance = object.create();
42 | return instance->cthis()->shared();
43 | }
44 | );
45 | });
46 | }
47 |
48 | } // namespace margelo::nitro::nitronetworkinfo
49 |
--------------------------------------------------------------------------------
/ios/NitroNetworkInfoImpl.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NitroNetworkInfoImpl.swift
3 | // NitroNetworkInfo
4 | //
5 | // Created by Patrick Kabwe on 04/05/2025.
6 | //
7 |
8 | import Foundation
9 | import Network
10 |
11 | protocol NitroNetworkInfoDelegate: AnyObject {
12 | func nitroNetworkInfoDidChange(_ nitroNetworkInfo: NitroNetworkStatusInfo)
13 | }
14 |
15 | class NitroNetworkInfoImpl {
16 | var nwPathMonitor = NWPathMonitor()
17 | weak var delegate: NitroNetworkInfoDelegate?
18 | var nwPath: NWPath?
19 | var isConnected: Bool = false {
20 | didSet {
21 | #if DEBUG
22 | print("isConnected: \(isConnected)")
23 | #endif
24 | }
25 | }
26 |
27 | init() {
28 | nwPathMonitor.start(queue: .global(qos: .background))
29 | nwPathMonitor.pathUpdateHandler = { path in
30 | DispatchQueue.main.async { [weak self] in
31 | guard let self else { return }
32 | let ni = NitroNetworkStatusInfo(
33 | isConnected: path.status == .satisfied,
34 | connectionType: self.getConnectionType()
35 | )
36 | self.isConnected = path.status == .satisfied
37 | self.nwPath = path
38 | self.delegate?.nitroNetworkInfoDidChange(ni)
39 | }
40 | }
41 | }
42 |
43 | func getIsConnected() -> Bool {
44 | return isConnected
45 | }
46 |
47 | func getConnectionType() -> ConnectionType {
48 | switch true {
49 | case nwPath?.usesInterfaceType(.cellular):
50 | return .cellular
51 | case nwPath?.usesInterfaceType(.wifi):
52 | return .wifi
53 | case nwPath?.usesInterfaceType(.wiredEthernet):
54 | return .ethernet
55 | default:
56 | return .unknown
57 | }
58 | }
59 |
60 | func unregister() {
61 | self.delegate = nil
62 | nwPathMonitor.cancel()
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/kotlin/com/margelo/nitro/nitronetworkinfo/HybridNitroNetworkInfoSpec.kt:
--------------------------------------------------------------------------------
1 | ///
2 | /// HybridNitroNetworkInfoSpec.kt
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | package com.margelo.nitro.nitronetworkinfo
9 |
10 | import androidx.annotation.Keep
11 | import com.facebook.jni.HybridData
12 | import com.facebook.proguard.annotations.DoNotStrip
13 | import com.margelo.nitro.core.HybridObject
14 |
15 | /**
16 | * A Kotlin class representing the NitroNetworkInfo HybridObject.
17 | * Implement this abstract class to create Kotlin-based instances of NitroNetworkInfo.
18 | */
19 | @DoNotStrip
20 | @Keep
21 | @Suppress(
22 | "KotlinJniMissingFunction", "unused",
23 | "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24 | "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25 | )
26 | abstract class HybridNitroNetworkInfoSpec: HybridObject() {
27 | @DoNotStrip
28 | private var mHybridData: HybridData = initHybrid()
29 |
30 | init {
31 | super.updateNative(mHybridData)
32 | }
33 |
34 | override fun updateNative(hybridData: HybridData) {
35 | mHybridData = hybridData
36 | super.updateNative(hybridData)
37 | }
38 |
39 | // Properties
40 | @get:DoNotStrip
41 | @get:Keep
42 | abstract val isConnected: Boolean
43 |
44 | @get:DoNotStrip
45 | @get:Keep
46 | abstract val connectionType: ConnectionType
47 |
48 | // Methods
49 | abstract fun addListener(listener: (networkInfo: NitroNetworkStatusInfo) -> Unit): () -> Unit
50 |
51 | @DoNotStrip
52 | @Keep
53 | private fun addListener_cxx(listener: Func_void_NitroNetworkStatusInfo): Func_void {
54 | val __result = addListener(listener)
55 | return Func_void_java(__result)
56 | }
57 |
58 | private external fun initHybrid(): HybridData
59 |
60 | companion object {
61 | protected const val TAG = "HybridNitroNetworkInfoSpec"
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/rn_edit_text_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
22 |
23 |
24 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 |
25 | # Use this property to specify which architecture you want to build.
26 | # You can also override it from the CLI using
27 | # ./gradlew -PreactNativeArchitectures=x86_64
28 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
29 |
30 | # Use this property to enable support to the new architecture.
31 | # This will allow you to use TurboModules and the Fabric render in
32 | # your application. You should enable this flag either if you want
33 | # to write custom TurboModules/Fabric components OR use libraries that
34 | # are providing them.
35 | newArchEnabled=true
36 |
37 | # Use this property to enable or disable the Hermes JS engine.
38 | # If set to false, you will be using JSC instead.
39 | hermesEnabled=true
40 |
41 | # Use this property to enable edge-to-edge display support.
42 | # This allows your app to draw behind system bars for an immersive UI.
43 | # Note: Only works with ReactActivity and should not be used with custom Activity.
44 | edgeToEdgeEnabled=false
45 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/c++/JFunc_void.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// JFunc_void.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | #include
11 | #include
12 |
13 | #include
14 |
15 | namespace margelo::nitro::nitronetworkinfo {
16 |
17 | using namespace facebook;
18 |
19 | /**
20 | * Represents the Java/Kotlin callback `() -> Unit`.
21 | * This can be passed around between C++ and Java/Kotlin.
22 | */
23 | struct JFunc_void: public jni::JavaClass {
24 | public:
25 | static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitronetworkinfo/Func_void;";
26 |
27 | public:
28 | /**
29 | * Invokes the function this `JFunc_void` instance holds through JNI.
30 | */
31 | void invoke() const {
32 | static const auto method = javaClassStatic()->getMethod("invoke");
33 | method(self());
34 | }
35 | };
36 |
37 | /**
38 | * An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`)
39 | */
40 | struct JFunc_void_cxx final: public jni::HybridClass {
41 | public:
42 | static jni::local_ref fromCpp(const std::function& func) {
43 | return JFunc_void_cxx::newObjectCxxArgs(func);
44 | }
45 |
46 | public:
47 | /**
48 | * Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds.
49 | */
50 | void invoke_cxx() {
51 | _func();
52 | }
53 |
54 | public:
55 | [[nodiscard]]
56 | inline const std::function& getFunction() const {
57 | return _func;
58 | }
59 |
60 | public:
61 | static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitronetworkinfo/Func_void_cxx;";
62 | static void registerNatives() {
63 | registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)});
64 | }
65 |
66 | private:
67 | explicit JFunc_void_cxx(const std::function& func): _func(func) { }
68 |
69 | private:
70 | friend HybridBase;
71 | std::function _func;
72 | };
73 |
74 | } // namespace margelo::nitro::nitronetworkinfo
75 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/NitroNetworkInfo+autolinking.rb:
--------------------------------------------------------------------------------
1 | #
2 | # NitroNetworkInfo+autolinking.rb
3 | # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | # https://github.com/mrousavy/nitro
5 | # Copyright © 2025 Marc Rousavy @ Margelo
6 | #
7 |
8 | # This is a Ruby script that adds all files generated by Nitrogen
9 | # to the given podspec.
10 | #
11 | # To use it, add this to your .podspec:
12 | # ```ruby
13 | # Pod::Spec.new do |spec|
14 | # # ...
15 | #
16 | # # Add all files generated by Nitrogen
17 | # load 'nitrogen/generated/ios/NitroNetworkInfo+autolinking.rb'
18 | # add_nitrogen_files(spec)
19 | # end
20 | # ```
21 |
22 | def add_nitrogen_files(spec)
23 | Pod::UI.puts "[NitroModules] 🔥 NitroNetworkInfo is boosted by nitro!"
24 |
25 | spec.dependency "NitroModules"
26 |
27 | current_source_files = Array(spec.attributes_hash['source_files'])
28 | spec.source_files = current_source_files + [
29 | # Generated cross-platform specs
30 | "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
31 | # Generated bridges for the cross-platform specs
32 | "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
33 | ]
34 |
35 | current_public_header_files = Array(spec.attributes_hash['public_header_files'])
36 | spec.public_header_files = current_public_header_files + [
37 | # Generated specs
38 | "nitrogen/generated/shared/**/*.{h,hpp}",
39 | # Swift to C++ bridging helpers
40 | "nitrogen/generated/ios/NitroNetworkInfo-Swift-Cxx-Bridge.hpp"
41 | ]
42 |
43 | current_private_header_files = Array(spec.attributes_hash['private_header_files'])
44 | spec.private_header_files = current_private_header_files + [
45 | # iOS specific specs
46 | "nitrogen/generated/ios/c++/**/*.{h,hpp}",
47 | # Views are framework-specific and should be private
48 | "nitrogen/generated/shared/**/views/**/*"
49 | ]
50 |
51 | current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
52 | spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
53 | # Use C++ 20
54 | "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
55 | # Enables C++ <-> Swift interop (by default it's only C)
56 | "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57 | # Enables stricter modular headers
58 | "DEFINES_MODULE" => "YES",
59 | })
60 | end
61 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/c++/JHybridNitroNetworkInfoSpec.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// HybridNitroNetworkInfoSpec.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | #include
11 | #include
12 | #include "HybridNitroNetworkInfoSpec.hpp"
13 |
14 |
15 |
16 |
17 | namespace margelo::nitro::nitronetworkinfo {
18 |
19 | using namespace facebook;
20 |
21 | class JHybridNitroNetworkInfoSpec: public jni::HybridClass,
22 | public virtual HybridNitroNetworkInfoSpec {
23 | public:
24 | static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitronetworkinfo/HybridNitroNetworkInfoSpec;";
25 | static jni::local_ref initHybrid(jni::alias_ref jThis);
26 | static void registerNatives();
27 |
28 | protected:
29 | // C++ constructor (called from Java via `initHybrid()`)
30 | explicit JHybridNitroNetworkInfoSpec(jni::alias_ref jThis) :
31 | HybridObject(HybridNitroNetworkInfoSpec::TAG),
32 | HybridBase(jThis),
33 | _javaPart(jni::make_global(jThis)) {}
34 |
35 | public:
36 | ~JHybridNitroNetworkInfoSpec() override {
37 | // Hermes GC can destroy JS objects on a non-JNI Thread.
38 | jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
39 | }
40 |
41 | public:
42 | size_t getExternalMemorySize() noexcept override;
43 | void dispose() noexcept override;
44 |
45 | public:
46 | inline const jni::global_ref& getJavaPart() const noexcept {
47 | return _javaPart;
48 | }
49 |
50 | public:
51 | // Properties
52 | bool getIsConnected() override;
53 | ConnectionType getConnectionType() override;
54 |
55 | public:
56 | // Methods
57 | std::function addListener(const std::function& listener) override;
58 |
59 | private:
60 | friend HybridBase;
61 | using HybridBase::HybridBase;
62 | jni::global_ref _javaPart;
63 | };
64 |
65 | } // namespace margelo::nitro::nitronetworkinfo
66 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/NitroNetworkInfo-Swift-Cxx-Umbrella.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkInfo-Swift-Cxx-Umbrella.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | // Forward declarations of C++ defined types
11 | // Forward declaration of `ConnectionType` to properly resolve imports.
12 | namespace margelo::nitro::nitronetworkinfo { enum class ConnectionType; }
13 | // Forward declaration of `HybridNitroNetworkInfoSpec` to properly resolve imports.
14 | namespace margelo::nitro::nitronetworkinfo { class HybridNitroNetworkInfoSpec; }
15 | // Forward declaration of `NitroNetworkStatusInfo` to properly resolve imports.
16 | namespace margelo::nitro::nitronetworkinfo { struct NitroNetworkStatusInfo; }
17 |
18 | // Include C++ defined types
19 | #include "ConnectionType.hpp"
20 | #include "HybridNitroNetworkInfoSpec.hpp"
21 | #include "NitroNetworkStatusInfo.hpp"
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | // C++ helpers for Swift
28 | #include "NitroNetworkInfo-Swift-Cxx-Bridge.hpp"
29 |
30 | // Common C++ types used in Swift
31 | #include
32 | #include
33 | #include
34 | #include
35 |
36 | // Forward declarations of Swift defined types
37 | // Forward declaration of `HybridNitroNetworkInfoSpec_cxx` to properly resolve imports.
38 | namespace NitroNetworkInfo { class HybridNitroNetworkInfoSpec_cxx; }
39 |
40 | // Include Swift defined types
41 | #if __has_include("NitroNetworkInfo-Swift.h")
42 | // This header is generated by Xcode/Swift on every app build.
43 | // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroNetworkInfo".
44 | #include "NitroNetworkInfo-Swift.h"
45 | // Same as above, but used when building with frameworks (`use_frameworks`)
46 | #elif __has_include()
47 | #include
48 | #else
49 | #error NitroNetworkInfo's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroNetworkInfo", and try building the app first.
50 | #endif
51 |
--------------------------------------------------------------------------------
/nitrogen/generated/shared/c++/HybridNitroNetworkInfoSpec.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// HybridNitroNetworkInfoSpec.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | #if __has_include()
11 | #include
12 | #else
13 | #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14 | #endif
15 |
16 | // Forward declaration of `ConnectionType` to properly resolve imports.
17 | namespace margelo::nitro::nitronetworkinfo { enum class ConnectionType; }
18 | // Forward declaration of `NitroNetworkStatusInfo` to properly resolve imports.
19 | namespace margelo::nitro::nitronetworkinfo { struct NitroNetworkStatusInfo; }
20 |
21 | #include "ConnectionType.hpp"
22 | #include
23 | #include "NitroNetworkStatusInfo.hpp"
24 |
25 | namespace margelo::nitro::nitronetworkinfo {
26 |
27 | using namespace margelo::nitro;
28 |
29 | /**
30 | * An abstract base class for `NitroNetworkInfo`
31 | * Inherit this class to create instances of `HybridNitroNetworkInfoSpec` in C++.
32 | * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
33 | * @example
34 | * ```cpp
35 | * class HybridNitroNetworkInfo: public HybridNitroNetworkInfoSpec {
36 | * public:
37 | * HybridNitroNetworkInfo(...): HybridObject(TAG) { ... }
38 | * // ...
39 | * };
40 | * ```
41 | */
42 | class HybridNitroNetworkInfoSpec: public virtual HybridObject {
43 | public:
44 | // Constructor
45 | explicit HybridNitroNetworkInfoSpec(): HybridObject(TAG) { }
46 |
47 | // Destructor
48 | ~HybridNitroNetworkInfoSpec() override = default;
49 |
50 | public:
51 | // Properties
52 | virtual bool getIsConnected() = 0;
53 | virtual ConnectionType getConnectionType() = 0;
54 |
55 | public:
56 | // Methods
57 | virtual std::function addListener(const std::function& listener) = 0;
58 |
59 | protected:
60 | // Hybrid Setup
61 | void loadHybridMethods() override;
62 |
63 | protected:
64 | // Tag for logging
65 | static constexpr auto TAG = "NitroNetworkInfo";
66 | };
67 |
68 | } // namespace margelo::nitro::nitronetworkinfo
69 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/kotlin/com/margelo/nitro/nitronetworkinfo/Func_void.kt:
--------------------------------------------------------------------------------
1 | ///
2 | /// Func_void.kt
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | package com.margelo.nitro.nitronetworkinfo
9 |
10 | import androidx.annotation.Keep
11 | import com.facebook.jni.HybridData
12 | import com.facebook.proguard.annotations.DoNotStrip
13 | import dalvik.annotation.optimization.FastNative
14 |
15 |
16 | /**
17 | * Represents the JavaScript callback `() => void`.
18 | * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19 | * or in Kotlin/Java (in which case it is a native callback).
20 | */
21 | @DoNotStrip
22 | @Keep
23 | @Suppress("ClassName", "RedundantUnitReturnType")
24 | fun interface Func_void: () -> Unit {
25 | /**
26 | * Call the given JS callback.
27 | * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28 | */
29 | @DoNotStrip
30 | @Keep
31 | override fun invoke(): Unit
32 | }
33 |
34 | /**
35 | * Represents the JavaScript callback `() => void`.
36 | * This is implemented in C++, via a `std::function<...>`.
37 | * The callback might be coming from JS.
38 | */
39 | @DoNotStrip
40 | @Keep
41 | @Suppress(
42 | "KotlinJniMissingFunction", "unused",
43 | "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44 | "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45 | )
46 | class Func_void_cxx: Func_void {
47 | @DoNotStrip
48 | @Keep
49 | private val mHybridData: HybridData
50 |
51 | @DoNotStrip
52 | @Keep
53 | private constructor(hybridData: HybridData) {
54 | mHybridData = hybridData
55 | }
56 |
57 | @DoNotStrip
58 | @Keep
59 | override fun invoke(): Unit
60 | = invoke_cxx()
61 |
62 | @FastNative
63 | private external fun invoke_cxx(): Unit
64 | }
65 |
66 | /**
67 | * Represents the JavaScript callback `() => void`.
68 | * This is implemented in Java/Kotlin, via a `() -> Unit`.
69 | * The callback is always coming from native.
70 | */
71 | @DoNotStrip
72 | @Keep
73 | @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74 | class Func_void_java(private val function: () -> Unit): Func_void {
75 | @DoNotStrip
76 | @Keep
77 | override fun invoke(): Unit {
78 | return this.function()
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/c++/JNitroNetworkStatusInfo.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// JNitroNetworkStatusInfo.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | #include
11 | #include "NitroNetworkStatusInfo.hpp"
12 |
13 | #include "ConnectionType.hpp"
14 | #include "JConnectionType.hpp"
15 |
16 | namespace margelo::nitro::nitronetworkinfo {
17 |
18 | using namespace facebook;
19 |
20 | /**
21 | * The C++ JNI bridge between the C++ struct "NitroNetworkStatusInfo" and the the Kotlin data class "NitroNetworkStatusInfo".
22 | */
23 | struct JNitroNetworkStatusInfo final: public jni::JavaClass {
24 | public:
25 | static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitronetworkinfo/NitroNetworkStatusInfo;";
26 |
27 | public:
28 | /**
29 | * Convert this Java/Kotlin-based struct to the C++ struct NitroNetworkStatusInfo by copying all values to C++.
30 | */
31 | [[maybe_unused]]
32 | [[nodiscard]]
33 | NitroNetworkStatusInfo toCpp() const {
34 | static const auto clazz = javaClassStatic();
35 | static const auto fieldIsConnected = clazz->getField("isConnected");
36 | jboolean isConnected = this->getFieldValue(fieldIsConnected);
37 | static const auto fieldConnectionType = clazz->getField("connectionType");
38 | jni::local_ref connectionType = this->getFieldValue(fieldConnectionType);
39 | return NitroNetworkStatusInfo(
40 | static_cast(isConnected),
41 | connectionType->toCpp()
42 | );
43 | }
44 |
45 | public:
46 | /**
47 | * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
48 | */
49 | [[maybe_unused]]
50 | static jni::local_ref fromCpp(const NitroNetworkStatusInfo& value) {
51 | using JSignature = JNitroNetworkStatusInfo(jboolean, jni::alias_ref);
52 | static const auto clazz = javaClassStatic();
53 | static const auto create = clazz->getStaticMethod("fromCpp");
54 | return create(
55 | clazz,
56 | value.isConnected,
57 | JConnectionType::fromCpp(value.connectionType)
58 | );
59 | }
60 | };
61 |
62 | } // namespace margelo::nitro::nitronetworkinfo
63 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/c++/JConnectionType.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// JConnectionType.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | #include
11 | #include "ConnectionType.hpp"
12 |
13 | namespace margelo::nitro::nitronetworkinfo {
14 |
15 | using namespace facebook;
16 |
17 | /**
18 | * The C++ JNI bridge between the C++ enum "ConnectionType" and the the Kotlin enum "ConnectionType".
19 | */
20 | struct JConnectionType final: public jni::JavaClass {
21 | public:
22 | static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitronetworkinfo/ConnectionType;";
23 |
24 | public:
25 | /**
26 | * Convert this Java/Kotlin-based enum to the C++ enum ConnectionType.
27 | */
28 | [[maybe_unused]]
29 | [[nodiscard]]
30 | ConnectionType toCpp() const {
31 | static const auto clazz = javaClassStatic();
32 | static const auto fieldOrdinal = clazz->getField("value");
33 | int ordinal = this->getFieldValue(fieldOrdinal);
34 | return static_cast(ordinal);
35 | }
36 |
37 | public:
38 | /**
39 | * Create a Java/Kotlin-based enum with the given C++ enum's value.
40 | */
41 | [[maybe_unused]]
42 | static jni::alias_ref fromCpp(ConnectionType value) {
43 | static const auto clazz = javaClassStatic();
44 | static const auto fieldUNKNOWN = clazz->getStaticField("UNKNOWN");
45 | static const auto fieldETHERNET = clazz->getStaticField("ETHERNET");
46 | static const auto fieldWIFI = clazz->getStaticField("WIFI");
47 | static const auto fieldCELLULAR = clazz->getStaticField("CELLULAR");
48 |
49 | switch (value) {
50 | case ConnectionType::UNKNOWN:
51 | return clazz->getStaticFieldValue(fieldUNKNOWN);
52 | case ConnectionType::ETHERNET:
53 | return clazz->getStaticFieldValue(fieldETHERNET);
54 | case ConnectionType::WIFI:
55 | return clazz->getStaticFieldValue(fieldWIFI);
56 | case ConnectionType::CELLULAR:
57 | return clazz->getStaticFieldValue(fieldCELLULAR);
58 | default:
59 | std::string stringValue = std::to_string(static_cast(value));
60 | throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
61 | }
62 | }
63 | };
64 |
65 | } // namespace margelo::nitro::nitronetworkinfo
66 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/NitroNetworkInfo-Swift-Cxx-Bridge.cpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkInfo-Swift-Cxx-Bridge.cpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #include "NitroNetworkInfo-Swift-Cxx-Bridge.hpp"
9 |
10 | // Include C++ implementation defined types
11 | #include "HybridNitroNetworkInfoSpecSwift.hpp"
12 | #include "NitroNetworkInfo-Swift-Cxx-Umbrella.hpp"
13 |
14 | namespace margelo::nitro::nitronetworkinfo::bridge::swift {
15 |
16 | // pragma MARK: std::function
17 | Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
18 | auto swiftClosure = NitroNetworkInfo::Func_void::fromUnsafe(swiftClosureWrapper);
19 | return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
20 | swiftClosure.call();
21 | };
22 | }
23 |
24 | // pragma MARK: std::function
25 | Func_void_NitroNetworkStatusInfo create_Func_void_NitroNetworkStatusInfo(void* NON_NULL swiftClosureWrapper) noexcept {
26 | auto swiftClosure = NitroNetworkInfo::Func_void_NitroNetworkStatusInfo::fromUnsafe(swiftClosureWrapper);
27 | return [swiftClosure = std::move(swiftClosure)](const NitroNetworkStatusInfo& networkInfo) mutable -> void {
28 | swiftClosure.call(networkInfo);
29 | };
30 | }
31 |
32 | // pragma MARK: std::shared_ptr
33 | std::shared_ptr create_std__shared_ptr_HybridNitroNetworkInfoSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
34 | NitroNetworkInfo::HybridNitroNetworkInfoSpec_cxx swiftPart = NitroNetworkInfo::HybridNitroNetworkInfoSpec_cxx::fromUnsafe(swiftUnsafePointer);
35 | return std::make_shared(swiftPart);
36 | }
37 | void* NON_NULL get_std__shared_ptr_HybridNitroNetworkInfoSpec_(std__shared_ptr_HybridNitroNetworkInfoSpec_ cppType) {
38 | std::shared_ptr swiftWrapper = std::dynamic_pointer_cast(cppType);
39 | #ifdef NITRO_DEBUG
40 | if (swiftWrapper == nullptr) [[unlikely]] {
41 | throw std::runtime_error("Class \"HybridNitroNetworkInfoSpec\" is not implemented in Swift!");
42 | }
43 | #endif
44 | NitroNetworkInfo::HybridNitroNetworkInfoSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
45 | return swiftPart.toUnsafe();
46 | }
47 |
48 | } // namespace margelo::nitro::nitronetworkinfo::bridge::swift
49 |
--------------------------------------------------------------------------------
/.github/workflows/ios-build.yml:
--------------------------------------------------------------------------------
1 | name: Build iOS
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | paths:
8 | - '.github/workflows/ios-build.yml'
9 | - 'example/ios/**'
10 | - 'example/Gemfile'
11 | - 'example/Gemfile.lock'
12 | - '**/nitrogen/generated/shared/**'
13 | - '**/nitrogen/generated/ios/**'
14 | - 'cpp/**'
15 | - 'ios/**'
16 | - '**/Podfile.lock'
17 | - '**/bun.lock'
18 | - '**/*.podspec'
19 | - '**/react-native.config.js'
20 | - '**/nitro.json'
21 | pull_request:
22 | paths:
23 | - '.github/workflows/ios-build.yml'
24 | - 'example/ios/**'
25 | - 'example/Gemfile'
26 | - 'example/Gemfile.lock'
27 | - '**/nitrogen/generated/shared/**'
28 | - '**/nitrogen/generated/ios/**'
29 | - 'cpp/**'
30 | - 'ios/**'
31 | - '**/Podfile.lock'
32 | - '**/bun.lock'
33 | - '**/*.podspec'
34 | - '**/react-native.config.js'
35 | - '**/nitro.json'
36 |
37 | env:
38 | USE_CCACHE: 1
39 |
40 | jobs:
41 | build_new:
42 | name: Build iOS Example App (new architecture)
43 | runs-on: macOS-15
44 | steps:
45 | - uses: actions/checkout@v6
46 | - uses: oven-sh/setup-bun@v2
47 |
48 | - name: Setup Xcode
49 | uses: maxim-lobanov/setup-xcode@v1
50 | with:
51 | xcode-version: 16.4
52 |
53 | - name: Install npm dependencies (bun)
54 | run: bun install
55 |
56 | - name: Setup Ruby (bundle)
57 | uses: ruby/setup-ruby@v1
58 | with:
59 | ruby-version: 2.7.2
60 | bundler-cache: true
61 | working-directory: example/ios
62 |
63 | - name: Install xcpretty
64 | run: gem install xcpretty
65 |
66 | - name: Restore Pods cache
67 | uses: actions/cache@v4
68 | with:
69 | path: example/ios/Pods
70 | key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock') }}
71 | restore-keys: |
72 | ${{ runner.os }}-pods-
73 | - name: Install Pods
74 | working-directory: example/ios
75 | run: pod install
76 | - name: Build App
77 | working-directory: example/ios
78 | run: "set -o pipefail && xcodebuild \
79 | CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
80 | -derivedDataPath build -UseModernBuildSystem=YES \
81 | -workspace NitroNetworkInfoExample.xcworkspace \
82 | -scheme NitroNetworkInfoExample \
83 | -sdk iphonesimulator \
84 | -configuration Debug \
85 | -destination 'platform=iOS Simulator,name=iPhone 16' \
86 | build \
87 | CODE_SIGNING_ALLOWED=NO | xcpretty"
--------------------------------------------------------------------------------
/nitrogen/generated/android/kotlin/com/margelo/nitro/nitronetworkinfo/Func_void_NitroNetworkStatusInfo.kt:
--------------------------------------------------------------------------------
1 | ///
2 | /// Func_void_NitroNetworkStatusInfo.kt
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | package com.margelo.nitro.nitronetworkinfo
9 |
10 | import androidx.annotation.Keep
11 | import com.facebook.jni.HybridData
12 | import com.facebook.proguard.annotations.DoNotStrip
13 | import dalvik.annotation.optimization.FastNative
14 |
15 |
16 | /**
17 | * Represents the JavaScript callback `(networkInfo: struct) => void`.
18 | * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19 | * or in Kotlin/Java (in which case it is a native callback).
20 | */
21 | @DoNotStrip
22 | @Keep
23 | @Suppress("ClassName", "RedundantUnitReturnType")
24 | fun interface Func_void_NitroNetworkStatusInfo: (NitroNetworkStatusInfo) -> Unit {
25 | /**
26 | * Call the given JS callback.
27 | * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28 | */
29 | @DoNotStrip
30 | @Keep
31 | override fun invoke(networkInfo: NitroNetworkStatusInfo): Unit
32 | }
33 |
34 | /**
35 | * Represents the JavaScript callback `(networkInfo: struct) => void`.
36 | * This is implemented in C++, via a `std::function<...>`.
37 | * The callback might be coming from JS.
38 | */
39 | @DoNotStrip
40 | @Keep
41 | @Suppress(
42 | "KotlinJniMissingFunction", "unused",
43 | "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44 | "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45 | )
46 | class Func_void_NitroNetworkStatusInfo_cxx: Func_void_NitroNetworkStatusInfo {
47 | @DoNotStrip
48 | @Keep
49 | private val mHybridData: HybridData
50 |
51 | @DoNotStrip
52 | @Keep
53 | private constructor(hybridData: HybridData) {
54 | mHybridData = hybridData
55 | }
56 |
57 | @DoNotStrip
58 | @Keep
59 | override fun invoke(networkInfo: NitroNetworkStatusInfo): Unit
60 | = invoke_cxx(networkInfo)
61 |
62 | @FastNative
63 | private external fun invoke_cxx(networkInfo: NitroNetworkStatusInfo): Unit
64 | }
65 |
66 | /**
67 | * Represents the JavaScript callback `(networkInfo: struct) => void`.
68 | * This is implemented in Java/Kotlin, via a `(NitroNetworkStatusInfo) -> Unit`.
69 | * The callback is always coming from native.
70 | */
71 | @DoNotStrip
72 | @Keep
73 | @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74 | class Func_void_NitroNetworkStatusInfo_java(private val function: (NitroNetworkStatusInfo) -> Unit): Func_void_NitroNetworkStatusInfo {
75 | @DoNotStrip
76 | @Keep
77 | override fun invoke(networkInfo: NitroNetworkStatusInfo): Unit {
78 | return this.function(networkInfo)
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/c++/JFunc_void_NitroNetworkStatusInfo.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// JFunc_void_NitroNetworkStatusInfo.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | #include
11 | #include
12 |
13 | #include "NitroNetworkStatusInfo.hpp"
14 | #include
15 | #include "JNitroNetworkStatusInfo.hpp"
16 | #include "ConnectionType.hpp"
17 | #include "JConnectionType.hpp"
18 |
19 | namespace margelo::nitro::nitronetworkinfo {
20 |
21 | using namespace facebook;
22 |
23 | /**
24 | * Represents the Java/Kotlin callback `(networkInfo: NitroNetworkStatusInfo) -> Unit`.
25 | * This can be passed around between C++ and Java/Kotlin.
26 | */
27 | struct JFunc_void_NitroNetworkStatusInfo: public jni::JavaClass {
28 | public:
29 | static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitronetworkinfo/Func_void_NitroNetworkStatusInfo;";
30 |
31 | public:
32 | /**
33 | * Invokes the function this `JFunc_void_NitroNetworkStatusInfo` instance holds through JNI.
34 | */
35 | void invoke(const NitroNetworkStatusInfo& networkInfo) const {
36 | static const auto method = javaClassStatic()->getMethod /* networkInfo */)>("invoke");
37 | method(self(), JNitroNetworkStatusInfo::fromCpp(networkInfo));
38 | }
39 | };
40 |
41 | /**
42 | * An implementation of Func_void_NitroNetworkStatusInfo that is backed by a C++ implementation (using `std::function<...>`)
43 | */
44 | struct JFunc_void_NitroNetworkStatusInfo_cxx final: public jni::HybridClass {
45 | public:
46 | static jni::local_ref fromCpp(const std::function& func) {
47 | return JFunc_void_NitroNetworkStatusInfo_cxx::newObjectCxxArgs(func);
48 | }
49 |
50 | public:
51 | /**
52 | * Invokes the C++ `std::function<...>` this `JFunc_void_NitroNetworkStatusInfo_cxx` instance holds.
53 | */
54 | void invoke_cxx(jni::alias_ref networkInfo) {
55 | _func(networkInfo->toCpp());
56 | }
57 |
58 | public:
59 | [[nodiscard]]
60 | inline const std::function& getFunction() const {
61 | return _func;
62 | }
63 |
64 | public:
65 | static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitronetworkinfo/Func_void_NitroNetworkStatusInfo_cxx;";
66 | static void registerNatives() {
67 | registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_NitroNetworkStatusInfo_cxx::invoke_cxx)});
68 | }
69 |
70 | private:
71 | explicit JFunc_void_NitroNetworkStatusInfo_cxx(const std::function& func): _func(func) { }
72 |
73 | private:
74 | friend HybridBase;
75 | std::function _func;
76 | };
77 |
78 | } // namespace margelo::nitro::nitronetworkinfo
79 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/NitroNetworkInfo+autolinking.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # NitroNetworkInfo+autolinking.cmake
3 | # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | # https://github.com/mrousavy/nitro
5 | # Copyright © 2025 Marc Rousavy @ Margelo
6 | #
7 |
8 | # This is a CMake file that adds all files generated by Nitrogen
9 | # to the current CMake project.
10 | #
11 | # To use it, add this to your CMakeLists.txt:
12 | # ```cmake
13 | # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroNetworkInfo+autolinking.cmake)
14 | # ```
15 |
16 | # Define a flag to check if we are building properly
17 | add_definitions(-DBUILDING_NITRONETWORKINFO_WITH_GENERATED_CMAKE_PROJECT)
18 |
19 | # Enable Raw Props parsing in react-native (for Nitro Views)
20 | add_definitions(-DRN_SERIALIZABLE_STATE)
21 |
22 | # Add all headers that were generated by Nitrogen
23 | include_directories(
24 | "../nitrogen/generated/shared/c++"
25 | "../nitrogen/generated/android/c++"
26 | "../nitrogen/generated/android/"
27 | )
28 |
29 | # Add all .cpp sources that were generated by Nitrogen
30 | target_sources(
31 | # CMake project name (Android C++ library name)
32 | NitroNetworkInfo PRIVATE
33 | # Autolinking Setup
34 | ../nitrogen/generated/android/NitroNetworkInfoOnLoad.cpp
35 | # Shared Nitrogen C++ sources
36 | ../nitrogen/generated/shared/c++/HybridNitroNetworkInfoSpec.cpp
37 | # Android-specific Nitrogen C++ sources
38 | ../nitrogen/generated/android/c++/JHybridNitroNetworkInfoSpec.cpp
39 | )
40 |
41 | # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42 | # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43 | target_compile_definitions(
44 | NitroNetworkInfo PRIVATE
45 | -DFOLLY_NO_CONFIG=1
46 | -DFOLLY_HAVE_CLOCK_GETTIME=1
47 | -DFOLLY_USE_LIBCPP=1
48 | -DFOLLY_CFG_NO_COROUTINES=1
49 | -DFOLLY_MOBILE=1
50 | -DFOLLY_HAVE_RECVMMSG=1
51 | -DFOLLY_HAVE_PTHREAD=1
52 | # Once we target android-23 above, we can comment
53 | # the following line. NDK uses GNU style stderror_r() after API 23.
54 | -DFOLLY_HAVE_XSI_STRERROR_R=1
55 | )
56 |
57 | # Add all libraries required by the generated specs
58 | find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59 | find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60 | find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61 |
62 | # Link all libraries together
63 | target_link_libraries(
64 | NitroNetworkInfo
65 | fbjni::fbjni # <-- Facebook C++ JNI helpers
66 | ReactAndroid::jsi # <-- RN: JSI
67 | react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68 | )
69 |
70 | # Link react-native (different prefab between RN 0.75 and RN 0.76)
71 | if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72 | target_link_libraries(
73 | NitroNetworkInfo
74 | ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75 | )
76 | else()
77 | target_link_libraries(
78 | NitroNetworkInfo
79 | ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80 | )
81 | endif()
82 |
--------------------------------------------------------------------------------
/nitrogen/generated/android/c++/JHybridNitroNetworkInfoSpec.cpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// JHybridNitroNetworkInfoSpec.cpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #include "JHybridNitroNetworkInfoSpec.hpp"
9 |
10 | // Forward declaration of `ConnectionType` to properly resolve imports.
11 | namespace margelo::nitro::nitronetworkinfo { enum class ConnectionType; }
12 | // Forward declaration of `NitroNetworkStatusInfo` to properly resolve imports.
13 | namespace margelo::nitro::nitronetworkinfo { struct NitroNetworkStatusInfo; }
14 |
15 | #include "ConnectionType.hpp"
16 | #include "JConnectionType.hpp"
17 | #include
18 | #include "JFunc_void.hpp"
19 | #include "NitroNetworkStatusInfo.hpp"
20 | #include "JFunc_void_NitroNetworkStatusInfo.hpp"
21 | #include "JNitroNetworkStatusInfo.hpp"
22 |
23 | namespace margelo::nitro::nitronetworkinfo {
24 |
25 | jni::local_ref JHybridNitroNetworkInfoSpec::initHybrid(jni::alias_ref jThis) {
26 | return makeCxxInstance(jThis);
27 | }
28 |
29 | void JHybridNitroNetworkInfoSpec::registerNatives() {
30 | registerHybrid({
31 | makeNativeMethod("initHybrid", JHybridNitroNetworkInfoSpec::initHybrid),
32 | });
33 | }
34 |
35 | size_t JHybridNitroNetworkInfoSpec::getExternalMemorySize() noexcept {
36 | static const auto method = javaClassStatic()->getMethod("getMemorySize");
37 | return method(_javaPart);
38 | }
39 |
40 | void JHybridNitroNetworkInfoSpec::dispose() noexcept {
41 | static const auto method = javaClassStatic()->getMethod("dispose");
42 | method(_javaPart);
43 | }
44 |
45 | // Properties
46 | bool JHybridNitroNetworkInfoSpec::getIsConnected() {
47 | static const auto method = javaClassStatic()->getMethod("isConnected");
48 | auto __result = method(_javaPart);
49 | return static_cast(__result);
50 | }
51 | ConnectionType JHybridNitroNetworkInfoSpec::getConnectionType() {
52 | static const auto method = javaClassStatic()->getMethod()>("getConnectionType");
53 | auto __result = method(_javaPart);
54 | return __result->toCpp();
55 | }
56 |
57 | // Methods
58 | std::function JHybridNitroNetworkInfoSpec::addListener(const std::function& listener) {
59 | static const auto method = javaClassStatic()->getMethod(jni::alias_ref /* listener */)>("addListener_cxx");
60 | auto __result = method(_javaPart, JFunc_void_NitroNetworkStatusInfo_cxx::fromCpp(listener));
61 | return [&]() -> std::function {
62 | if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
63 | auto downcast = jni::static_ref_cast(__result);
64 | return downcast->cthis()->getFunction();
65 | } else {
66 | auto __resultRef = jni::make_global(__result);
67 | return [__resultRef]() -> void {
68 | return __resultRef->invoke();
69 | };
70 | }
71 | }();
72 | }
73 |
74 | } // namespace margelo::nitro::nitronetworkinfo
75 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/c++/HybridNitroNetworkInfoSpecSwift.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// HybridNitroNetworkInfoSpecSwift.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | #include "HybridNitroNetworkInfoSpec.hpp"
11 |
12 | // Forward declaration of `HybridNitroNetworkInfoSpec_cxx` to properly resolve imports.
13 | namespace NitroNetworkInfo { class HybridNitroNetworkInfoSpec_cxx; }
14 |
15 | // Forward declaration of `ConnectionType` to properly resolve imports.
16 | namespace margelo::nitro::nitronetworkinfo { enum class ConnectionType; }
17 | // Forward declaration of `NitroNetworkStatusInfo` to properly resolve imports.
18 | namespace margelo::nitro::nitronetworkinfo { struct NitroNetworkStatusInfo; }
19 |
20 | #include "ConnectionType.hpp"
21 | #include
22 | #include "NitroNetworkStatusInfo.hpp"
23 |
24 | #include "NitroNetworkInfo-Swift-Cxx-Umbrella.hpp"
25 |
26 | namespace margelo::nitro::nitronetworkinfo {
27 |
28 | /**
29 | * The C++ part of HybridNitroNetworkInfoSpec_cxx.swift.
30 | *
31 | * HybridNitroNetworkInfoSpecSwift (C++) accesses HybridNitroNetworkInfoSpec_cxx (Swift), and might
32 | * contain some additional bridging code for C++ <> Swift interop.
33 | *
34 | * Since this obviously introduces an overhead, I hope at some point in
35 | * the future, HybridNitroNetworkInfoSpec_cxx can directly inherit from the C++ class HybridNitroNetworkInfoSpec
36 | * to simplify the whole structure and memory management.
37 | */
38 | class HybridNitroNetworkInfoSpecSwift: public virtual HybridNitroNetworkInfoSpec {
39 | public:
40 | // Constructor from a Swift instance
41 | explicit HybridNitroNetworkInfoSpecSwift(const NitroNetworkInfo::HybridNitroNetworkInfoSpec_cxx& swiftPart):
42 | HybridObject(HybridNitroNetworkInfoSpec::TAG),
43 | _swiftPart(swiftPart) { }
44 |
45 | public:
46 | // Get the Swift part
47 | inline NitroNetworkInfo::HybridNitroNetworkInfoSpec_cxx& getSwiftPart() noexcept {
48 | return _swiftPart;
49 | }
50 |
51 | public:
52 | inline size_t getExternalMemorySize() noexcept override {
53 | return _swiftPart.getMemorySize();
54 | }
55 | void dispose() noexcept override {
56 | _swiftPart.dispose();
57 | }
58 |
59 | public:
60 | // Properties
61 | inline bool getIsConnected() noexcept override {
62 | return _swiftPart.isConnected();
63 | }
64 | inline ConnectionType getConnectionType() noexcept override {
65 | auto __result = _swiftPart.getConnectionType();
66 | return static_cast(__result);
67 | }
68 |
69 | public:
70 | // Methods
71 | inline std::function addListener(const std::function& listener) override {
72 | auto __result = _swiftPart.addListener(listener);
73 | if (__result.hasError()) [[unlikely]] {
74 | std::rethrow_exception(__result.error());
75 | }
76 | auto __value = std::move(__result.value());
77 | return __value;
78 | }
79 |
80 | private:
81 | NitroNetworkInfo::HybridNitroNetworkInfoSpec_cxx _swiftPart;
82 | };
83 |
84 | } // namespace margelo::nitro::nitronetworkinfo
85 |
--------------------------------------------------------------------------------
/example/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/nitrogen/generated/shared/c++/NitroNetworkStatusInfo.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkStatusInfo.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | #if __has_include()
11 | #include
12 | #else
13 | #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14 | #endif
15 | #if __has_include()
16 | #include
17 | #else
18 | #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19 | #endif
20 | #if __has_include()
21 | #include
22 | #else
23 | #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24 | #endif
25 |
26 | // Forward declaration of `ConnectionType` to properly resolve imports.
27 | namespace margelo::nitro::nitronetworkinfo { enum class ConnectionType; }
28 |
29 | #include "ConnectionType.hpp"
30 |
31 | namespace margelo::nitro::nitronetworkinfo {
32 |
33 | /**
34 | * A struct which can be represented as a JavaScript object (NitroNetworkStatusInfo).
35 | */
36 | struct NitroNetworkStatusInfo {
37 | public:
38 | bool isConnected SWIFT_PRIVATE;
39 | ConnectionType connectionType SWIFT_PRIVATE;
40 |
41 | public:
42 | NitroNetworkStatusInfo() = default;
43 | explicit NitroNetworkStatusInfo(bool isConnected, ConnectionType connectionType): isConnected(isConnected), connectionType(connectionType) {}
44 | };
45 |
46 | } // namespace margelo::nitro::nitronetworkinfo
47 |
48 | namespace margelo::nitro {
49 |
50 | // C++ NitroNetworkStatusInfo <> JS NitroNetworkStatusInfo (object)
51 | template <>
52 | struct JSIConverter final {
53 | static inline margelo::nitro::nitronetworkinfo::NitroNetworkStatusInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
54 | jsi::Object obj = arg.asObject(runtime);
55 | return margelo::nitro::nitronetworkinfo::NitroNetworkStatusInfo(
56 | JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "isConnected")),
57 | JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "connectionType"))
58 | );
59 | }
60 | static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitronetworkinfo::NitroNetworkStatusInfo& arg) {
61 | jsi::Object obj(runtime);
62 | obj.setProperty(runtime, "isConnected", JSIConverter::toJSI(runtime, arg.isConnected));
63 | obj.setProperty(runtime, "connectionType", JSIConverter::toJSI(runtime, arg.connectionType));
64 | return obj;
65 | }
66 | static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
67 | if (!value.isObject()) {
68 | return false;
69 | }
70 | jsi::Object obj = value.getObject(runtime);
71 | if (!nitro::isPlainObject(runtime, obj)) {
72 | return false;
73 | }
74 | if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "isConnected"))) return false;
75 | if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "connectionType"))) return false;
76 | return true;
77 | }
78 | };
79 |
80 | } // namespace margelo::nitro
81 |
--------------------------------------------------------------------------------
/example/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (3.0.7)
5 | base64
6 | nkf
7 | rexml
8 | activesupport (7.2.3)
9 | base64
10 | benchmark (>= 0.3)
11 | bigdecimal
12 | concurrent-ruby (~> 1.0, >= 1.3.1)
13 | connection_pool (>= 2.2.5)
14 | drb
15 | i18n (>= 1.6, < 2)
16 | logger (>= 1.4.2)
17 | minitest (>= 5.1)
18 | securerandom (>= 0.3)
19 | tzinfo (~> 2.0, >= 2.0.5)
20 | addressable (2.8.7)
21 | public_suffix (>= 2.0.2, < 7.0)
22 | algoliasearch (1.27.5)
23 | httpclient (~> 2.8, >= 2.8.3)
24 | json (>= 1.5.1)
25 | atomos (0.1.3)
26 | base64 (0.3.0)
27 | benchmark (0.5.0)
28 | bigdecimal (3.3.1)
29 | claide (1.1.0)
30 | cocoapods (1.16.2)
31 | addressable (~> 2.8)
32 | claide (>= 1.0.2, < 2.0)
33 | cocoapods-core (= 1.16.2)
34 | cocoapods-deintegrate (>= 1.0.3, < 2.0)
35 | cocoapods-downloader (>= 2.1, < 3.0)
36 | cocoapods-plugins (>= 1.0.0, < 2.0)
37 | cocoapods-search (>= 1.0.0, < 2.0)
38 | cocoapods-trunk (>= 1.6.0, < 2.0)
39 | cocoapods-try (>= 1.1.0, < 2.0)
40 | colored2 (~> 3.1)
41 | escape (~> 0.0.4)
42 | fourflusher (>= 2.3.0, < 3.0)
43 | gh_inspector (~> 1.0)
44 | molinillo (~> 0.8.0)
45 | nap (~> 1.0)
46 | ruby-macho (>= 2.3.0, < 3.0)
47 | xcodeproj (>= 1.27.0, < 2.0)
48 | cocoapods-core (1.16.2)
49 | activesupport (>= 5.0, < 8)
50 | addressable (~> 2.8)
51 | algoliasearch (~> 1.0)
52 | concurrent-ruby (~> 1.1)
53 | fuzzy_match (~> 2.0.4)
54 | nap (~> 1.0)
55 | netrc (~> 0.11)
56 | public_suffix (~> 4.0)
57 | typhoeus (~> 1.0)
58 | cocoapods-deintegrate (1.0.5)
59 | cocoapods-downloader (2.1)
60 | cocoapods-plugins (1.0.0)
61 | nap
62 | cocoapods-search (1.0.1)
63 | cocoapods-trunk (1.6.0)
64 | nap (>= 0.8, < 2.0)
65 | netrc (~> 0.11)
66 | cocoapods-try (1.2.0)
67 | colored2 (3.1.2)
68 | concurrent-ruby (1.3.5)
69 | connection_pool (2.5.4)
70 | drb (2.2.3)
71 | escape (0.0.4)
72 | ethon (0.16.0)
73 | ffi (>= 1.15.0)
74 | ffi (1.17.2)
75 | fourflusher (2.3.1)
76 | fuzzy_match (2.0.4)
77 | gh_inspector (1.1.3)
78 | httpclient (2.9.0)
79 | mutex_m
80 | i18n (1.14.7)
81 | concurrent-ruby (~> 1.0)
82 | json (2.11.3)
83 | logger (1.7.0)
84 | minitest (5.26.0)
85 | molinillo (0.8.0)
86 | mutex_m (0.3.0)
87 | nanaimo (0.4.0)
88 | nap (1.1.0)
89 | netrc (0.11.0)
90 | nkf (0.2.0)
91 | public_suffix (4.0.7)
92 | rexml (3.4.1)
93 | ruby-macho (2.5.1)
94 | securerandom (0.4.1)
95 | typhoeus (1.4.1)
96 | ethon (>= 0.9.0)
97 | tzinfo (2.0.6)
98 | concurrent-ruby (~> 1.0)
99 | xcodeproj (1.27.0)
100 | CFPropertyList (>= 2.3.3, < 4.0)
101 | atomos (~> 0.1.3)
102 | claide (>= 1.0.2, < 2.0)
103 | colored2 (~> 3.1)
104 | nanaimo (~> 0.4.0)
105 | rexml (>= 3.3.6, < 4.0)
106 |
107 | PLATFORMS
108 | ruby
109 |
110 | DEPENDENCIES
111 | activesupport (>= 6.1.7.5, != 7.1.0)
112 | benchmark
113 | bigdecimal
114 | cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
115 | concurrent-ruby (< 1.3.6)
116 | logger
117 | mutex_m
118 | xcodeproj (< 1.28.0)
119 |
120 | RUBY VERSION
121 | ruby 3.3.6p108
122 |
123 | BUNDLED WITH
124 | 2.5.22
125 |
--------------------------------------------------------------------------------
/android/src/main/java/com/nitronetworkinfo/NitroNetworkInfoImpl.kt:
--------------------------------------------------------------------------------
1 | package com.nitronetworkinfo
2 |
3 | import android.content.Context
4 | import android.net.ConnectivityManager
5 | import android.net.Network
6 | import android.net.NetworkCapabilities
7 | import android.net.NetworkRequest
8 | import android.os.Handler
9 | import android.os.Looper
10 | import android.util.Log
11 | import com.margelo.nitro.nitronetworkinfo.ConnectionType
12 | import com.margelo.nitro.nitronetworkinfo.NitroNetworkStatusInfo
13 |
14 | interface NetworkInfoDelegate {
15 | fun onNetworkInfoChanged(info: NitroNetworkStatusInfo)
16 | }
17 |
18 | class NitroNetworkInfoImpl(val context: Context, val delegate: NetworkInfoDelegate? = null) {
19 | private val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
20 | private var networkCallback: ConnectivityManager.NetworkCallback? = null
21 | private val mainHandler = Handler(Looper.getMainLooper())
22 |
23 | init {
24 | registerNetworkCallback()
25 | }
26 |
27 | private fun registerNetworkCallback() {
28 | val request = NetworkRequest.Builder()
29 | .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
30 | .build()
31 |
32 | networkCallback = object : ConnectivityManager.NetworkCallback() {
33 | override fun onAvailable(network: Network) {
34 | Log.d(TAG, "Network is available")
35 | val ni = NitroNetworkStatusInfo(
36 | isConnected = true,
37 | connectionType = getConnectionType()
38 | )
39 | mainHandler.post {
40 | delegate?.onNetworkInfoChanged(ni)
41 | }
42 | }
43 |
44 | override fun onLost(network: Network) {
45 | Log.d(TAG, "Network is lost")
46 | val ni = NitroNetworkStatusInfo(
47 | isConnected = false,
48 | connectionType = ConnectionType.UNKNOWN
49 | )
50 | mainHandler.post {
51 | delegate?.onNetworkInfoChanged(ni)
52 | }
53 | }
54 | }
55 | networkCallback?.let {
56 | connectivityManager.registerNetworkCallback(request, it)
57 | }
58 |
59 | }
60 |
61 | fun getIsConnection(): Boolean {
62 | val network = connectivityManager.activeNetwork
63 | val capabilities = connectivityManager.getNetworkCapabilities(network)
64 | return capabilities?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) == true
65 | }
66 |
67 | fun getConnectionType(): ConnectionType {
68 | val network = connectivityManager.activeNetwork
69 | val capabilities = connectivityManager.getNetworkCapabilities(network)
70 | val connectionType = when (true) {
71 | capabilities?.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> {
72 | ConnectionType.WIFI
73 | }
74 |
75 | capabilities?.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> {
76 | ConnectionType.CELLULAR
77 | }
78 |
79 | capabilities?.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> {
80 | ConnectionType.ETHERNET
81 | }
82 |
83 | else -> ConnectionType.UNKNOWN
84 | }
85 | return connectionType
86 | }
87 |
88 | fun unregister() {
89 | networkCallback?.let {
90 | connectivityManager.unregisterNetworkCallback(it)
91 | }
92 | networkCallback = null
93 | }
94 |
95 | companion object {
96 | const val TAG = "NitroNetworkInfo"
97 | }
98 | }
--------------------------------------------------------------------------------
/example/ios/NitroNetworkInfoExample.xcodeproj/xcshareddata/xcschemes/NitroNetworkInfoExample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2 |
3 | # Getting Started
4 |
5 | > **Note**: Make sure you have completed the [Set Up Your Environment](https://reactnative.dev/docs/set-up-your-environment) guide before proceeding.
6 |
7 | ## Step 1: Start Metro
8 |
9 | First, you will need to run **Metro**, the JavaScript build tool for React Native.
10 |
11 | To start the Metro dev server, run the following command from the root of your React Native project:
12 |
13 | ```sh
14 | # Using npm
15 | npm start
16 |
17 | # OR using Yarn
18 | yarn start
19 | ```
20 |
21 | ## Step 2: Build and run your app
22 |
23 | With Metro running, open a new terminal window/pane from the root of your React Native project, and use one of the following commands to build and run your Android or iOS app:
24 |
25 | ### Android
26 |
27 | ```sh
28 | # Using npm
29 | npm run android
30 |
31 | # OR using Yarn
32 | yarn android
33 | ```
34 |
35 | ### iOS
36 |
37 | For iOS, remember to install CocoaPods dependencies (this only needs to be run on first clone or after updating native deps).
38 |
39 | The first time you create a new project, run the Ruby bundler to install CocoaPods itself:
40 |
41 | ```sh
42 | bundle install
43 | ```
44 |
45 | Then, and every time you update your native dependencies, run:
46 |
47 | ```sh
48 | bundle exec pod install
49 | ```
50 |
51 | For more information, please visit [CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html).
52 |
53 | ```sh
54 | # Using npm
55 | npm run ios
56 |
57 | # OR using Yarn
58 | yarn ios
59 | ```
60 |
61 | If everything is set up correctly, you should see your new app running in the Android Emulator, iOS Simulator, or your connected device.
62 |
63 | This is one way to run your app — you can also build it directly from Android Studio or Xcode.
64 |
65 | ## Step 3: Modify your app
66 |
67 | Now that you have successfully run the app, let's make changes!
68 |
69 | Open `App.tsx` in your text editor of choice and make some changes. When you save, your app will automatically update and reflect these changes — this is powered by [Fast Refresh](https://reactnative.dev/docs/fast-refresh).
70 |
71 | When you want to forcefully reload, for example to reset the state of your app, you can perform a full reload:
72 |
73 | - **Android**: Press the R key twice or select **"Reload"** from the **Dev Menu**, accessed via Ctrl + M (Windows/Linux) or Cmd ⌘ + M (macOS).
74 | - **iOS**: Press R in iOS Simulator.
75 |
76 | ## Congratulations! :tada:
77 |
78 | You've successfully run and modified your React Native App. :partying_face:
79 |
80 | ### Now what?
81 |
82 | - If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
83 | - If you're curious to learn more about React Native, check out the [docs](https://reactnative.dev/docs/getting-started).
84 |
85 | # Troubleshooting
86 |
87 | If you're having issues getting the above steps to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
88 |
89 | # Learn More
90 |
91 | To learn more about React Native, take a look at the following resources:
92 |
93 | - [React Native Website](https://reactnative.dev) - learn more about React Native.
94 | - [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
95 | - [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
96 | - [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
97 | - [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
98 |
--------------------------------------------------------------------------------
/nitrogen/generated/shared/c++/ConnectionType.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// ConnectionType.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | #if __has_include()
11 | #include
12 | #else
13 | #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14 | #endif
15 | #if __has_include()
16 | #include
17 | #else
18 | #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19 | #endif
20 | #if __has_include()
21 | #include
22 | #else
23 | #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24 | #endif
25 |
26 | namespace margelo::nitro::nitronetworkinfo {
27 |
28 | /**
29 | * An enum which can be represented as a JavaScript union (ConnectionType).
30 | */
31 | enum class ConnectionType {
32 | UNKNOWN SWIFT_NAME(unknown) = 0,
33 | ETHERNET SWIFT_NAME(ethernet) = 1,
34 | WIFI SWIFT_NAME(wifi) = 2,
35 | CELLULAR SWIFT_NAME(cellular) = 3,
36 | } CLOSED_ENUM;
37 |
38 | } // namespace margelo::nitro::nitronetworkinfo
39 |
40 | namespace margelo::nitro {
41 |
42 | // C++ ConnectionType <> JS ConnectionType (union)
43 | template <>
44 | struct JSIConverter final {
45 | static inline margelo::nitro::nitronetworkinfo::ConnectionType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
46 | std::string unionValue = JSIConverter::fromJSI(runtime, arg);
47 | switch (hashString(unionValue.c_str(), unionValue.size())) {
48 | case hashString("unknown"): return margelo::nitro::nitronetworkinfo::ConnectionType::UNKNOWN;
49 | case hashString("ethernet"): return margelo::nitro::nitronetworkinfo::ConnectionType::ETHERNET;
50 | case hashString("wifi"): return margelo::nitro::nitronetworkinfo::ConnectionType::WIFI;
51 | case hashString("cellular"): return margelo::nitro::nitronetworkinfo::ConnectionType::CELLULAR;
52 | default: [[unlikely]]
53 | throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ConnectionType - invalid value!");
54 | }
55 | }
56 | static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitronetworkinfo::ConnectionType arg) {
57 | switch (arg) {
58 | case margelo::nitro::nitronetworkinfo::ConnectionType::UNKNOWN: return JSIConverter::toJSI(runtime, "unknown");
59 | case margelo::nitro::nitronetworkinfo::ConnectionType::ETHERNET: return JSIConverter::toJSI(runtime, "ethernet");
60 | case margelo::nitro::nitronetworkinfo::ConnectionType::WIFI: return JSIConverter::toJSI(runtime, "wifi");
61 | case margelo::nitro::nitronetworkinfo::ConnectionType::CELLULAR: return JSIConverter::toJSI(runtime, "cellular");
62 | default: [[unlikely]]
63 | throw std::invalid_argument("Cannot convert ConnectionType to JS - invalid value: "
64 | + std::to_string(static_cast(arg)) + "!");
65 | }
66 | }
67 | static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
68 | if (!value.isString()) {
69 | return false;
70 | }
71 | std::string unionValue = JSIConverter::fromJSI(runtime, value);
72 | switch (hashString(unionValue.c_str(), unionValue.size())) {
73 | case hashString("unknown"):
74 | case hashString("ethernet"):
75 | case hashString("wifi"):
76 | case hashString("cellular"):
77 | return true;
78 | default:
79 | return false;
80 | }
81 | }
82 | };
83 |
84 | } // namespace margelo::nitro
85 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | }
6 |
7 | dependencies {
8 | classpath "com.android.tools.build:gradle:8.13.1"
9 | }
10 | }
11 |
12 | def reactNativeArchitectures() {
13 | def value = rootProject.getProperties().get("reactNativeArchitectures")
14 | return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
15 | }
16 |
17 | def isNewArchitectureEnabled() {
18 | return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19 | }
20 |
21 | apply plugin: "com.android.library"
22 | apply plugin: 'org.jetbrains.kotlin.android'
23 | apply from: '../nitrogen/generated/android/NitroNetworkInfo+autolinking.gradle'
24 |
25 | if (isNewArchitectureEnabled()) {
26 | apply plugin: "com.facebook.react"
27 | }
28 |
29 | def getExtOrDefault(name) {
30 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["NitroNetworkInfo_" + name]
31 | }
32 |
33 | def getExtOrIntegerDefault(name) {
34 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["NitroNetworkInfo_" + name]).toInteger()
35 | }
36 |
37 | android {
38 | namespace "com.nitronetworkinfo"
39 |
40 | ndkVersion getExtOrDefault("ndkVersion")
41 | compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
42 |
43 | defaultConfig {
44 | minSdkVersion getExtOrIntegerDefault("minSdkVersion")
45 | targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
46 | buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
47 |
48 | externalNativeBuild {
49 | cmake {
50 | cppFlags "-frtti -fexceptions -Wall -Wextra -fstack-protector-all"
51 | arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
52 | abiFilters (*reactNativeArchitectures())
53 |
54 | buildTypes {
55 | debug {
56 | cppFlags "-O1 -g"
57 | }
58 | release {
59 | cppFlags "-O2"
60 | }
61 | }
62 | }
63 | }
64 | }
65 |
66 | externalNativeBuild {
67 | cmake {
68 | path "CMakeLists.txt"
69 | }
70 | }
71 |
72 | packagingOptions {
73 | excludes = [
74 | "META-INF",
75 | "META-INF/**",
76 | "**/libc++_shared.so",
77 | "**/libfbjni.so",
78 | "**/libjsi.so",
79 | "**/libfolly_json.so",
80 | "**/libfolly_runtime.so",
81 | "**/libglog.so",
82 | "**/libhermes.so",
83 | "**/libhermes-executor-debug.so",
84 | "**/libhermes_executor.so",
85 | "**/libreactnative.so",
86 | "**/libreactnativejni.so",
87 | "**/libturbomodulejsijni.so",
88 | "**/libreact_nativemodule_core.so",
89 | "**/libjscexecutor.so"
90 | ]
91 | }
92 |
93 | buildFeatures {
94 | buildConfig true
95 | prefab true
96 | }
97 |
98 | buildTypes {
99 | release {
100 | minifyEnabled false
101 | }
102 | }
103 |
104 | lintOptions {
105 | disable "GradleCompatible"
106 | }
107 |
108 | compileOptions {
109 | sourceCompatibility JavaVersion.VERSION_1_8
110 | targetCompatibility JavaVersion.VERSION_1_8
111 | }
112 |
113 | sourceSets {
114 | main {
115 | if (isNewArchitectureEnabled()) {
116 | java.srcDirs += [
117 | // React Codegen files
118 | "${project.buildDir}/generated/source/codegen/java"
119 | ]
120 | }
121 | }
122 | }
123 | }
124 |
125 | repositories {
126 | mavenCentral()
127 | google()
128 | }
129 |
130 |
131 | dependencies {
132 | // For < 0.71, this will be from the local maven repo
133 | // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
134 | //noinspection GradleDynamicVersion
135 | implementation "com.facebook.react:react-native:+"
136 |
137 | // Add a dependency on NitroModules
138 | implementation project(":react-native-nitro-modules")
139 | }
140 |
141 | if (isNewArchitectureEnabled()) {
142 | react {
143 | jsRootDir = file("../src/")
144 | libraryName = "NitroNetworkInfo"
145 | codegenJavaPackageName = "com.nitronetworkinfo"
146 | }
147 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-nitro-network-info",
3 | "version": "1.0.6",
4 | "description": "A React Native library for monitoring network connectivity status and connection type using Nitro Modules for high performance",
5 | "main": "./lib/commonjs/index.js",
6 | "module": "./lib/module/index.js",
7 | "types": "./lib/typescript/src/index.d.ts",
8 | "react-native": "src/index",
9 | "source": "src/index",
10 | "scripts": {
11 | "typecheck": "tsc --noEmit",
12 | "clean": "git clean -dfX",
13 | "release": "semantic-release",
14 | "build": "bun run typecheck && bob build",
15 | "codegen": "nitrogen --logLevel=\"debug\" && bun run build && node post-script.js",
16 | "postcodegen": "bun --cwd example pod"
17 | },
18 | "keywords": [
19 | "react-native",
20 | "react-native-nitro-network-info",
21 | "nitro",
22 | "network",
23 | "connection",
24 | "wifi",
25 | "cellular",
26 | "ethernet"
27 | ],
28 | "files": [
29 | "src",
30 | "react-native.config.js",
31 | "lib",
32 | "nitrogen",
33 | "cpp",
34 | "android/build.gradle",
35 | "android/gradle.properties",
36 | "android/CMakeLists.txt",
37 | "android/src",
38 | "ios/**/*.h",
39 | "ios/**/*.m",
40 | "ios/**/*.mm",
41 | "ios/**/*.cpp",
42 | "ios/**/*.swift",
43 | "app.plugin.js",
44 | "*.podspec",
45 | "README.md"
46 | ],
47 | "workspaces": [
48 | "example"
49 | ],
50 | "repository": "https://github.com/patrickkabwe/react-native-nitro-network-info.git",
51 | "author": "Patrick Kabwe",
52 | "license": "MIT",
53 | "bugs": "https://github.com/patrickkabwe/react-native-nitro-network-info/issues",
54 | "homepage": "https://github.com/patrickkabwe/react-native-nitro-network-info#readme",
55 | "publishConfig": {
56 | "access": "public",
57 | "registry": "https://registry.npmjs.org/"
58 | },
59 | "devDependencies": {
60 | "@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
61 | "@types/jest": "^29.5.12",
62 | "@types/react": "^19.0.10",
63 | "nitrogen": "^0.31.2",
64 | "react": "19.1.1",
65 | "react-native": "0.82.1",
66 | "react-native-builder-bob": "^0.37.0",
67 | "react-native-nitro-modules": "^0.31.2",
68 | "release-it": "^19.0.2",
69 | "typescript": "^5.8.3",
70 | "@semantic-release/changelog": "^6.0.3",
71 | "@semantic-release/git": "^10.0.1",
72 | "conventional-changelog-conventionalcommits": "^9.1.0",
73 | "semantic-release": "^24.2.3"
74 | },
75 | "peerDependencies": {
76 | "react": "*",
77 | "react-native": "*",
78 | "react-native-nitro-modules": "*"
79 | },
80 | "eslintConfig": {
81 | "root": true,
82 | "extends": [
83 | "@react-native",
84 | "prettier"
85 | ],
86 | "plugins": [
87 | "prettier"
88 | ],
89 | "rules": {
90 | "prettier/prettier": [
91 | "warn",
92 | {
93 | "quoteProps": "consistent",
94 | "singleQuote": true,
95 | "tabWidth": 2,
96 | "trailingComma": "es5",
97 | "useTabs": false
98 | }
99 | ]
100 | }
101 | },
102 | "eslintIgnore": [
103 | "node_modules/",
104 | "lib/"
105 | ],
106 | "prettier": {
107 | "quoteProps": "consistent",
108 | "singleQuote": true,
109 | "tabWidth": 2,
110 | "trailingComma": "es5",
111 | "useTabs": false,
112 | "semi": false
113 | },
114 | "react-native-builder-bob": {
115 | "source": "src",
116 | "output": "lib",
117 | "targets": [
118 | "commonjs",
119 | "module",
120 | [
121 | "typescript",
122 | {
123 | "project": "tsconfig.json"
124 | }
125 | ]
126 | ]
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-native-nitro-network-info
2 |
3 | A React Native library for monitoring network connectivity status and connection type using Nitro Modules for high performance.
4 |
5 | ## Features
6 |
7 | - 🚀 High performance with Nitro Modules
8 | - 📡 Real-time network status monitoring
9 | - 🔄 Connection type detection (WiFi, Cellular, etc.)
10 | - 📱 Cross-platform support (iOS & Android)
11 | - 🎣 React hooks friendly with listeners
12 |
13 | ## Requirements
14 |
15 | - React Native v0.76.0 or higher
16 | - Node 18.0.0 or higher
17 |
18 | ## Installation
19 |
20 | ```bash
21 | bun add react-native-nitro-network-info react-native-nitro-modules@0.31.2
22 | ```
23 |
24 | ## Usage
25 |
26 | ### Basic Usage
27 |
28 | ```typescript
29 | import React, { useEffect, useState } from 'react';
30 | import { View, Text } from 'react-native';
31 | import NitroNetworkInfo, {
32 | type NitroNetworkStatusInfo
33 | } from 'react-native-nitro-network-info';
34 |
35 | function App() {
36 | const [networkInfo, setNetworkInfo] = useState(null);
37 |
38 | useEffect(() => {
39 | // Add listener for network changes
40 | const unsubscribe = NitroNetworkInfo.addListener((networkInfo) => {
41 | setNetworkInfo(networkInfo);
42 | });
43 |
44 | // Cleanup listener on unmount
45 | return () => {
46 | unsubscribe();
47 | };
48 | }, []);
49 |
50 | return (
51 |
52 |
53 | Status: {NitroNetworkInfo.isConnected ? 'Connected' : 'Disconnected'}
54 |
55 |
56 | Type: {NitroNetworkInfo.connectionType || 'Unknown'}
57 |
58 |
59 | Network Info: {JSON.stringify(networkInfo, null, 2)}
60 |
61 |
62 | );
63 | }
64 | ```
65 |
66 | ## API Reference
67 |
68 | ### Properties
69 |
70 | #### `isConnected: boolean`
71 |
72 | A readonly property that indicates whether the device is currently connected to a network.
73 |
74 | ```typescript
75 | const isConnected = NitroNetworkInfo.isConnected
76 | ```
77 |
78 | #### `connectionType: ConnectionType`
79 |
80 | A readonly property that returns the current connection type (e.g., 'wifi', 'cellular', 'ethernet', etc.).
81 |
82 | ```typescript
83 | const connectionType = NitroNetworkInfo.connectionType
84 | ```
85 |
86 | ### Methods
87 |
88 | #### `addListener(listener: NetworkInfoListener): () => void`
89 |
90 | Adds a listener for network status changes. Returns a function to unsubscribe the listener.
91 |
92 | **Parameters:**
93 |
94 | - `listener: NetworkInfoListener` - Callback function that receives network status updates
95 |
96 | **Returns:**
97 |
98 | - `() => void` - Unsubscribe function
99 |
100 | ```typescript
101 | const unsubscribe = NitroNetworkInfo.addListener((networkInfo) => {
102 | console.log('Network status changed:', networkInfo)
103 | })
104 |
105 | // Later, when you want to stop listening
106 | unsubscribe()
107 | ```
108 |
109 | ### Types
110 |
111 | | Type | Description |
112 | | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
113 | | `NetworkInfoListener` | Callback function type that receives network status updates. Signature: `(networkInfo: NitroNetworkStatusInfo) => void` |
114 | | `ConnectionType` | Enum or string type representing the available connection types (e.g., 'wifi', 'cellular', 'ethernet'). Exact values depend on platform implementation. |
115 | | `NitroNetworkStatusInfo` | Object containing detailed network status information passed to listeners. Structure depends on platform implementation and includes connection state and type details. |
116 |
117 | ## Credits
118 |
119 | Bootstrapped with [create-nitro-module](https://github.com/patrickkabwe/create-nitro-module).
120 |
121 | ## Contributing
122 |
123 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
124 |
--------------------------------------------------------------------------------
/example/ios/NitroNetworkInfoExample/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [1.0.6](https://github.com/patrickkabwe/react-native-nitro-network-info/compare/v1.0.5...v1.0.6) (2025-10-24)
2 |
3 | ### 🛠️ Other changes
4 |
5 | * bump up nitro to version 0.28.1 ([5fb061d](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/5fb061d0753c46c554263da5d0ff6c646fd11f3f))
6 | * bump up react native to 0.82, ([9ddf1de](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/9ddf1de81d9e073f2e5ce887c9f674adb43df502))
7 | * remove old architecture build steps from Android and iOS workflows ([30c783a](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/30c783a4842c327842b1e833212183075d739aeb))
8 | * update nitro 0.31.2 ([389a49c](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/389a49c249abf69069a2ea151eaa31c0e9d9dc7e))
9 |
10 | ## [1.0.5](https://github.com/patrickkabwe/react-native-nitro-network-info/compare/v1.0.4...v1.0.5) (2025-08-20)
11 |
12 | ### 🛠️ Other changes
13 |
14 | * update package.json ([ad5c107](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/ad5c107c4ccb9abe2ed231d359d13fbf9a716a22))
15 |
16 | ## [1.0.4](https://github.com/patrickkabwe/react-native-nitro-network-info/compare/v1.0.3...v1.0.4) (2025-08-20)
17 |
18 | ### 🛠️ Other changes
19 |
20 | * add Xcode setup step to iOS build workflow with version 16.4 ([4c6daac](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/4c6daacb9d301f78f58f45ada7acbee1e63d2cfd))
21 | * **release:** add Git author and committer information to workflow ([86f3ffb](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/86f3ffbab46d68b619c8f4953d50fc4aae6dbe51))
22 | * update dependencies and configurations ([633b4cf](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/633b4cfe5368de347a1fdf44d6e1239d4165058a))
23 |
24 | ## [1.0.3](https://github.com/patrickkabwe/react-native-nitro-network-info/compare/v1.0.2...v1.0.3) (2025-07-21)
25 |
26 | ### 🛠️ Other changes
27 |
28 | * bump up react native version 0.81 ([a4138f6](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/a4138f64741901e589d5fab1077d19f3a9b37208))
29 | * update gradle-wrapper.jar to the latest version ([11054a8](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/11054a84c681919662c380954772ef59e3949030))
30 | * update ReactCodegen version in Podfile.lock ([f459e4b](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/f459e4b440050385d43b951e5af5f29f1949bb69))
31 |
32 | ## [1.0.2](https://github.com/patrickkabwe/react-native-nitro-network-info/compare/v1.0.1...v1.0.2) (2025-06-05)
33 |
34 | ### 🛠️ Other changes
35 |
36 | * update package.json to add additional keywords for better package discoverability ([fed4862](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/fed486256d4e7fddbcd32031dd892721f5c4067f))
37 |
38 | ## [1.0.1](https://github.com/patrickkabwe/react-native-nitro-network-info/compare/v1.0.0...v1.0.1) (2025-06-05)
39 |
40 | ### 🛠️ Other changes
41 |
42 | * update package.json to set public access for npm registry ([1797442](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/179744294d0033cdbcb51694e90047f96c8ab09c))
43 |
44 | ## 1.0.0 (2025-06-05)
45 |
46 | ### ✨ Features
47 |
48 | * init ([6d983bc](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/6d983bca1c3a72885271ddbd53cfd97d67129116))
49 |
50 | ### 📚 Documentation
51 |
52 | * enhance README with detailed features, usage examples, and API reference for NitroNetworkInfo ([c25793c](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/c25793c4d30f3e5edd2d4d760f64a574f5bf353d))
53 |
54 | ### 🛠️ Other changes
55 |
56 | * **ios:** adds NitroNetworkInfoImpl ([7734e9b](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/7734e9bdef0fec21b5956dc819c0456358e18fb8))
57 | * migrate to semantic-release and update release configuration ([3f10902](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/3f109026248c72d7732775734f7e8a9b68765cf2))
58 | * update nitro-codegen and react-native-nitro-modules to version 0.26.1 ([3695073](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/36950731a9f9869f633b690a10db313d230626a2))
59 | * update NitroModules to version 0.26.1 and adjust Podfile.lock paths ([836a7d2](https://github.com/patrickkabwe/react-native-nitro-network-info/commit/836a7d25584cad5cce3176b0176aaa5fd652416a))
60 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 | apply plugin: "org.jetbrains.kotlin.android"
3 | apply plugin: "com.facebook.react"
4 |
5 | /**
6 | * This is the configuration block to customize your React Native Android app.
7 | * By default you don't need to apply any configuration, just uncomment the lines you need.
8 | */
9 | react {
10 | /* Folders */
11 | // The root of your project, i.e. where "package.json" lives. Default is '../..'
12 | // root = file("../../")
13 | // The folder where the react-native NPM package is. Default is ../../node_modules/react-native
14 | reactNativeDir = file("../../../node_modules/react-native")
15 | // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
16 | codegenDir = file("../../../node_modules/@react-native/codegen")
17 | // The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
18 | cliFile = file("../../../node_modules/react-native/cli.js")
19 |
20 | /* Variants */
21 | // The list of variants to that are debuggable. For those we're going to
22 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
23 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
24 | // debuggableVariants = ["liteDebug", "prodDebug"]
25 |
26 | /* Bundling */
27 | // A list containing the node command and its flags. Default is just 'node'.
28 | // nodeExecutableAndArgs = ["node"]
29 | //
30 | // The command to run when bundling. By default is 'bundle'
31 | // bundleCommand = "ram-bundle"
32 | //
33 | // The path to the CLI configuration file. Default is empty.
34 | // bundleConfig = file(../rn-cli.config.js)
35 | //
36 | // The name of the generated asset file containing your JS bundle
37 | // bundleAssetName = "MyApplication.android.bundle"
38 | //
39 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
40 | // entryFile = file("../js/MyApplication.android.js")
41 | //
42 | // A list of extra flags to pass to the 'bundle' commands.
43 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
44 | // extraPackagerArgs = []
45 |
46 | /* Hermes Commands */
47 | // The hermes compiler command to run. By default it is 'hermesc'
48 | hermesCommand = "$rootDir/../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc"
49 | //
50 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51 | // hermesFlags = ["-O", "-output-source-map"]
52 |
53 | /* Autolinking */
54 | autolinkLibrariesWithApp()
55 | }
56 |
57 | /**
58 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
59 | */
60 | def enableProguardInReleaseBuilds = false
61 |
62 | /**
63 | * The preferred build flavor of JavaScriptCore (JSC)
64 | *
65 | * For example, to use the international variant, you can use:
66 | * `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
67 | *
68 | * The international variant includes ICU i18n library and necessary data
69 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
70 | * give correct results when using with locales other than en-US. Note that
71 | * this variant is about 6MiB larger per architecture than default.
72 | */
73 | def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
74 |
75 | android {
76 | ndkVersion rootProject.ext.ndkVersion
77 | buildToolsVersion rootProject.ext.buildToolsVersion
78 | compileSdk rootProject.ext.compileSdkVersion
79 |
80 | namespace "com.nitronetworkinfoexample"
81 | defaultConfig {
82 | applicationId "com.nitronetworkinfoexample"
83 | minSdkVersion rootProject.ext.minSdkVersion
84 | targetSdkVersion rootProject.ext.targetSdkVersion
85 | versionCode 1
86 | versionName "1.0"
87 | }
88 | signingConfigs {
89 | debug {
90 | storeFile file('debug.keystore')
91 | storePassword 'android'
92 | keyAlias 'androiddebugkey'
93 | keyPassword 'android'
94 | }
95 | }
96 | buildTypes {
97 | debug {
98 | signingConfig signingConfigs.debug
99 | }
100 | release {
101 | // Caution! In production, you need to generate your own keystore file.
102 | // see https://reactnative.dev/docs/signed-apk-android.
103 | signingConfig signingConfigs.debug
104 | minifyEnabled enableProguardInReleaseBuilds
105 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
106 |
107 | debuggable true
108 | }
109 | }
110 | }
111 |
112 | dependencies {
113 | // The version of react-native is set by the React Native Gradle Plugin
114 | implementation("com.facebook.react:react-android")
115 |
116 | if (hermesEnabled.toBoolean()) {
117 | implementation("com.facebook.react:hermes-android")
118 | } else {
119 | implementation jscFlavor
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/NitroNetworkInfo-Swift-Cxx-Bridge.hpp:
--------------------------------------------------------------------------------
1 | ///
2 | /// NitroNetworkInfo-Swift-Cxx-Bridge.hpp
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | #pragma once
9 |
10 | // Forward declarations of C++ defined types
11 | // Forward declaration of `ConnectionType` to properly resolve imports.
12 | namespace margelo::nitro::nitronetworkinfo { enum class ConnectionType; }
13 | // Forward declaration of `HybridNitroNetworkInfoSpec` to properly resolve imports.
14 | namespace margelo::nitro::nitronetworkinfo { class HybridNitroNetworkInfoSpec; }
15 | // Forward declaration of `NitroNetworkStatusInfo` to properly resolve imports.
16 | namespace margelo::nitro::nitronetworkinfo { struct NitroNetworkStatusInfo; }
17 |
18 | // Forward declarations of Swift defined types
19 | // Forward declaration of `HybridNitroNetworkInfoSpec_cxx` to properly resolve imports.
20 | namespace NitroNetworkInfo { class HybridNitroNetworkInfoSpec_cxx; }
21 |
22 | // Include C++ defined types
23 | #include "ConnectionType.hpp"
24 | #include "HybridNitroNetworkInfoSpec.hpp"
25 | #include "NitroNetworkStatusInfo.hpp"
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | /**
32 | * Contains specialized versions of C++ templated types so they can be accessed from Swift,
33 | * as well as helper functions to interact with those C++ types from Swift.
34 | */
35 | namespace margelo::nitro::nitronetworkinfo::bridge::swift {
36 |
37 | // pragma MARK: std::function
38 | /**
39 | * Specialized version of `std::function`.
40 | */
41 | using Func_void = std::function;
42 | /**
43 | * Wrapper class for a `std::function`, this can be used from Swift.
44 | */
45 | class Func_void_Wrapper final {
46 | public:
47 | explicit Func_void_Wrapper(std::function&& func): _function(std::make_unique>(std::move(func))) {}
48 | inline void call() const noexcept {
49 | _function->operator()();
50 | }
51 | private:
52 | std::unique_ptr> _function;
53 | } SWIFT_NONCOPYABLE;
54 | Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
55 | inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
56 | return Func_void_Wrapper(std::move(value));
57 | }
58 |
59 | // pragma MARK: std::function
60 | /**
61 | * Specialized version of `std::function`.
62 | */
63 | using Func_void_NitroNetworkStatusInfo = std::function;
64 | /**
65 | * Wrapper class for a `std::function`, this can be used from Swift.
66 | */
67 | class Func_void_NitroNetworkStatusInfo_Wrapper final {
68 | public:
69 | explicit Func_void_NitroNetworkStatusInfo_Wrapper(std::function&& func): _function(std::make_unique>(std::move(func))) {}
70 | inline void call(NitroNetworkStatusInfo networkInfo) const noexcept {
71 | _function->operator()(networkInfo);
72 | }
73 | private:
74 | std::unique_ptr> _function;
75 | } SWIFT_NONCOPYABLE;
76 | Func_void_NitroNetworkStatusInfo create_Func_void_NitroNetworkStatusInfo(void* NON_NULL swiftClosureWrapper) noexcept;
77 | inline Func_void_NitroNetworkStatusInfo_Wrapper wrap_Func_void_NitroNetworkStatusInfo(Func_void_NitroNetworkStatusInfo value) noexcept {
78 | return Func_void_NitroNetworkStatusInfo_Wrapper(std::move(value));
79 | }
80 |
81 | // pragma MARK: std::shared_ptr
82 | /**
83 | * Specialized version of `std::shared_ptr`.
84 | */
85 | using std__shared_ptr_HybridNitroNetworkInfoSpec_ = std::shared_ptr;
86 | std::shared_ptr create_std__shared_ptr_HybridNitroNetworkInfoSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
87 | void* NON_NULL get_std__shared_ptr_HybridNitroNetworkInfoSpec_(std__shared_ptr_HybridNitroNetworkInfoSpec_ cppType);
88 |
89 | // pragma MARK: std::weak_ptr
90 | using std__weak_ptr_HybridNitroNetworkInfoSpec_ = std::weak_ptr;
91 | inline std__weak_ptr_HybridNitroNetworkInfoSpec_ weakify_std__shared_ptr_HybridNitroNetworkInfoSpec_(const std::shared_ptr& strong) noexcept { return strong; }
92 |
93 | // pragma MARK: Result>
94 | using Result_std__function_void____ = Result>;
95 | inline Result_std__function_void____ create_Result_std__function_void____(const std::function& value) noexcept {
96 | return Result>::withValue(value);
97 | }
98 | inline Result_std__function_void____ create_Result_std__function_void____(const std::exception_ptr& error) noexcept {
99 | return Result>::withError(error);
100 | }
101 |
102 | } // namespace margelo::nitro::nitronetworkinfo::bridge::swift
103 |
--------------------------------------------------------------------------------
/nitrogen/generated/ios/swift/HybridNitroNetworkInfoSpec_cxx.swift:
--------------------------------------------------------------------------------
1 | ///
2 | /// HybridNitroNetworkInfoSpec_cxx.swift
3 | /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4 | /// https://github.com/mrousavy/nitro
5 | /// Copyright © 2025 Marc Rousavy @ Margelo
6 | ///
7 |
8 | import Foundation
9 | import NitroModules
10 |
11 | /**
12 | * A class implementation that bridges HybridNitroNetworkInfoSpec over to C++.
13 | * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14 | *
15 | * Also, some Swift types need to be bridged with special handling:
16 | * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17 | * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18 | * - Throwing methods need to be wrapped with a Result type, as exceptions cannot be propagated to C++
19 | */
20 | open class HybridNitroNetworkInfoSpec_cxx {
21 | /**
22 | * The Swift <> C++ bridge's namespace (`margelo::nitro::nitronetworkinfo::bridge::swift`)
23 | * from `NitroNetworkInfo-Swift-Cxx-Bridge.hpp`.
24 | * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25 | */
26 | public typealias bridge = margelo.nitro.nitronetworkinfo.bridge.swift
27 |
28 | /**
29 | * Holds an instance of the `HybridNitroNetworkInfoSpec` Swift protocol.
30 | */
31 | private var __implementation: any HybridNitroNetworkInfoSpec
32 |
33 | /**
34 | * Holds a weak pointer to the C++ class that wraps the Swift class.
35 | */
36 | private var __cxxPart: bridge.std__weak_ptr_HybridNitroNetworkInfoSpec_
37 |
38 | /**
39 | * Create a new `HybridNitroNetworkInfoSpec_cxx` that wraps the given `HybridNitroNetworkInfoSpec`.
40 | * All properties and methods bridge to C++ types.
41 | */
42 | public init(_ implementation: any HybridNitroNetworkInfoSpec) {
43 | self.__implementation = implementation
44 | self.__cxxPart = .init()
45 | /* no base class */
46 | }
47 |
48 | /**
49 | * Get the actual `HybridNitroNetworkInfoSpec` instance this class wraps.
50 | */
51 | @inline(__always)
52 | public func getHybridNitroNetworkInfoSpec() -> any HybridNitroNetworkInfoSpec {
53 | return __implementation
54 | }
55 |
56 | /**
57 | * Casts this instance to a retained unsafe raw pointer.
58 | * This acquires one additional strong reference on the object!
59 | */
60 | public func toUnsafe() -> UnsafeMutableRawPointer {
61 | return Unmanaged.passRetained(self).toOpaque()
62 | }
63 |
64 | /**
65 | * Casts an unsafe pointer to a `HybridNitroNetworkInfoSpec_cxx`.
66 | * The pointer has to be a retained opaque `Unmanaged`.
67 | * This removes one strong reference from the object!
68 | */
69 | public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroNetworkInfoSpec_cxx {
70 | return Unmanaged.fromOpaque(pointer).takeRetainedValue()
71 | }
72 |
73 | /**
74 | * Gets (or creates) the C++ part of this Hybrid Object.
75 | * The C++ part is a `std::shared_ptr`.
76 | */
77 | public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroNetworkInfoSpec_ {
78 | let cachedCxxPart = self.__cxxPart.lock()
79 | if cachedCxxPart.__convertToBool() {
80 | return cachedCxxPart
81 | } else {
82 | let newCxxPart = bridge.create_std__shared_ptr_HybridNitroNetworkInfoSpec_(self.toUnsafe())
83 | __cxxPart = bridge.weakify_std__shared_ptr_HybridNitroNetworkInfoSpec_(newCxxPart)
84 | return newCxxPart
85 | }
86 | }
87 |
88 |
89 |
90 | /**
91 | * Get the memory size of the Swift class (plus size of any other allocations)
92 | * so the JS VM can properly track it and garbage-collect the JS object if needed.
93 | */
94 | @inline(__always)
95 | public var memorySize: Int {
96 | return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97 | }
98 |
99 | /**
100 | * Call dispose() on the Swift class.
101 | * This _may_ be called manually from JS.
102 | */
103 | @inline(__always)
104 | public func dispose() {
105 | self.__implementation.dispose()
106 | }
107 |
108 | // Properties
109 | public final var isConnected: Bool {
110 | @inline(__always)
111 | get {
112 | return self.__implementation.isConnected
113 | }
114 | }
115 |
116 | public final var connectionType: Int32 {
117 | @inline(__always)
118 | get {
119 | return self.__implementation.connectionType.rawValue
120 | }
121 | }
122 |
123 | // Methods
124 | @inline(__always)
125 | public final func addListener(listener: bridge.Func_void_NitroNetworkStatusInfo) -> bridge.Result_std__function_void____ {
126 | do {
127 | let __result = try self.__implementation.addListener(listener: { () -> (NitroNetworkStatusInfo) -> Void in
128 | let __wrappedFunction = bridge.wrap_Func_void_NitroNetworkStatusInfo(listener)
129 | return { (__networkInfo: NitroNetworkStatusInfo) -> Void in
130 | __wrappedFunction.call(__networkInfo)
131 | }
132 | }())
133 | let __resultCpp = { () -> bridge.Func_void in
134 | let __closureWrapper = Func_void(__result)
135 | return bridge.create_Func_void(__closureWrapper.toUnsafe())
136 | }()
137 | return bridge.create_Result_std__function_void____(__resultCpp)
138 | } catch (let __error) {
139 | let __exceptionPtr = __error.toCpp()
140 | return bridge.create_Result_std__function_void____(__exceptionPtr)
141 | }
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/example/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH="\\\"\\\""
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | if ! command -v java >/dev/null 2>&1
137 | then
138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139 |
140 | Please set the JAVA_HOME variable in your environment to match the
141 | location of your Java installation."
142 | fi
143 | fi
144 |
145 | # Increase the maximum file descriptors if we can.
146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147 | case $MAX_FD in #(
148 | max*)
149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150 | # shellcheck disable=SC2039,SC3045
151 | MAX_FD=$( ulimit -H -n ) ||
152 | warn "Could not query maximum file descriptor limit"
153 | esac
154 | case $MAX_FD in #(
155 | '' | soft) :;; #(
156 | *)
157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158 | # shellcheck disable=SC2039,SC3045
159 | ulimit -n "$MAX_FD" ||
160 | warn "Could not set maximum file descriptor limit to $MAX_FD"
161 | esac
162 | fi
163 |
164 | # Collect all arguments for the java command, stacking in reverse order:
165 | # * args from the command line
166 | # * the main class name
167 | # * -classpath
168 | # * -D...appname settings
169 | # * --module-path (only if needed)
170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171 |
172 | # For Cygwin or MSYS, switch paths to Windows format before running java
173 | if "$cygwin" || "$msys" ; then
174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176 |
177 | JAVACMD=$( cygpath --unix "$JAVACMD" )
178 |
179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
180 | for arg do
181 | if
182 | case $arg in #(
183 | -*) false ;; # don't mess with options #(
184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185 | [ -e "$t" ] ;; #(
186 | *) false ;;
187 | esac
188 | then
189 | arg=$( cygpath --path --ignore --mixed "$arg" )
190 | fi
191 | # Roll the args list around exactly as many times as the number of
192 | # args, so each arg winds up back in the position where it started, but
193 | # possibly modified.
194 | #
195 | # NB: a `for` loop captures its iteration list before it begins, so
196 | # changing the positional parameters here affects neither the number of
197 | # iterations, nor the values presented in `arg`.
198 | shift # remove old arg
199 | set -- "$@" "$arg" # push replacement arg
200 | done
201 | fi
202 |
203 |
204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206 |
207 | # Collect all arguments for the java command:
208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209 | # and any embedded shellness will be escaped.
210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211 | # treated as '${Hostname}' itself on the command line.
212 |
213 | set -- \
214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
215 | -classpath "$CLASSPATH" \
216 | -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217 | "$@"
218 |
219 | # Stop when "xargs" is not available.
220 | if ! command -v xargs >/dev/null 2>&1
221 | then
222 | die "xargs is not available"
223 | fi
224 |
225 | # Use "xargs" to parse quoted args.
226 | #
227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228 | #
229 | # In Bash we could simply go:
230 | #
231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232 | # set -- "${ARGS[@]}" "$@"
233 | #
234 | # but POSIX shell has neither arrays nor command substitution, so instead we
235 | # post-process each arg (as a line of input to sed) to backslash-escape any
236 | # character that might be a shell metacharacter, then use eval to reverse
237 | # that process (while maintaining the separation between arguments), and wrap
238 | # the whole thing up as a single "set" statement.
239 | #
240 | # This will of course break if any of these variables contains a newline or
241 | # an unmatched quote.
242 | #
243 |
244 | eval "set -- $(
245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246 | xargs -n1 |
247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248 | tr '\n' ' '
249 | )" '"$@"'
250 |
251 | exec "$JAVACMD" "$@"
252 |
--------------------------------------------------------------------------------
/example/ios/NitroNetworkInfoExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 54;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 0C80B921A6F3F58F76C31292 /* libPods-NitroNetworkInfoExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DCACB8F33CDC322A6C60F78 /* libPods-NitroNetworkInfoExample.a */; };
11 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
12 | 6CA45A9774F1C34AF148E6F5 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; };
13 | 761780ED2CA45674006654EE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 761780EC2CA45674006654EE /* AppDelegate.swift */; };
14 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
15 | /* End PBXBuildFile section */
16 |
17 | /* Begin PBXFileReference section */
18 | 13B07F961A680F5B00A75B9A /* NitroNetworkInfoExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NitroNetworkInfoExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
19 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = NitroNetworkInfoExample/Images.xcassets; sourceTree = ""; };
20 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = NitroNetworkInfoExample/Info.plist; sourceTree = ""; };
21 | 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = NitroNetworkInfoExample/PrivacyInfo.xcprivacy; sourceTree = ""; };
22 | 3B4392A12AC88292D35C810B /* Pods-NitroNetworkInfoExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NitroNetworkInfoExample.debug.xcconfig"; path = "Target Support Files/Pods-NitroNetworkInfoExample/Pods-NitroNetworkInfoExample.debug.xcconfig"; sourceTree = ""; };
23 | 5709B34CF0A7D63546082F79 /* Pods-NitroNetworkInfoExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NitroNetworkInfoExample.release.xcconfig"; path = "Target Support Files/Pods-NitroNetworkInfoExample/Pods-NitroNetworkInfoExample.release.xcconfig"; sourceTree = ""; };
24 | 5DCACB8F33CDC322A6C60F78 /* libPods-NitroNetworkInfoExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NitroNetworkInfoExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
25 | 761780EC2CA45674006654EE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = NitroNetworkInfoExample/AppDelegate.swift; sourceTree = ""; };
26 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = NitroNetworkInfoExample/LaunchScreen.storyboard; sourceTree = ""; };
27 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
28 | /* End PBXFileReference section */
29 |
30 | /* Begin PBXFrameworksBuildPhase section */
31 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = {
32 | isa = PBXFrameworksBuildPhase;
33 | buildActionMask = 2147483647;
34 | files = (
35 | 0C80B921A6F3F58F76C31292 /* libPods-NitroNetworkInfoExample.a in Frameworks */,
36 | );
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXFrameworksBuildPhase section */
40 |
41 | /* Begin PBXGroup section */
42 | 13B07FAE1A68108700A75B9A /* NitroNetworkInfoExample */ = {
43 | isa = PBXGroup;
44 | children = (
45 | 13B07FB51A68108700A75B9A /* Images.xcassets */,
46 | 761780EC2CA45674006654EE /* AppDelegate.swift */,
47 | 13B07FB61A68108700A75B9A /* Info.plist */,
48 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
49 | 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */,
50 | );
51 | name = NitroNetworkInfoExample;
52 | sourceTree = "";
53 | };
54 | 2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
55 | isa = PBXGroup;
56 | children = (
57 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
58 | 5DCACB8F33CDC322A6C60F78 /* libPods-NitroNetworkInfoExample.a */,
59 | );
60 | name = Frameworks;
61 | sourceTree = "";
62 | };
63 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = {
64 | isa = PBXGroup;
65 | children = (
66 | );
67 | name = Libraries;
68 | sourceTree = "";
69 | };
70 | 83CBB9F61A601CBA00E9B192 = {
71 | isa = PBXGroup;
72 | children = (
73 | 13B07FAE1A68108700A75B9A /* NitroNetworkInfoExample */,
74 | 832341AE1AAA6A7D00B99B32 /* Libraries */,
75 | 83CBBA001A601CBA00E9B192 /* Products */,
76 | 2D16E6871FA4F8E400B85C8A /* Frameworks */,
77 | BBD78D7AC51CEA395F1C20DB /* Pods */,
78 | );
79 | indentWidth = 2;
80 | sourceTree = "";
81 | tabWidth = 2;
82 | usesTabs = 0;
83 | };
84 | 83CBBA001A601CBA00E9B192 /* Products */ = {
85 | isa = PBXGroup;
86 | children = (
87 | 13B07F961A680F5B00A75B9A /* NitroNetworkInfoExample.app */,
88 | );
89 | name = Products;
90 | sourceTree = "";
91 | };
92 | BBD78D7AC51CEA395F1C20DB /* Pods */ = {
93 | isa = PBXGroup;
94 | children = (
95 | 3B4392A12AC88292D35C810B /* Pods-NitroNetworkInfoExample.debug.xcconfig */,
96 | 5709B34CF0A7D63546082F79 /* Pods-NitroNetworkInfoExample.release.xcconfig */,
97 | );
98 | path = Pods;
99 | sourceTree = "";
100 | };
101 | /* End PBXGroup section */
102 |
103 | /* Begin PBXNativeTarget section */
104 | 13B07F861A680F5B00A75B9A /* NitroNetworkInfoExample */ = {
105 | isa = PBXNativeTarget;
106 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "NitroNetworkInfoExample" */;
107 | buildPhases = (
108 | C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */,
109 | 13B07F871A680F5B00A75B9A /* Sources */,
110 | 13B07F8C1A680F5B00A75B9A /* Frameworks */,
111 | 13B07F8E1A680F5B00A75B9A /* Resources */,
112 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
113 | 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */,
114 | E235C05ADACE081382539298 /* [CP] Copy Pods Resources */,
115 | );
116 | buildRules = (
117 | );
118 | dependencies = (
119 | );
120 | name = NitroNetworkInfoExample;
121 | productName = NitroNetworkInfoExample;
122 | productReference = 13B07F961A680F5B00A75B9A /* NitroNetworkInfoExample.app */;
123 | productType = "com.apple.product-type.application";
124 | };
125 | /* End PBXNativeTarget section */
126 |
127 | /* Begin PBXProject section */
128 | 83CBB9F71A601CBA00E9B192 /* Project object */ = {
129 | isa = PBXProject;
130 | attributes = {
131 | LastUpgradeCheck = 1210;
132 | TargetAttributes = {
133 | 13B07F861A680F5B00A75B9A = {
134 | LastSwiftMigration = 1120;
135 | };
136 | };
137 | };
138 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "NitroNetworkInfoExample" */;
139 | compatibilityVersion = "Xcode 12.0";
140 | developmentRegion = en;
141 | hasScannedForEncodings = 0;
142 | knownRegions = (
143 | en,
144 | Base,
145 | );
146 | mainGroup = 83CBB9F61A601CBA00E9B192;
147 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
148 | projectDirPath = "";
149 | projectRoot = "";
150 | targets = (
151 | 13B07F861A680F5B00A75B9A /* NitroNetworkInfoExample */,
152 | );
153 | };
154 | /* End PBXProject section */
155 |
156 | /* Begin PBXResourcesBuildPhase section */
157 | 13B07F8E1A680F5B00A75B9A /* Resources */ = {
158 | isa = PBXResourcesBuildPhase;
159 | buildActionMask = 2147483647;
160 | files = (
161 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
162 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
163 | 6CA45A9774F1C34AF148E6F5 /* PrivacyInfo.xcprivacy in Resources */,
164 | );
165 | runOnlyForDeploymentPostprocessing = 0;
166 | };
167 | /* End PBXResourcesBuildPhase section */
168 |
169 | /* Begin PBXShellScriptBuildPhase section */
170 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
171 | isa = PBXShellScriptBuildPhase;
172 | buildActionMask = 2147483647;
173 | files = (
174 | );
175 | inputPaths = (
176 | "$(SRCROOT)/.xcode.env.local",
177 | "$(SRCROOT)/.xcode.env",
178 | );
179 | name = "Bundle React Native code and images";
180 | outputPaths = (
181 | );
182 | runOnlyForDeploymentPostprocessing = 0;
183 | shellPath = /bin/sh;
184 | shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
185 | };
186 | 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
187 | isa = PBXShellScriptBuildPhase;
188 | buildActionMask = 2147483647;
189 | files = (
190 | );
191 | inputFileListPaths = (
192 | "${PODS_ROOT}/Target Support Files/Pods-NitroNetworkInfoExample/Pods-NitroNetworkInfoExample-frameworks-${CONFIGURATION}-input-files.xcfilelist",
193 | );
194 | inputPaths = (
195 | );
196 | name = "[CP] Embed Pods Frameworks";
197 | outputFileListPaths = (
198 | "${PODS_ROOT}/Target Support Files/Pods-NitroNetworkInfoExample/Pods-NitroNetworkInfoExample-frameworks-${CONFIGURATION}-output-files.xcfilelist",
199 | );
200 | outputPaths = (
201 | );
202 | runOnlyForDeploymentPostprocessing = 0;
203 | shellPath = /bin/sh;
204 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-NitroNetworkInfoExample/Pods-NitroNetworkInfoExample-frameworks.sh\"\n";
205 | showEnvVarsInLog = 0;
206 | };
207 | C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */ = {
208 | isa = PBXShellScriptBuildPhase;
209 | buildActionMask = 2147483647;
210 | files = (
211 | );
212 | inputFileListPaths = (
213 | );
214 | inputPaths = (
215 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
216 | "${PODS_ROOT}/Manifest.lock",
217 | );
218 | name = "[CP] Check Pods Manifest.lock";
219 | outputFileListPaths = (
220 | );
221 | outputPaths = (
222 | "$(DERIVED_FILE_DIR)/Pods-NitroNetworkInfoExample-checkManifestLockResult.txt",
223 | );
224 | runOnlyForDeploymentPostprocessing = 0;
225 | shellPath = /bin/sh;
226 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
227 | showEnvVarsInLog = 0;
228 | };
229 | E235C05ADACE081382539298 /* [CP] Copy Pods Resources */ = {
230 | isa = PBXShellScriptBuildPhase;
231 | buildActionMask = 2147483647;
232 | files = (
233 | );
234 | inputFileListPaths = (
235 | "${PODS_ROOT}/Target Support Files/Pods-NitroNetworkInfoExample/Pods-NitroNetworkInfoExample-resources-${CONFIGURATION}-input-files.xcfilelist",
236 | );
237 | inputPaths = (
238 | );
239 | name = "[CP] Copy Pods Resources";
240 | outputFileListPaths = (
241 | "${PODS_ROOT}/Target Support Files/Pods-NitroNetworkInfoExample/Pods-NitroNetworkInfoExample-resources-${CONFIGURATION}-output-files.xcfilelist",
242 | );
243 | outputPaths = (
244 | );
245 | runOnlyForDeploymentPostprocessing = 0;
246 | shellPath = /bin/sh;
247 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-NitroNetworkInfoExample/Pods-NitroNetworkInfoExample-resources.sh\"\n";
248 | showEnvVarsInLog = 0;
249 | };
250 | /* End PBXShellScriptBuildPhase section */
251 |
252 | /* Begin PBXSourcesBuildPhase section */
253 | 13B07F871A680F5B00A75B9A /* Sources */ = {
254 | isa = PBXSourcesBuildPhase;
255 | buildActionMask = 2147483647;
256 | files = (
257 | 761780ED2CA45674006654EE /* AppDelegate.swift in Sources */,
258 | );
259 | runOnlyForDeploymentPostprocessing = 0;
260 | };
261 | /* End PBXSourcesBuildPhase section */
262 |
263 | /* Begin XCBuildConfiguration section */
264 | 13B07F941A680F5B00A75B9A /* Debug */ = {
265 | isa = XCBuildConfiguration;
266 | baseConfigurationReference = 3B4392A12AC88292D35C810B /* Pods-NitroNetworkInfoExample.debug.xcconfig */;
267 | buildSettings = {
268 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
269 | CLANG_ENABLE_MODULES = YES;
270 | CURRENT_PROJECT_VERSION = 1;
271 | DEVELOPMENT_TEAM = 5D7YX8MRR4;
272 | ENABLE_BITCODE = NO;
273 | INFOPLIST_FILE = NitroNetworkInfoExample/Info.plist;
274 | IPHONEOS_DEPLOYMENT_TARGET = 15.1;
275 | LD_RUNPATH_SEARCH_PATHS = (
276 | "$(inherited)",
277 | "@executable_path/Frameworks",
278 | );
279 | MARKETING_VERSION = 1.0;
280 | OTHER_LDFLAGS = (
281 | "$(inherited)",
282 | "-ObjC",
283 | "-lc++",
284 | );
285 | PRODUCT_BUNDLE_IDENTIFIER = com.nitronetworkinfoexample;
286 | PRODUCT_NAME = NitroNetworkInfoExample;
287 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
288 | SWIFT_VERSION = 5.0;
289 | VERSIONING_SYSTEM = "apple-generic";
290 | };
291 | name = Debug;
292 | };
293 | 13B07F951A680F5B00A75B9A /* Release */ = {
294 | isa = XCBuildConfiguration;
295 | baseConfigurationReference = 5709B34CF0A7D63546082F79 /* Pods-NitroNetworkInfoExample.release.xcconfig */;
296 | buildSettings = {
297 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
298 | CLANG_ENABLE_MODULES = YES;
299 | CURRENT_PROJECT_VERSION = 1;
300 | DEVELOPMENT_TEAM = 5D7YX8MRR4;
301 | INFOPLIST_FILE = NitroNetworkInfoExample/Info.plist;
302 | IPHONEOS_DEPLOYMENT_TARGET = 15.1;
303 | LD_RUNPATH_SEARCH_PATHS = (
304 | "$(inherited)",
305 | "@executable_path/Frameworks",
306 | );
307 | MARKETING_VERSION = 1.0;
308 | OTHER_LDFLAGS = (
309 | "$(inherited)",
310 | "-ObjC",
311 | "-lc++",
312 | );
313 | PRODUCT_BUNDLE_IDENTIFIER = com.nitronetworkinfoexample;
314 | PRODUCT_NAME = NitroNetworkInfoExample;
315 | SWIFT_VERSION = 5.0;
316 | VERSIONING_SYSTEM = "apple-generic";
317 | };
318 | name = Release;
319 | };
320 | 83CBBA201A601CBA00E9B192 /* Debug */ = {
321 | isa = XCBuildConfiguration;
322 | buildSettings = {
323 | ALWAYS_SEARCH_USER_PATHS = NO;
324 | CC = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";
325 | CCACHE_BINARY = /opt/homebrew/bin/ccache;
326 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
327 | CLANG_CXX_LANGUAGE_STANDARD = "c++20";
328 | CLANG_CXX_LIBRARY = "libc++";
329 | CLANG_ENABLE_MODULES = YES;
330 | CLANG_ENABLE_OBJC_ARC = YES;
331 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
332 | CLANG_WARN_BOOL_CONVERSION = YES;
333 | CLANG_WARN_COMMA = YES;
334 | CLANG_WARN_CONSTANT_CONVERSION = YES;
335 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
336 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
337 | CLANG_WARN_EMPTY_BODY = YES;
338 | CLANG_WARN_ENUM_CONVERSION = YES;
339 | CLANG_WARN_INFINITE_RECURSION = YES;
340 | CLANG_WARN_INT_CONVERSION = YES;
341 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
342 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
343 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
345 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
346 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
347 | CLANG_WARN_STRICT_PROTOTYPES = YES;
348 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
349 | CLANG_WARN_UNREACHABLE_CODE = YES;
350 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
351 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
352 | COPY_PHASE_STRIP = NO;
353 | CXX = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang++.sh";
354 | ENABLE_STRICT_OBJC_MSGSEND = YES;
355 | ENABLE_TESTABILITY = YES;
356 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
357 | GCC_C_LANGUAGE_STANDARD = gnu99;
358 | GCC_DYNAMIC_NO_PIC = NO;
359 | GCC_NO_COMMON_BLOCKS = YES;
360 | GCC_OPTIMIZATION_LEVEL = 0;
361 | GCC_PREPROCESSOR_DEFINITIONS = (
362 | "DEBUG=1",
363 | "$(inherited)",
364 | );
365 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
366 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
367 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
368 | GCC_WARN_UNDECLARED_SELECTOR = YES;
369 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
370 | GCC_WARN_UNUSED_FUNCTION = YES;
371 | GCC_WARN_UNUSED_VARIABLE = YES;
372 | IPHONEOS_DEPLOYMENT_TARGET = 15.1;
373 | LD = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";
374 | LDPLUSPLUS = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang++.sh";
375 | LD_RUNPATH_SEARCH_PATHS = (
376 | /usr/lib/swift,
377 | "$(inherited)",
378 | );
379 | LIBRARY_SEARCH_PATHS = (
380 | "\"$(SDKROOT)/usr/lib/swift\"",
381 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
382 | "\"$(inherited)\"",
383 | );
384 | MTL_ENABLE_DEBUG_INFO = YES;
385 | ONLY_ACTIVE_ARCH = YES;
386 | OTHER_CPLUSPLUSFLAGS = (
387 | "$(OTHER_CFLAGS)",
388 | "-DFOLLY_NO_CONFIG",
389 | "-DFOLLY_MOBILE=1",
390 | "-DFOLLY_USE_LIBCPP=1",
391 | "-DFOLLY_CFG_NO_COROUTINES=1",
392 | "-DFOLLY_HAVE_CLOCK_GETTIME=1",
393 | );
394 | OTHER_LDFLAGS = "$(inherited) ";
395 | REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native";
396 | SDKROOT = iphoneos;
397 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
398 | USE_HERMES = true;
399 | };
400 | name = Debug;
401 | };
402 | 83CBBA211A601CBA00E9B192 /* Release */ = {
403 | isa = XCBuildConfiguration;
404 | buildSettings = {
405 | ALWAYS_SEARCH_USER_PATHS = NO;
406 | CC = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";
407 | CCACHE_BINARY = /opt/homebrew/bin/ccache;
408 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
409 | CLANG_CXX_LANGUAGE_STANDARD = "c++20";
410 | CLANG_CXX_LIBRARY = "libc++";
411 | CLANG_ENABLE_MODULES = YES;
412 | CLANG_ENABLE_OBJC_ARC = YES;
413 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
414 | CLANG_WARN_BOOL_CONVERSION = YES;
415 | CLANG_WARN_COMMA = YES;
416 | CLANG_WARN_CONSTANT_CONVERSION = YES;
417 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
418 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
419 | CLANG_WARN_EMPTY_BODY = YES;
420 | CLANG_WARN_ENUM_CONVERSION = YES;
421 | CLANG_WARN_INFINITE_RECURSION = YES;
422 | CLANG_WARN_INT_CONVERSION = YES;
423 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
424 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
425 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
426 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
427 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
428 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
429 | CLANG_WARN_STRICT_PROTOTYPES = YES;
430 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
431 | CLANG_WARN_UNREACHABLE_CODE = YES;
432 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
433 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
434 | COPY_PHASE_STRIP = YES;
435 | CXX = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang++.sh";
436 | ENABLE_NS_ASSERTIONS = NO;
437 | ENABLE_STRICT_OBJC_MSGSEND = YES;
438 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
439 | GCC_C_LANGUAGE_STANDARD = gnu99;
440 | GCC_NO_COMMON_BLOCKS = YES;
441 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
442 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
443 | GCC_WARN_UNDECLARED_SELECTOR = YES;
444 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
445 | GCC_WARN_UNUSED_FUNCTION = YES;
446 | GCC_WARN_UNUSED_VARIABLE = YES;
447 | IPHONEOS_DEPLOYMENT_TARGET = 15.1;
448 | LD = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";
449 | LDPLUSPLUS = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang++.sh";
450 | LD_RUNPATH_SEARCH_PATHS = (
451 | /usr/lib/swift,
452 | "$(inherited)",
453 | );
454 | LIBRARY_SEARCH_PATHS = (
455 | "\"$(SDKROOT)/usr/lib/swift\"",
456 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
457 | "\"$(inherited)\"",
458 | );
459 | MTL_ENABLE_DEBUG_INFO = NO;
460 | OTHER_CPLUSPLUSFLAGS = (
461 | "$(OTHER_CFLAGS)",
462 | "-DFOLLY_NO_CONFIG",
463 | "-DFOLLY_MOBILE=1",
464 | "-DFOLLY_USE_LIBCPP=1",
465 | "-DFOLLY_CFG_NO_COROUTINES=1",
466 | "-DFOLLY_HAVE_CLOCK_GETTIME=1",
467 | );
468 | OTHER_LDFLAGS = "$(inherited) ";
469 | REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native";
470 | SDKROOT = iphoneos;
471 | USE_HERMES = true;
472 | VALIDATE_PRODUCT = YES;
473 | };
474 | name = Release;
475 | };
476 | /* End XCBuildConfiguration section */
477 |
478 | /* Begin XCConfigurationList section */
479 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "NitroNetworkInfoExample" */ = {
480 | isa = XCConfigurationList;
481 | buildConfigurations = (
482 | 13B07F941A680F5B00A75B9A /* Debug */,
483 | 13B07F951A680F5B00A75B9A /* Release */,
484 | );
485 | defaultConfigurationIsVisible = 0;
486 | defaultConfigurationName = Release;
487 | };
488 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "NitroNetworkInfoExample" */ = {
489 | isa = XCConfigurationList;
490 | buildConfigurations = (
491 | 83CBBA201A601CBA00E9B192 /* Debug */,
492 | 83CBBA211A601CBA00E9B192 /* Release */,
493 | );
494 | defaultConfigurationIsVisible = 0;
495 | defaultConfigurationName = Release;
496 | };
497 | /* End XCConfigurationList section */
498 | };
499 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
500 | }
501 |
--------------------------------------------------------------------------------