@notifymvp/react-native-sdk
v1.1.2
Published
Official React Native SDK for NotifyMVP — push notification platform
Maintainers
Readme
@notifymvp/react-native-sdk
Official React Native SDK for NotifyMVP.
npm: https://www.npmjs.com/package/@notifymvp/react-native-sdk
New integration? Start with SETUP.md.
npm install @notifymvp/react-native-sdkInstallation
npm install @notifymvp/react-native-sdk \
@react-native-firebase/app \
@react-native-firebase/messaging \
@notifee/react-native \
react-native-device-info \
react-native-encrypted-storage
# iOS only
cd ios && pod installSetup
Android — android/build.gradle
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.4.0'
}
}Android — android/app/build.gradle
apply plugin: 'com.google.gms.google-services'Download google-services.json from Firebase Console → place in android/app/.
iOS — ios/AppDelegate.swift
import Firebase
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions ...) -> Bool {
FirebaseApp.configure()
return true
}
}Download GoogleService-Info.plist → place in ios/<AppName>/.
Rich Push (imageUrl + actions)
Requires @notifee/react-native (v7.8+). The server sends data-only rich payloads (notifymvp_rich=1) with imageUrl, iconUrl, and optional data.actions.
Background / killed (Android): register the SDK handler at the top of your entry file:
import messaging from '@react-native-firebase/messaging';
import { notifyMvpFirebaseBackgroundHandler } from '@notifymvp/react-native-sdk';
messaging().setBackgroundMessageHandler(notifyMvpFirebaseBackgroundHandler);Foreground: NotifyMVP.onForegroundMessage(...) displays rich notifications by default (displayRich: false to disable).
Channel id: notifymvp_heads_up_channel (created on NotifyMVP.initialize()).
baseUrl
baseUrl is your NotifyMVP Cloudflare Worker URL (no trailing slash).
After you deploy my-app/ with Wrangler:
https://notifymvp.<your-account>.workers.dev- or
https://notify.yourdomain.com
Usage
index.js / app entry
import messaging from '@react-native-firebase/messaging';
import {
NotifyMVP,
notifyMvpFirebaseBackgroundHandler,
} from '@notifymvp/react-native-sdk';
messaging().setBackgroundMessageHandler(notifyMvpFirebaseBackgroundHandler);
// Initialize SDK once at app start
await NotifyMVP.initialize({
appId: 'app_xxxxxxxx', // Dashboard → Projects → App ID
apiKey: 'your_api_key', // Dashboard → Projects → API Key
baseUrl: 'https://your-worker.workers.dev', // your Cloudflare Worker URL
debugLogging: __DEV__,
});Foreground notifications (inside component)
useEffect(() => {
const unsubscribe = NotifyMVP.onForegroundMessage((title, body, data) => {
console.log('Foreground:', title, body);
// Show local notification or update UI
});
return unsubscribe;
}, []);Manual re-register / external user id
const result = await NotifyMVP.register();
if (result.isSuccess) {
console.log('Re-registered!');
}
await NotifyMVP.setExternalUserId('user_12345');API
| Method | Description |
|--------|-------------|
| NotifyMVP.initialize(config) | Init SDK, request permission, register device |
| NotifyMVP.register() | Manually register / re-register |
| NotifyMVP.setExternalUserId(id) | Link / clear external user id, then re-register |
| NotifyMVP.onForegroundMessage(handler) | Listen for foreground messages |
| NotifyMVP.onNotificationOpened(handler) | Tap while app in background — use url to route |
| NotifyMVP.getInitialNotification() | Cold start from notification tap (url in payload) |
| NotifyMVP.fcmToken | Current FCM token |
| NotifyMVP.externalUserId | Last linked user id |
| NotifyMVP.isInitialized | Boolean — SDK ready? |
Deep link / Launch URL (OneSignal-style)
In the dashboard, set Launch URL / Deep link when sending. It arrives as data.url.
NotifyMVP.onNotificationOpened(({ title, body, url, data }) => {
if (url) {
// Linking.openURL(url) or navigation.navigate(url)
}
});
const initial = await NotifyMVP.getInitialNotification();
if (initial?.url) {
// navigate using initial.url
}