[BREAKGLASS] Append-only mirror of github.com/bluewallet/react-native-live-activity
Go to file
Cristiano Alves 4c339fab26
Merge pull request #7 from G2Jose/master
Prevent crash on macOS, update library interface for simplicity, fix return value of `startActivity`
2024-05-14 17:26:38 +01:00
android chore: initial commit 2022-09-19 10:13:24 +01:00
example Make all methods awaitable 2024-04-07 03:12:32 -04:00
ios Make all methods awaitable 2024-04-07 03:12:32 -04:00
scripts chore: initial commit 2022-09-19 10:13:24 +01:00
src Make all methods awaitable 2024-04-07 03:12:32 -04:00
.editorconfig chore: initial commit 2022-09-19 10:13:24 +01:00
.gitattributes chore: initial commit 2022-09-19 10:13:24 +01:00
.gitignore chore: initial commit 2022-09-19 10:13:24 +01:00
.watchmanconfig chore: initial commit 2022-09-19 10:13:24 +01:00
.yarnrc chore: initial commit 2022-09-19 10:13:24 +01:00
babel.config.js chore: initial commit 2022-09-19 10:13:24 +01:00
CONTRIBUTING.md chore: initial commit 2022-09-19 10:13:24 +01:00
LICENSE chore: initial commit 2022-09-19 10:13:24 +01:00
package.json Add contributor 2024-02-03 14:47:10 -05:00
react-native-live-activity.podspec chore: initial commit 2022-09-19 10:13:24 +01:00
README.md Update library interface to be easier to use 2024-02-03 14:41:12 -05:00
tsconfig.build.json chore: initial commit 2022-09-19 10:13:24 +01:00
tsconfig.json Get project building again 2024-02-03 14:40:57 -05:00
yarn.lock Get project building again 2024-02-03 14:40:57 -05:00

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.

https://user-images.githubusercontent.com/3778297/192741742-9d3a9bc5-e26a-4197-b152-5f60796736eb.mp4

License

MIT


Made with create-react-native-library