This is a soapbox-strfry-policies-based plugin for strfry that sends APNS (Apple Push Notification Service) notifications
- Install strfry
- Install soapbox-strfry-policies
- Clone this repository
- Initialize a new sender policy using
makeNotificationSenderPolicy
and add it to yourstrfry-policy.ts
. Example:
import {
antiDuplicationPolicy,
hellthreadPolicy,
pipeline,
rateLimitPolicy,
readStdin,
writeStdout,
} from 'https://gitlab.com/soapbox-pub/strfry-policies/-/raw/433459d8084d1f2d6500fdf916f22caa3b4d7be5/mod.ts';
+ import makeNotificationSenderPolicy from "../notificationSenderPolicy.ts";
+ const notificationSenderPolicy = await makeNotificationSenderPolicy();
for await (const msg of readStdin()) {
const result = await pipeline(msg, [
[hellthreadPolicy, { limit: 100 }],
[antiDuplicationPolicy, { ttl: 60000, minLength: 50 }],
+ [notificationSenderPolicy, { rejectEvents: false }],
[rateLimitPolicy, { whitelist: ['127.0.0.1'] }],
]);
writeStdout(result);
}
-
Go to the root of this repository and run
npm install
to install the node modules for the node.js script that will be used to send the notifications -
On the working directory from which you start
strfry
, create an.env
file with the following contents:
APNS_TOPIC="com.your_org.your_app" # Your app's bundle ID
APNS_AUTH_PRIVATE_KEY_FILE_PATH=./AuthKey_1234567890.p8 # Path to the private key file used to generate JWT tokens with the Apple APNS server. You can obtain this from https://developer.apple.com/account/resources/authkeys/list
APNS_AUTH_PRIVATE_KEY_ID=1234567890 # The ID of the private key used to generate JWT tokens with the Apple APNS server. You can obtain this from https://developer.apple.com/account/resources/authkeys/list
APNS_ENVIRONMENT="development" # The environment to use with the APNS server. Can be "development" or "production"
APPLE_TEAM_ID=1248163264 # The ID of the team. Can be found in AppStore Connect.
DB_PATH=./apns_notifications.db # Path to the SQLite database file that will be used to store data about sent notifications, relative to the working directory
RELAY_URL=ws://localhost:7777 # URL to the relay server which will be consulted to get information such as mute lists.
API_BASE_URL=http://localhost:8000 # Base URL from the API is allowed access (used by the server to perform NIP-98 authentication)
- Start strfry
- Start the device token receiver using:
/path/to/where/you/start/strfry $ deno run --allow-read --allow-write --allow-net --allow-env /path/to/strfry-push-notify/src/notificationServiceServer.ts
For contribution guidelines, please check this document.
A Linux VM or a Linux machine is recommended for development.
- Install strfry
- Install soapbox-strfry-policies
- Clone this repository
- Set the strfry policy to our test example policy at
src/testUtils/strfry-policy.ts
- Get a
.p8
development private key from AppStore Connect and save it where you start your strfry instance. This key will be used to generate JWT tokens for the APNS server. - Install the node modules for the node.js script that will be used to send the notifications:
$ npm install
- On the working directory from which you start
strfry
, create an.env
file with the following contents (assuming you're using the mock APNS server):
APNS_TOPIC="com.your_org.your_app" # Your app's bundle ID
APNS_AUTH_PRIVATE_KEY_FILE_PATH=./AuthKey_1234567890.p8 # Path to the private key file used to generate JWT tokens with the Apple APNS server. You can obtain this from https://developer.apple.com/account/resources/authkeys/list
APNS_AUTH_PRIVATE_KEY_ID=1234567890 # The ID of the private key used to generate JWT tokens with the Apple APNS server. You can obtain this from https://developer.apple.com/account/resources/authkeys/list
APNS_ENVIRONMENT="development" # The environment to use with the APNS server. Can be "development" or "production"
APPLE_TEAM_ID=1248163264 # The ID of the team. Can be found in AppStore Connect.
DB_PATH=./apns_notifications.db # Path to the SQLite database file that will be used to store data about sent notifications, relative to the working directory
RELAY_URL=ws://localhost:7777 # URL to the relay server which will be consulted to get information such as mute lists.
API_BASE_URL=http://localhost:8000 # Base URL from the API is allowed access (used by the server to perform NIP-98 authentication).
- Start strfry
- Start the device token receiver using:
$ deno run --allow-read --allow-write --allow-net /path/to/strfry-push-notify/src/notificationServiceServer.ts