
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
localnotification-react-native-sdk
Advanced tools
React Native SDK for LocalNotification - Remote local notification management with user segmentation and analytics
React Native SDK for LocalNotification - Remote local notification management with user segmentation and analytics.
npm install @aspect-music/localnotification-react-native
# or
yarn add @aspect-music/localnotification-react-native
# or
pnpm add @aspect-music/localnotification-react-native
npm install expo-notifications react react-native
Wrap your app with LocalNotificationProvider:
import { LocalNotificationProvider } from '@aspect-music/localnotification-react-native';
export default function App() {
return (
<LocalNotificationProvider
config={{
apiUrl: 'https://your-api.com',
appId: 'your-app-id',
apiKey: 'your-api-key', // optional
syncInterval: 60000, // sync every 60 seconds
trackSessions: true, // enable session tracking for analytics
}}
>
<YourApp />
</LocalNotificationProvider>
);
}
import { useLocalNotificationContext } from '@aspect-music/localnotification-react-native';
function MyComponent() {
const {
notifications,
segments,
isInitialized,
isLoading,
error,
sync,
setUserContext,
updateUserProperties,
triggerNotification,
} = useLocalNotificationContext();
// Set user context with properties for segmentation
useEffect(() => {
setUserContext({
userId: 'user-123',
locale: 'en',
timezone: 'America/New_York',
properties: {
total_played_games: 25,
is_premium: true,
level: 10,
},
});
}, []);
// Update user properties dynamically
const handleGameComplete = async () => {
await updateUserProperties({
total_played_games: 26,
last_game_date: new Date().toISOString(),
});
};
return (
<View>
<Text>Notifications: {notifications.length}</Text>
<Button title="Refresh" onPress={sync} disabled={isLoading} />
</View>
);
}
For simpler use cases without context:
import { useLocalNotifications } from '@aspect-music/localnotification-react-native';
function MyComponent() {
const {
notifications,
segments,
isInitialized,
isLoading,
error,
sync,
setUserContext,
updateUserProperties,
triggerNotification,
} = useLocalNotifications({
apiUrl: 'https://your-api.com',
appId: 'your-app-id',
});
// ...
}
For advanced use cases:
import { createLocalNotificationSDK } from '@aspect-music/localnotification-react-native';
const sdk = createLocalNotificationSDK({
apiUrl: 'https://your-api.com',
appId: 'your-app-id',
apiKey: 'your-api-key',
trackSessions: true,
});
await sdk.initialize();
// Set user context
await sdk.setUserContext({
userId: 'user-123',
properties: {
total_played_games: 25,
is_premium: true,
},
});
// Update properties
await sdk.updateUserProperties({
total_played_games: 26,
});
// Manual sync
await sdk.sync();
// Trigger a notification immediately
await sdk.triggerImmediate('notification-id');
// Get cached data
const notifications = sdk.getNotifications();
const segments = sdk.getSegments();
const userContext = sdk.getUserContext();
// Cleanup
await sdk.destroy();
| Option | Type | Default | Description |
|---|---|---|---|
apiUrl | string | required | Base URL of your LocalNotification API |
appId | string | required | Your application ID |
apiKey | string | optional | API key for authentication |
syncInterval | number | 60000 | Auto-sync interval in milliseconds |
trackSessions | boolean | true | Enable automatic session tracking |
The SDK automatically filters notifications based on user segments defined in the admin panel.
// Via context
await setUserContext({
userId: 'user-123',
properties: {
total_played_games: 25,
is_premium: true,
country: 'US',
},
});
// Update specific properties
await updateUserProperties({
total_played_games: 26,
last_login: new Date().toISOString(),
});
Segments are defined in the admin panel with rules like:
total_played_games > 20is_premium = truecountry in ["US", "CA", "UK"]Notifications attached to a segment will only be shown to matching users.
Notification titles and bodies support dynamic text using {{property}} syntax:
Title: "Welcome back, {{userId}}!"
Body: "You've played {{total_played_games}} games!"
When trackSessions is enabled, the SDK automatically tracks:
This data powers the analytics dashboard with:
Displayed immediately when conditions are met.
Displayed at a specific date and time.
Displayed on a schedule:
Full TypeScript support with exported types:
import type {
SDKConfig,
UserContext,
Notification,
UserProperties,
Condition,
Trigger,
Segment,
} from '@aspect-music/localnotification-react-native';
| Prop | Type | Description |
|---|---|---|
config | SDKConfig | SDK configuration |
children | ReactNode | Child components |
autoInitialize | boolean | Auto-initialize on mount (default: true) |
Returns:
notifications: Notification[] - Cached notificationssegments: SegmentInfo[] - Available segmentsisInitialized: boolean - SDK initialization statusisLoading: boolean - Loading stateerror: Error | null - Last errorsync(): Promise<void> - Manual syncsetUserContext(context): Promise<void> - Set user contextupdateUserProperties(props): Promise<void> - Update user propertiestriggerNotification(id): Promise<void> - Trigger notificationMethods:
initialize(): Promise<void>setUserContext(context: UserContext): Promise<void>updateUserProperties(properties: UserProperties): Promise<void>sync(): Promise<SyncResponse>syncDelta(): Promise<SyncResponse>triggerImmediate(notificationId: string): Promise<void>getNotifications(): Notification[]getSegments(): SegmentInfo[]getUserContext(): UserContextstopAutoSync(): voiddestroy(): Promise<void>MIT
FAQs
React Native SDK for LocalNotification - Remote local notification management with user segmentation and analytics
We found that localnotification-react-native-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.