@exxili/capacitor-ios-background-push v0.0.21
@exxili/capacitor-ios-background-push
š§ Alpha Release - Work in Progress Note: The plugin is currently working, Still work in progress - as/when i get time i will update this to include tests
Please note that this plugin is currently under active development and may be subject to changes or updates.
A Capacitor plugin designed to handle iOS Silent Push notifications, enabling background updates, processing, and seamless integration with standard push notifications.
ā ļø iOS-specific Support
This plugin is specifically designed for iOS and does not support Android. It handles Silent Push notifications on iOS devices, providing a seamless integration with standard push notifications.
š Getting Started
Follow the steps below to integrate the plugin into your Capacitor project:
- Install the plugin using npm:
npm install @exxili/capacitor-ios-background-push
- Sync your Capacitor project:
npx cap sync
Import the plugin in your project and use it to listen for remote notifications:
import { IOSBackgroundPush } from '@exxili/capacitor-ios-background-push';
// Add a listener for silent push notifications
IOSBackgroundPush.addListener('SilentNotificationReceived', (data) => {
console.log('Silent push notification received:', data);
});
- Update your AppDelegate.swift file in your iOS project to handle Silent Push notifications. Add the following method to your AppDelegate class:
import UIKit
import Capacitor
import ExxiliCapacitorIosBackgroundPush
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
// ... other existing code ...
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
NotificationCenter.default.post(name: .didReceiveRemoteNotificationForIOSBackgroundPush, object: nil, userInfo: [
"userInfo": userInfo,
"completionHandler": completionHandler
])
}
}
API
addListener('SilentNotificationReceived', ...)
addListener(eventName: 'SilentNotificationReceived', listenerFunc: (data: { data: any; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Called when a silent push notification is received.
Param | Type |
---|---|
eventName | 'SilentNotificationReceived' |
listenerFunc | (data: { data: any; }) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Interfaces
PluginListenerHandle
Prop | Type |
---|---|
remove | () => Promise<void> |