vibes-react-native-expo
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

vibes-react-native-expo

Push SDK for Expo

Installation

npx expo install vibes-react-native-expo

Usage

import Vibes from 'vibes-react-native-expo';

Setup

Android

In your expo-build-properties plugin, add the following repository to your gradle.properties.

"plugins": [
  [
    "expo-build-properties",
    {
      "android": {
        "repositories": {
            maven {
                url "https://maven.pkg.github.com/vibes/android-sdk-repository"
                credentials {
                    username = System.getenv("VIBES_GITHUB_USERNAME") ?: ""
                    password = System.getenv("VIBES_GITHUB_PASSWORD") ?: ""
                }
            }
        }
      }
    }
  ]
]

Also, set the required manifest placeholders in your app.json:

"android": {
  "config": {
    "googleServicesFile": "./google-services.json"
  },
  "manifestPlaceholders": {
    "vibesAppId": "YOUR_VIBES_APPID",
    "vibesApiUrl": "VIBES_API_URL"
  }
}

iOS

In your app.json or app.config.js, add the following to the expo.plugins section:

"expo.plugins": [
  [
    "expo-build-properties",
    {
      "ios": {
        "infoPlist": {
          "VibesAppId": "YOUR_VIBES_APPID",
          "VibesApiURL": "VIBES_API_URL"
        }
      }
    }
  ]
]

Push Notifications Usage

The SDK automatically registers the device and push token when the app starts.

Registering and Unregistering

await VibesReactNativeExpo.registerDevice();
await VibesReactNativeExpo.unregisterDevice();
await VibesReactNativeExpo.registerPush();
await VibesReactNativeExpo.unregisterPush();

Get Device Info

const deviceInfo = await VibesReactNativeExpo.getVibesDeviceInfo();
console.log(deviceInfo);

Handling Push Notifications

Register event listeners to handle push notifications:

import { addEventListener } from 'vibes-react-native-expo';

addEventListener('pushReceived', (event) => {
  console.log('Push received:', event.payload);
});

addEventListener('pushOpened', (event) => {
  console.log('Push opened:', event.payload);
});

Associate a Person

await VibesReactNativeExpo.associatePerson('user@example.com');

Fetch Inbox Messages

const messages = await VibesReactNativeExpo.fetchInboxMessages();
console.log(messages);

Mark Inbox Message as Read

await VibesReactNativeExpo.markInboxMessageAsRead('message_uid');

Expire an Inbox Message

await VibesReactNativeExpo.expireInboxMessage('message_uid');

Rich Push Support

For Android, ensure your project includes the appropriate drawable icon and notification sound settings. For iOS, add a Notification Service Extension to support rich push notifications.

For more details, refer to the Vibes documentation.

License

MIT

ry { const fs = require('fs');

if (fs.existsSync('ios/Podfile')) { const podfileContent = fs.readFileSync('ios/Podfile', 'utf8');

if (podfileContent.includes("pod 'VibesPush'") || podfileContent.includes('pod "VibesPush"')) {
  process.exit(0);
}

if (podfileContent.includes('use_expo_modules!')) {
  const updatedContent = podfileContent.replace(
    /use_expo_modules!/,
    "use_expo_modules!\n  pod 'VibesPush', :modular_headers => true"
  );
  
  fs.writeFileSync('ios/Podfile', updatedContent);
} else {
  fs.appendFileSync('ios/Podfile', "\npod 'VibesPush', :modular_headers => true\n");
}

} } catch (error) { process.exit(0); }

{"SDKBuildVersion": "Unavailable (Mock)", "addListener": [Function bound addListener], "associatePerson": [Function associatePerson], "emit": [Function bound emit], "expireInboxMessage": [Function expireInboxMessage], "fetchInboxMessage": [Function fetchInboxMessage], "fetchInboxMessages": [Function fetchInboxMessages], "getPerson": [Function getPerson], "listenerCount": [Function bound listenerCount], "markInboxMessageAsRead": [Function markInboxMessageAsRead], "onInboxMessageOpen": [Function onInboxMessageOpen], "onInboxMessagesFetched": [Function onInboxMessagesFetched], "registerDevice": [Function registerDevice], "registerPush": [Function registerPush], "removeAllListeners": [Function bound removeAllListeners], "removeListener": [Function bound removeListener], "setValueAsync": [Function setValueAsync], "unregisterDevice": [Function unregisterDevice], "unregisterPush": [Function unregisterPush], "updateDevice": [Function updateDevice]}

Package Sidebar

Install

npm i vibes-react-native-expo

Weekly Downloads

91

Version

0.2.3

License

MIT

Unpacked Size

50.3 kB

Total Files

36

Last publish

Collaborators

  • clement.wekesa
  • simon_g