React Native module for iOS APNs permission and token management
npm install react-native-apns-kitA React Native TurboModule that bridges Appleβs APNs (Apple Push Notification Service) APIs for iOS.
This library lets your React Native app or App Clip request push-notification permission, register with APNs, and retrieve the device token needed to send push notifications from your backend.
> [!NOTE]
>
> - This library was originally built for my work app, which uses the Bare React Native CLI (non-Expo).
> - Iβve open-sourced it so the wider React Native community can easily integrate APNS Support.
> - Pull requests are welcome β especially for Expo support (via custom config plugins) or additional native enhancements.
---
```
npm install react-native-apns-kit
Then install pods:
``
cd ios && pod install
---
> [!IMPORTANT]
>
> - iOS only (works for full apps, App Clips, and extensions).
> - The library does not handle local or scheduled notifications β it focuses purely on permission and token registration.
---
Enable Push Notifications capability in Xcode
In Xcode, select your App target (and App Clip target if used) β Signing & Capabilities β + Capability β Push Notifications.
Set aps-environment entitlement
Xcode will add an entitlements file automatically when you add Push Notifications. Confirm your \*.entitlements file contains:
``
Use development for debug builds; production for App Store / production provisioning.
App ID / Provisioning profile
In Apple Developer portal, for your App ID (and App Clip App ID), enable Push Notifications.
Recreate/download provisioning profiles so they include the push entitlement and install them in Xcode.
---
In your AppDelegate.swift, add:
`swift
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenParts = deviceToken.map { String(format: "%02x", $0) }
let token = tokenParts.joined()
print("β
APNs Device Token:", token)
UserDefaults.standard.set(token, forKey: "AppAPNSToken")
UserDefaults.standard.synchronize()
}
func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("β Failed to register for APNs:", error.localizedDescription)
}
`
> These callbacks are required β theyβre how iOS delivers the token back to your app.
---
- π Apple Docs: Registering for Remote Notifications
- π Apple Docs: Handling Notifications in Your App
- π§Ύ Apple Developer: About Push Notifications
---
Most React Native push libraries wrap Firebase or third-party SDKs.
If you only need native APNs registration β for enterprise, App Clips, or direct APNs backends β this lightweight module does exactly that and nothing more.
Built for production use in real apps, now open-sourced for the community.
---
This module wraps Appleβs UNUserNotificationCenter and UIApplication APIs and exposes:
`ts`
{
requestNotificationPermission(): Promise
getAPNSToken(): Promise
}
Example token (hex):
``
b0f6c67e7e81f9fa5e6c29163ce3a4b7e61d4c390f021f173b7d69c4e6c9c812
---
`tsx
import { requestNotificationPermission, getAPNSToken } from 'react-native-apns-kit';
import { Alert } from 'react-native';
export async function registerForPush() {
try {
const granted = await requestNotificationPermission();
if (!granted) {
Alert.alert(
'Notifications Disabled',
'Enable notifications in Settings.'
);
return;
}
const token = await getAPNSToken();
console.log('π² APNs Token:', token);
// Send to your backend for push targeting
await fetch('https://your-backend.com/api/register-token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token }),
});
} catch (err: any) {
Alert.alert('Error', err.message);
}
}
`
---
| Platform | Status |
| ---------------------------- | ---------------------- |
| iOS (13+) | β
Fully supported |
| App Clip | β
Supported |
| Android | π« Not applicable |
| Web | π« Not applicable |
| Expo (Custom Dev Client) | β
Works automatically |
---
This module wraps:
``
UNUserNotificationCenter.requestAuthorization(options)
UIApplication.registerForRemoteNotifications()
application:didRegisterForRemoteNotificationsWithDeviceToken
and saves the resulting token into NSUserDefaults` (or App Group if configured)
so the JS layer can safely retrieve it via TurboModule.
---
Pull requests are welcome β especially improvements for Swift extensions or App Group support!
- Development workflow
- Sending a pull request
- Code of conduct
---
MIT Β© Gautham Vijayan
---
Made with create-react-native-library