@elemanhill/react-native-activity-kit
v0.0.12
Published
@elemanhill/react-native-activity-kit
Readme
react-native-activity-kit
A React Native library for iOS Live Activities using ActivityKit.
Installation
npm install @elemanhill/react-native-activity-kit
# or
yarn add @elemanhill/react-native-activity-kitExpo Configuration
If you're using Expo, add the plugin to your app.json or app.config.js:
{
"expo": {
"plugins": [
"@elemanhill/react-native-activity-kit"
]
}
}The plugin automatically adds NSSupportsLiveActivities: true to your iOS Info.plist file.
Plugin Options
You can configure the plugin with options:
{
"expo": {
"plugins": [
[
"@elemanhill/react-native-activity-kit",
{
"NSSupportsLiveActivities": true
}
]
]
}
}| Option | Type | Default | Description |
|--------|------|---------|-------------|
| NSSupportsLiveActivities | boolean | true | Enables Live Activities support in your app |
Manual Setup
If you're not using Expo, you need to manually add the following to your iOS Info.plist:
<key>NSSupportsLiveActivities</key>
<true/>Contributing
Contribute a change to this template to update it for newer React Native versions.
Structure
android/: All yourandroid-specific implementations.build.gradle: The gradle build file. This contains four important pieces:- Standard react-native library boilerplate code
- Configures Kotlin (
apply plugin: 'org.jetbrains.kotlin.android') - Adds all Nitrogen files (
apply from: '.../NitroActivityKit+autolinking.gradle') - Triggers the native C++ build (via CMake/
externalNativeBuild)
CMakeLists.txt: The CMake build file to build C++ code. This contains four important pieces:- Creates a library called
NitroActivityKit(same as innitro.json) - Adds all Nitrogen files (
include(.../NitroActivityKit+autolinking.cmake)) - Adds all custom C++ files (only
HybridTestObjectCpp.cpp) - Adds a
cpp-adapter.cppfile, which autolinks all C++ HybridObjects (onlyHybridTestObjectCpp)
- Creates a library called
src/main/java/com/margelo/nitro/activitykit/: All Kotlin implementations.NitroActivityKitPackage.java: The react-native package. You need this because the react-native CLI only adds libraries if they have a*Package.javafile. In here, you can autolink all Kotlin HybridObjects.
cpp/: All your cross-platform implementations. (onlyHybridTestObjectCpp.cpp)ios/: All your iOS-specific implementations.nitrogen/: All files generated by nitrogen. You should commit this folder to git.src/: The TypeScript codebase. This defines all HybridObjects and loads them at runtime.specs/: All HybridObject types. Nitrogen will run on all*.nitro.tsfiles.
nitro.json: The configuration file for nitrogen. This will define all native namespaces, as well as the library name.NitroActivityKit.podspec: The iOS podspec build file to build the iOS code. This contains three important pieces:- Specifies the Pod's name. This must be identical to the name specified in
nitro.json. - Adds all of your
.swiftor.cppfiles (implementations). - Adds all Nitrogen files (
add_nitrogen_files(s))
- Specifies the Pod's name. This must be identical to the name specified in
package.json: The npm package.json file.react-native-nitro-modulesshould be apeerDependency.
