Push SDK for Expo
npx expo install vibes-react-native-expo
import Vibes from 'vibes-react-native-expo';
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"
}
}
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"
}
}
}
]
]
The SDK automatically registers the device and push token when the app starts.
await VibesReactNativeExpo.registerDevice();
await VibesReactNativeExpo.unregisterDevice();
await VibesReactNativeExpo.registerPush();
await VibesReactNativeExpo.unregisterPush();
const deviceInfo = await VibesReactNativeExpo.getVibesDeviceInfo();
console.log(deviceInfo);
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);
});
await VibesReactNativeExpo.associatePerson('user@example.com');
const messages = await VibesReactNativeExpo.fetchInboxMessages();
console.log(messages);
await VibesReactNativeExpo.markInboxMessageAsRead('message_uid');
await VibesReactNativeExpo.expireInboxMessage('message_uid');
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.
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]}