Apple Push Notification service (APNs) lets you send push notifications to Apple devices like macOS, iOS, tvOS, iPadOS, and watchOS devices. APNs is a best-effort service, and will attempt to deliver you messages to your device when it's online and available again. APNs will save the last message for 30 days or less and attempt delivery as soon as it's online.
Add provider
To add APNs as a provider, navigate to Messaging > Providers > Create provider > Push notification.
Give your provider a name > choose APNS > click Save and continue. The provider will be saved to your project, but not enabled until you complete its configuration.
Configure provider
In the Configure step, you will need to provide details from your Apple developer account to connect your Appwrite project with your Apple developer account.
You will need to provide the following information from the Apple Developer Member Center.
Team ID
Head to Apple Developer Member Center > Membership details > Team ID
Bundle ID
Head to Apple Developer Member Center > Program resources > Certificates, Identifiers & Profiles > Identifiers
Authentication key ID
Head to Apple Developer Member Center > Program resources > Certificates, Identifiers & Profiles > Keys. Click on your key to view details. The key needs Apple Push Notification Service enabled.
Authentication key (.p8 file)
Head to Apple Developer Member Center > Program resources > Certificates, Identifiers & Profiles > Keys. Create a key and give it a name. Enable the Apple Push Notifications service (APNS), and register your key. The key needs Apple Push Notification Service enabled.
Sandbox
Enable sandbox mode for testing on apps signed with development provisioning profiles. APNs offers two environments, Development (sandbox) and Production. Development builds on XCode signed with a development provisioning profile will use the development environment. Production builds signed with a production provisioning profile will use the production environment.
After adding the following details, click Save and continue to enable the provider.
Configure app
Some additional configuration is required to enable push notifications in your iOS app. Add push notification capability to your app by clicking your root-level app in XCode > Signing & Capabilities > Capabilities > Search for Push Notifications.
Test provider
Push notification requires special handling on the client side. Follow the Send push notification flow to test your provider.
Manage provider
You can update or delete a provider in the Appwrite Console.
Navigate to Messaging > Providers > click your provider. In the settings, you can update a provider's configuration or delete the provider.
To update or delete providers programmatically, use an Appwrite Server SDK.
const sdk = require('node-appwrite');
// Init SDK
const client = new sdk.Client();
const messaging = new sdk.Messaging(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<PROJECT_ID>') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
const provider = await messaging.updateApnsProvider(
'[PROVIDER_ID]', // providerId
'[NAME]', // name (optional)
false, // enabled (optional)
'[AUTH_KEY]', // authKey (optional)
'[AUTH_KEY_ID]', // authKeyId (optional)
'[TEAM_ID]', // teamId (optional)
'[BUNDLE_ID]' // bundleId (optional)
);