WixNotificationsAdapter
Notification adapter for Wix react-native-notifications library.
The WixNotificationsAdapter integrates with Wix's react-native-notifications library.
Installation
npm install react-native-notifications
# or
bun add react-native-notificationsFor iOS:
cd ios && pod installUsage
import { WixNotificationsAdapter } from '@teardown/react-native/wix-notifications';
const notifications = new WixNotificationsAdapter();
// Request permissions
const granted = await notifications.requestPermissions();
if (granted) {
// Get push token
const token = await notifications.getToken();
console.log('Push token:', token);
}Import Path
import { WixNotificationsAdapter } from '@teardown/react-native/wix-notifications';API
getToken()
Get the device push token:
const token = await notifications.getToken();
// Returns: device token string or nullrequestPermissions()
Request notification permissions:
const granted = await notifications.requestPermissions();
// Returns: true if granted, false otherwiseisEnabled()
Check if notifications are enabled:
const enabled = await notifications.isEnabled();onNotification()
Subscribe to incoming notifications:
const unsubscribe = notifications.onNotification((notification) => {
console.log('Received:', notification.title);
});
// Cleanup
unsubscribe();onNotificationResponse()
Subscribe to notification opens:
const unsubscribe = notifications.onNotificationResponse((response) => {
console.log('User tapped:', response.notification.title);
});
// Cleanup
unsubscribe();Configuration
iOS
- Enable Push Notifications capability in Xcode
- Add to
AppDelegate.m:
#import <RNNotifications.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[RNNotifications startMonitorNotifications];
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
[RNNotifications didFailToRegisterForRemoteNotificationsWithError:error];
}Android
- Add Firebase configuration (google-services.json)
- Initialize in
MainApplication.java:
import com.wix.reactnativenotifications.RNNotificationsPackage;When to Use
- Existing projects using react-native-notifications
- Projects requiring fine-grained notification control
- Cross-platform notification handling
Requirements
react-native-notifications>= 4.0.0- React Native >= 0.60