Skip to content

Commit e7e47f8

Browse files
authored
Merge pull request #229 from lucarosty/master
Fix missing httpAgent for proxy support
2 parents 2d840ac + ce877a9 commit e7e47f8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ A node.js module for interfacing with Apple Push Notification, Google Cloud Mess
2121
- [ADM](#adm)
2222
- [Web-Push](#web-push)
2323
- [Resources](#resources)
24+
- [Proxy](#proxy)
2425
- [LICENSE](#license)
2526

2627
## Installation
@@ -684,6 +685,28 @@ webPush.sendNotification(regId, payload, settings.web);
684685
685686
A working server example implementation can be found at [https://github.com/alex-friedl/webpush-example/blob/master/server/index.js](https://github.com/alex-friedl/webpush-example/blob/master/server/index.js)
686687
688+
## Proxy
689+
690+
To use the module with a proxy:
691+
692+
```
693+
import { HttpsProxyAgent } from 'https-proxy-agent';
694+
...
695+
const settings = {
696+
fcm: {
697+
...,
698+
httpAgent = new HttpsProxyAgent(`http://${env.proxy.host}:${env.proxy.port}`);
699+
},
700+
apn: {
701+
...
702+
proxy: {
703+
host: <proxy_address>,
704+
port: <proxy_port>
705+
}
706+
}
707+
};
708+
```
709+
687710
## Resources
688711
689712
- [Crossplatform integration example using this library and a React Native app](https://github.com/alex-friedl/crossplatform-push-notifications-example)

src/sendFCM.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const sendFCM = (regIds, data, settings) => {
6767
const opts = {
6868
credential:
6969
settings.fcm.credential || firebaseAdmin.credential.cert(settings.fcm.serviceAccountKey),
70+
httpAgent: settings.fcm.httpAgent || undefined
7071
};
7172

7273
const firebaseApp = firebaseAdmin.initializeApp(opts, appName);

0 commit comments

Comments
 (0)