WixNotificationsAdapter
Notification adapter for Wix react-native-notifications library.
Work in Progress: The notification adapter APIs are under active development and may change in future releases.
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 { TeardownCore } from '@teardown/force-updates';
import { WixNotificationsAdapter } from '@teardown/force-updates/wix';
import { DeviceInfoAdapter } from '@teardown/force-updates/adapters/device-info';
import { AsyncStorageAdapter } from '@teardown/force-updates/adapters/async-storage';
const teardown = new TeardownCore({
org_id: 'your-org-id',
project_id: 'your-project-id',
api_key: 'your-api-key',
storageAdapter: new AsyncStorageAdapter(),
deviceAdapter: new DeviceInfoAdapter(),
notificationAdapter: new WixNotificationsAdapter(),
});
// Access via NotificationsClient
if (teardown.notifications) {
const status = await teardown.notifications.requestPermissions();
if (status.granted) {
const token = await teardown.notifications.getToken();
console.log('Push token:', token);
}
}Import Path
import { WixNotificationsAdapter } from '@teardown/force-updates/wix';API
All methods are accessed via NotificationsClient, not directly on the adapter.
requestPermissions()
Request notification permissions:
const status = await teardown.notifications.requestPermissions();
// Returns: { granted: boolean, canAskAgain: boolean }getToken()
Get the device push token:
const token = await teardown.notifications.getToken();
// Returns: device token string or nullonNotificationReceived()
Subscribe to foreground notifications:
const unsubscribe = teardown.notifications.onNotificationReceived((notification) => {
console.log('Received:', notification.title);
});
// Cleanup
unsubscribe();onNotificationOpened()
Subscribe to notification taps:
const unsubscribe = teardown.notifications.onNotificationOpened((notification) => {
console.log('User tapped:', notification.title);
});
// Cleanup
unsubscribe();onTokenRefresh()
Subscribe to token changes:
const unsubscribe = teardown.notifications.onTokenChange((token) => {
console.log('New token:', token);
});
// Cleanup
unsubscribe();onDataMessage()
Subscribe to data-only messages (silent push):
const unsubscribe = teardown.notifications.onDataMessage((message) => {
console.log('Data message:', message.data);
});
// 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;Platform
Returns NotificationPlatformEnum.APNS on iOS, NotificationPlatformEnum.FCM on Android.
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