Skip to content

Commit

Permalink
chore: prepare for RC3 release (#275)
Browse files Browse the repository at this point in the history
* chore: prepare for RC3 release

* docs: update CHANGELOG

* docs: CHANGELOG revisions

* fix: no warnings on CHANGELOG when generating docs

* docs: various updates

Also removed the Goth HTTP stub.
  • Loading branch information
hpopp authored Sep 10, 2024
1 parent fec0405 commit 53f87c1
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 151 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Changelog

## Unreleased
## v2.0.0-rc.3

### Breaking Changes

- `Pigeon.LegacyFCM` has been removed entirely and migrated to [pigeon_legacy_fcm](https://github.com/codedge-llc/pigeon-legacy-fcm) package.
- FCM `service_account_json` config option has been removed and replaced with `:auth`, a [Goth](https://github.com/peburrows/goth) configuration.
See `Pigeon.FCM` documentation for setup and [#235](https://github.com/codedge-llc/pigeon/pull/235) for more details.

**Changed**

- Bump `goth` dependency to `~> 1.4.3`. ([#252](https://github.com/codedge-llc/pigeon/pull/252))
- Fix `DispatcherWorker` missing a clause for `{:stop, reason}` in the handle_info function.

**Fixed**

- `DispatcherWorker` missing a clause for `{:stop, reason}` in the handle_info function.

## v2.0.0-rc.2

Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
> HTTP2-compliant wrapper for sending iOS and Android push notifications.
[![CI](https://github.com/codedge-llc/pigeon/actions/workflows/ci.yml/badge.svg)](https://github.com/codedge-llc/pigeon/actions/workflows/ci.yml)
[![Hex.pm](http://img.shields.io/hexpm/v/pigeon.svg)](https://hex.pm/packages/pigeon)
[![Hex.pm](http://img.shields.io/hexpm/dt/pigeon.svg)](https://hex.pm/packages/pigeon)
[![Version](https://img.shields.io/hexpm/v/pigeon.svg)](https://hex.pm/packages/pigeon)
[![Total Downloads](https://img.shields.io/hexpm/dt/pigeon.svg)](https://hex.pm/packages/pigeon)
[![License](https://img.shields.io/hexpm/l/pigeon.svg)](https://github.com/codedge-llc/pigeon/blob/master/LICENSE)
[![Last Updated](https://img.shields.io/github/last-commit/codedge-llc/pigeon.svg)](https://github.com/codedge-llc/pigeon/commits/master)
[![Documentation](https://img.shields.io/badge/documentation-gray)](https://hexdocs.pm/pigeon/)

_Pigeon v2.0 is in release candidate status. See [the latest stable 1.6 on Hex](https://hex.pm/packages/pigeon)
or [the 1.6 branch on GitHub](https://github.com/codedge-llc/pigeon/tree/v1.6) for installation._
Expand All @@ -16,7 +19,7 @@ Add `:pigeon` and as a `mix.exs` dependency:
```elixir
def deps do
[
{:pigeon, "~> 2.0.0-rc.2"}
{:pigeon, "~> 2.0.0-rc.3"}
]
end
```
Expand Down
4 changes: 3 additions & 1 deletion lib/pigeon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ defmodule Pigeon do
- `Pigeon.ADM` - Amazon Android.
- `Pigeon.APNS` - Apple iOS.
- `Pigeon.FCM` - Firebase Cloud Messaging v1 API.
- `Pigeon.LegacyFCM` - Firebase Cloud Messaging Legacy API.
## Creating Dynamic Runtime Dispatchers
Expand Down Expand Up @@ -97,6 +96,9 @@ defmodule Pigeon do
notification :: struct | no_return
@spec push(pid | atom, notifications :: [notification, ...], push_opts) ::
notifications :: [struct, ...] | no_return
@doc """
Sends a push notification with given options.
"""
def push(pid, notifications, opts \\ [])

def push(pid, notifications, opts) when is_list(notifications) do
Expand Down
17 changes: 10 additions & 7 deletions lib/pigeon/adm.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ defmodule Pigeon.ADM do
## Getting Started
1. Create an ADM dispatcher.
### Create a dispatcher.
```
# lib/adm.ex
# lib/your_app/adm.ex
defmodule YourApp.ADM do
use Pigeon.Dispatcher, otp_app: :your_app
end
```
2. (Optional) Add configuration to your `config.exs`.
### Configure your dispatcher.
Configure your `ADM` dispatcher and start it on application boot.
```
# config.exs
Expand All @@ -24,7 +27,7 @@ defmodule Pigeon.ADM do
client_secret: "your_oauth2_client_secret_here"
```
3. Start your dispatcher on application boot.
Add it to your supervision tree.
```
defmodule YourApp.Application do
Expand All @@ -43,7 +46,7 @@ defmodule Pigeon.ADM do
end
```
If you skipped step two, include your configuration.
If preferred, you can include your configuration directly.
```
defmodule YourApp.Application do
Expand All @@ -70,14 +73,14 @@ defmodule Pigeon.ADM do
end
```
4. Create a notification.
### Create a notification.
```
msg = %{ "body" => "your message" }
n = Pigeon.ADM.Notification.new("your device registration ID", msg)
```
5. Send the notification.
### Send the notification.
```
YourApp.ADM.push(n)
Expand Down
28 changes: 17 additions & 11 deletions lib/pigeon/apns.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ defmodule Pigeon.APNS do
## Getting Started
1. Create an `APNS` dispatcher.
### Create a dispatcher.
```
# lib/apns.ex
# lib/your_app/apns.ex
defmodule YourApp.APNS do
use Pigeon.Dispatcher, otp_app: :your_app
end
```
2. (Optional) Add configuration to your `config.exs`.
### Configure your dispatcher.
Configure your `APNS` dispatcher and start it on application boot.
```
# config.exs
Expand All @@ -23,11 +26,9 @@ defmodule Pigeon.APNS do
cert: File.read!("cert.pem"),
key: File.read!("key_unencrypted.pem"),
mode: :dev
```
Or use token based authentication:
# Or for token based authentication:
```
config :your_app, YourApp.APNS,
adapter: Pigeon.APNS,
key: File.read!("AuthKey.p8"),
Expand All @@ -36,7 +37,7 @@ defmodule Pigeon.APNS do
team_id: "DEF8901234"
```
3. Start your dispatcher on application boot.
Add it to your supervision tree.
```
defmodule YourApp.Application do
Expand All @@ -55,7 +56,7 @@ defmodule Pigeon.APNS do
end
```
If you skipped step two, include your configuration.
If preferred, you can include your configuration directly.
```
defmodule YourApp.Application do
Expand Down Expand Up @@ -83,14 +84,19 @@ defmodule Pigeon.APNS do
end
```
4. Create a notification. **Note: Your push topic is generally the app's bundle identifier.**
### Create a notification.
```
n = Pigeon.APNS.Notification.new("your message", "your device token", "your push topic")
```
> #### Note {: .info}
>
> Note: Your push topic is generally the app's bundle identifier.
5. Send the packet. Pushes are synchronous and return the notification with an
updated `:response` key.
### Send the notification.
Pushes are synchronous and return the notification with an updated `:response` key.
```
YourApp.APNS.push(n)
Expand Down
79 changes: 24 additions & 55 deletions lib/pigeon/fcm.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,35 @@ defmodule Pigeon.FCM do
## Getting Started
1. Create a `FCM` dispatcher.
### Create a dispatcher.
```
# lib/fcm.ex
defmodule YourApp.FCM do
use Pigeon.Dispatcher, otp_app: :your_app
end
```
```
# lib/your_app/fcm.ex
defmodule YourApp.FCM do
use Pigeon.Dispatcher, otp_app: :your_app
end
```
2. Configure the [`goth`](https://hexdocs.pm/goth/1.4.3/readme.html#installation) library, and add it to `config.exs`
### Install and configure Goth.
Install and configure [`goth`](https://hexdocs.pm/goth/1.4.3/readme.html#installation)
if you haven't already. `Pigeon.FCM` requires it for token authentication.
### Configure your dispatcher.
Configure your `FCM` dispatcher and start it on application boot.
```
# config.exs
# See Step 3 for alternative configuration
config :your_app, YourApp.FCM,
adapter: Pigeon.FCM,
auth: YourApp.Goth,
auth: YourApp.Goth, # Your Goth worker configured in the previous step.
project_id: "example-project-123"
```
3. Start your dispatcher on application boot.
Add it to your supervision tree.
```
defmodule YourApp.Application do
Expand All @@ -45,7 +52,7 @@ defmodule Pigeon.FCM do
end
```
If preferred, you can include your configuration directly
If preferred, you can include your configuration directly.
```
defmodule YourApp.Application do
Expand Down Expand Up @@ -73,13 +80,13 @@ defmodule Pigeon.FCM do
end
```
4. Create a notification.
### Create a notification.
```
n = Pigeon.FCM.Notification.new({:token, "reg ID"}, %{"body" => "test message"})
```
5. Send the notification.
### Send the notification.
On successful response, `:name` will be set to the name returned from the FCM
API and `:response` will be `:success`. If there was an error, `:error` will
Expand All @@ -92,47 +99,9 @@ defmodule Pigeon.FCM do
## Customizing Goth
If you need a customizable `:auth` that handles fetching its own configuration, here's
an example you can use to get started.
For other `:source` configurations of `YourApp.Goth`, check out the `goth` documentation for [`Goth.start_link/1`](https://hexdocs.pm/goth/Goth.html#start_link/1)
```
# lib/your_app/goth.ex
defmodule YourApp.Goth
@spec child_spec(any()) :: Supervisor.child_spec()
def child_spec(_args) do
env_opts = Keyword.new(Application.get_env(:your_app, YourApp.Goth, []))
opts = Keyword.merge([name: YourApp.Goth], env_opts)
%{
:id => YourApp.Goth,
:start => {Goth, :start_link, [opts]}
}
end
end
# config.exs
config :your_app, YourApp.Goth, source: {:metadata, []}
# config/test.exs
config :your_app, YourApp.Goth,
source: {:metadata, []},
http_client: {&PigeonTest.GothHttpClient.Stub.access_token_response/1, []}
# application.exs
def start(_type, _args) do
children = [
# The `child_spec/1` handles fetching the proper config
YourApp.Goth,
YourApp.FCM
]
opts = [strategy: :one_for_one, name: YourApp.Supervisor]
Supervisor.start_link(children, opts)
end
```
You can use any of the configuration options (e.g. `:source`) for Goth. Check out the
documentation of [`Goth.start_link/1`](https://hexdocs.pm/goth/Goth.html#start_link/1)
for more details.
"""

@max_retries 3
Expand Down
20 changes: 14 additions & 6 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Pigeon.Mixfile do
use Mix.Project

@source_url "https://github.com/codedge-llc/pigeon"
@version "2.0.0-rc.2"
@version "2.0.0-rc.3"

def project do
[
Expand Down Expand Up @@ -58,16 +58,23 @@ defmodule Pigeon.Mixfile do

defp docs do
[
extras: [
"CHANGELOG.md",
LICENSE: [title: "License"]
],
groups_for_modules: [
"ADM - Amazon Android": [Pigeon.ADM, Pigeon.ADM.Notification],
"APNS - Apple iOS": [Pigeon.APNS, Pigeon.APNS.Notification],
"FCM - Firebase Cloud Messaging": [
Pigeon.FCM,
Pigeon.FCM.Notification,
PigeonTest.GothHttpClient.Stub
Pigeon.FCM.Notification
]
],
main: "Pigeon"
formatters: ["html"],
main: "Pigeon",
skip_undefined_reference_warnings_on: ["CHANGELOG.md"],
source_ref: "v#{@version}",
source_url: @source_url
]
end

Expand All @@ -80,11 +87,12 @@ defmodule Pigeon.Mixfile do

defp package do
[
files: ["lib", "mix.exs", "README*", "LICENSE*"],
files: ["lib", "mix.exs", "README*", "LICENSE*", "CHANGELOG*"],
licenses: ["MIT"],
links: %{
"Changelog" => "https://hexdocs.pm/pigeon/changelog.html",
"GitHub" => @source_url
"GitHub" => @source_url,
"Sponsor" => "https://github.com/sponsors/codedge-llc"
},
maintainers: ["Henry Popp", "Tyler Hurst"]
]
Expand Down
Loading

0 comments on commit 53f87c1

Please sign in to comment.