forked from nation3/mobile-passport
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(apple): separate apn provider code (nation3#76)
- Loading branch information
1 parent
59c28e6
commit bbfa591
Showing
3 changed files
with
27 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
import apn, { Responses } from 'apn' | ||
import { config } from './Config'; | ||
|
||
/** | ||
* Apple Push Notification (APN) provider. | ||
*/ | ||
export class APNProvider { | ||
|
||
|
||
static async sendNotification(pushToken: string): Promise<Responses> { | ||
console.info('[APNProvider.ts] sendNotification') | ||
|
||
const apnProvider: apn.Provider = new apn.Provider({ | ||
cert: `-----BEGIN CERTIFICATE-----\n${config.appleCertificatePEM}\n-----END CERTIFICATE-----`, | ||
key: `-----BEGIN RSA PRIVATE KEY-----\n${config.appleCertificateKey}\n-----END RSA PRIVATE KEY-----`, | ||
production: true | ||
}) | ||
const notification: apn.Notification = new apn.Notification(); | ||
notification.topic = 'pass.org.passport.nation3' | ||
console.info('[APNProvider.ts] Sending notification...') | ||
return await apnProvider.send(notification, pushToken) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters