npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

expo-bare-kit

0.1.1

@tonygo

npmHomeRepoSnykSocket
Downloads:4
$ npm install expo-bare-kit
DailyWeeklyMonthlyYearly

expo-bare-kit

Expo config plugin for react-native-bare-kit. Handles all native scaffolding so you can use Bare Kit in a managed Expo workflow.

Install

npm install expo-bare-kit react-native-bare-kit

Setup

Add the plugin to your app.json (or app.config.js):

{
  "expo": {
    "plugins": [
      [
        "expo-bare-kit",
        {
          "ios": {
            "notifications": {
              "worklet": "push.bundle"
            }
          },
          "android": {
            "notifications": {
              "worklet": "push.bundle",
              "googleServices": "google-services.json"
            }
          }
        }
      ]
    ]
  }
}

Then run prebuild:

npx expo prebuild

Plugin options

iOS notifications

Enable by setting ios.notifications to an object. Omit or set to null to skip.

[
  "expo-bare-kit",
  {
    "ios": {
      "notifications": {
        "worklet": "push.bundle",
        "targetName": "NotificationServiceExtension"
      }
    }
  }
]
OptionTypeDefaultDescription
workletstringrequiredPath to the push notification worklet bundle
targetNamestring'NotificationServiceExtension'Name of the Xcode extension target

Android notifications

Enable by setting android.notifications to an object. Omit or set to null to skip.

[
  "expo-bare-kit",
  {
    "android": {
      "notifications": {
        "worklet": "push.bundle",
        "googleServices": "google-services.json",
        "channelId": "default",
        "channelName": "Notifications"
      }
    }
  }
]
OptionTypeDefaultDescription
workletstringrequiredPath to the push notification worklet bundle
googleServicesstringrequiredPath to google-services.json from Firebase
channelIdstring'default'Android notification channel ID
channelNamestring'Notifications'Display name for the notification channel

Push worklet

The worklet is a JavaScript file that runs in a Bare runtime when a push notification arrives. It must be bundled with bare-pack before use:

npx bare-pack --preset <ios|android> --out push.bundle push.js

Example push.js:

// BareKit is a global provided by the Bare runtime
BareKit.on('push', (payload, reply) => {
  const { data } = JSON.parse(payload)

  reply(
    null,
    JSON.stringify({
      title: data.title || 'Notification',
      body: data.body || 'New message received'
    })
  )
})

The worklet receives the push payload as a JSON string and must reply with a JSON string containing title and body.

API

This package re-exports everything from react-native-bare-kit:

import { Worklet } from 'expo-bare-kit'

License

Apache-2.0