Skip to content

BlueWallet/react-native-live-activity

 
 

Repository files navigation

react-native-live-activity

This is an example of a Native Module to control the iOS Live Activities.

Installation

npm install react-native-live-activity

Build your Swift module

Take inspiration from the example to build your own Swift module.

Usage

import LiveActivity from 'react-native-live-activity';

// Please be careful to use the same type as the one you defined in your Swift module.
type LiveActivityParams = {
  status: string;
  driverName: string;
  expectedDeliveryTime: string;
}

const liveActivity = new LiveActivity<LiveActivityParams>()

const activity = await liveActivity.startActivity({
  status: "Packing",
  driveName: "John",
  expectedDeliveryTime: "12 PM"
})

await liveActivity.updateActivity(activity.id, {
  status: "Driving",
  driveName: "John",
  expectedDeliveryTime: "12 PM"
})

await liveActivity.endActivity(activity.id)

const [activities, setActivities] = React.useState<any[]>([])
liveActivity.listAllActivities().then(setActivities)

Example

Run

$ yarn install

Then

$ open ./example/ios/LiveActivityExample.xcworkspace

After that build the xCode project.

Simulator.Screen.Recording.-.iPhone.14.Pro.-.2022-09-28.at.10.20.58.mp4

License

MIT


Made with create-react-native-library

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 33.1%
  • C++ 15.0%
  • TypeScript 14.7%
  • Swift 11.8%
  • Objective-C++ 7.8%
  • Ruby 5.3%
  • Other 12.3%