Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ For the full configuration you need to set the following directory structure up:
* token.json - `FCM` service account JSON file

If you want to use `APNS` token authentication you need to provide token and set `key_id` and `team_id` environmental variables. To see how to obtain token and `key_id` read:
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token_based_connection_to_apns
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token_based_connection_to_apns
To see how to obtain `team_id` read: https://www.mobiloud.com/help/knowledge-base/ios-app-transfer/
`FCM` JSON file can be generated by Firebase console (https://console.firebase.google.com). Go to your project -> `Project Settings` -> `Service accounts` -> `Generate new private key`
`FCM` JSON file can be generated by Firebase console (https://console.firebase.google.com). Go to your project -> `Project Settings` -> `Service accounts` -> `Generate new private key`
Assuming that you have the `priv` directory with all ceriticates and fcm token in current directory, then you may start MongoosePush with the following command:

```bash
Expand Down Expand Up @@ -111,7 +111,7 @@ Environmental variables to configure production release:
> It is however highly recommended to build MongoosePush with Erlang/OTP 21.x.
* Rebar3 (just enter ```mix local.rebar```)

#### Build and run
#### Build and run of production release

Build step is really easy. Just type in root of the repository:
```bash
Expand All @@ -120,10 +120,30 @@ MIX_ENV=prod mix do deps.get, compile, certs.dev, distillery.release

After this step you may try to run the service via:
```bash
_build/prod/rel/mongoose_push/bin/mongoose_push console
_build/prod/rel/mongoose_push/bin/mongoose_push foreground
```

Yeah, I know... It crashed. Running this service is fast and simple but unfortunately you can't have push notifications without properly configured `FCM` and/or `APNS` service. You can find out how to properly configure it in `Configuration` section of this README.

#### Build and run of development release

Build step is really easy. Just type in root of the repository:
```bash
MIX_ENV=dev mix do deps.get, compile, certs.dev, distillery.release
```

Development release is by default configured to connect to local APNS / FCM mock. This configuration may be changed as needed
in `config/dev.exs` file.
For now, let's just start those mocks so that we can use default dev configuration:
```bash
docker-compose -f test/docker/docker-compose.yml up -d
```

After this step you may try to run the service via:
```bash
_build/dev/rel/mongoose_push/bin/mongoose_push console
```

Yeah, I know... It crashed. Running this service is fast and simple but unfortunately you can't have push notifications without properly configured `FCM` and/or `APNS` service. So, lets configure it!

### Running tests

Expand Down Expand Up @@ -179,7 +199,8 @@ config :mongoose_push, fcm: [
appfile: "path/to/token.json",
endpoint: "localhost",
pool_size: 5,
mode: :prod
mode: :prod,
tls_opts: []
]
]
```
Expand All @@ -191,7 +212,9 @@ Each `FCM` pool may be configured by setting the following fields:
* **pool_size** (*required*) - maximum number of used `HTTP/2` connections to google's service
* **mode** (*either `:prod` or `:dev`*) - pool's mode. The `HTTP` client may select pool used to push a notification by specifying matching option in the request
* **endpoint** (*optional*) - URL override for `FCM` service. Useful mainly in tests
* **port** (*optional*) - Port number override for `FCM` service. Useful mainly in tests
* **tags** (*optional*) - a list of tags. Used when choosing pool to match request tags when sending a notification. More details: https://github.com/esl/sparrow#tags
* **tls_opts** (*optional*) - a list of raw options passed to `ssl:connect` function call while connecting to `FCM`. When this option is omitted, it will default to set of values that will verify server certificate based on internal CA chain. Providing this option overrides all defaults, effectively disabling certificate validation. Therefore passing this option is not recommended outside dev and test environments.

You may entirely skip the `FCM` config entry to disable `FCM` support.

Expand All @@ -205,14 +228,16 @@ config :mongoose_push, apns: [
key: "priv/apns/dev_key.pem",
mode: :dev,
use_2197: false,
pool_size: 5
pool_size: 5,
tls_opts: []
],
prod: [
cert: "priv/apns/prod_cert.pem",
key: "priv/apns/prod_key.pem",
mode: :prod,
use_2197: false,
pool_size: 5
pool_size: 5,
tls_opts: []
]
]
```
Expand All @@ -224,8 +249,10 @@ Each `APNS` pool may be configured by setting the following fields:
* **pool_size** (*required*) - maximum number of used `HTTP/2` connections to google's service
* **mode** (*either `:prod` or `:dev`*) - pool's mode. The `HTTP` client may select pool used to push a notification by specifying matching option in the request
* **endpoint** (*optional*) - URL override for `APNS` service. Useful mainly in tests
* **port** (*optional*) - Port number override for `APNS` service. Useful mainly in tests
* **use_2197** (*optional `true` or `false`*) - whether use alternative port for `APNS`: 2197
* **tags** (*optional*) - a list of tags. Used when choosing pool to match request tags when sending a notification. More details: https://github.com/esl/sparrow#tags
* **tls_opts** (*optional*) - a list of raw options passed to `ssl:connect` function call while connecting to `APNS`. When this option is omitted, it will default to set of values that will verify server certificate based on internal CA chain. Providing this option overrides all defaults, effectively disabling certificate validation. Therefore passing this option is not recommended outside dev and test environments.

You may entirely skip the `APNS` config entry to disable `APNS` support.

Expand Down
10 changes: 7 additions & 3 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ config :mongoose_push,
fcm: [
default: [
endpoint: "localhost",
port: 4000,
appfile: "priv/fcm/token.json",
pool_size: 5,
mode: :prod
mode: :prod,
tls_opts: []
]
]

Expand All @@ -42,7 +44,8 @@ config :mongoose_push,
endpoint: "localhost",
mode: :dev,
use_2197: true,
pool_size: 5
pool_size: 5,
tls_opts: []
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option is here, as recently MongoosePush started validating APNS / FCM server certs by default. As for dev release we expect to be connecting to mocks, we need to disable the verification, as otherwise the release won't boot.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add this option to the list here: 7983a85#diff-04c6e90faac2675aa89e2176d2eec7d8R194 ?

],
prod: [
auth: %{
Expand All @@ -53,6 +56,7 @@ config :mongoose_push,
endpoint: "localhost",
mode: :prod,
use_2197: true,
pool_size: 5
pool_size: 5,
tls_opts: []
]
]