Skip to content

Commit b052e00

Browse files
committed
v0.0.7
1 parent a1e7cff commit b052e00

File tree

3 files changed

+58
-27
lines changed

3 files changed

+58
-27
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 0.0.7 (2015-11-17)
4+
5+
* Now APNS will automatically start pools defined in config. (see README)
6+
* Updated config structure (see README)
7+
* Renamed feedback_timeout config key to feedback_interval as more appropriate (see README)
8+
* Deprecated manual connection start (see README)
9+
310
## 0.0.6 (2015-10-14)
411

512
* In case when token size is incorrect (!= 64), error callback will be triggered

README.md

+50-26
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This library is a work in progress and it's API is subject to change till `v0.1`
1111
1. Add apns to your list of dependencies in mix.exs:
1212

1313
def deps do
14-
[{:apns, "== 0.0.6"}]
14+
[{:apns, "== 0.0.7"}]
1515
end
1616

1717
2. Ensure apns is started before your application:
@@ -20,38 +20,62 @@ This library is a work in progress and it's API is subject to change till `v0.1`
2020
[applications: [:apns]]
2121
end
2222

23-
## Using
23+
## Usage
2424

25-
1. Config the APNS app
25+
Config the APNS app and define pools
2626

27-
You can provide config as `key: value` to use the same value for both envs or `key: [dev: dev_value, prod: prod_value]` to use different values for :dev and :prod env
28-
29-
- Required APNS config will only include paths to certificates:
30-
```elixir
31-
config :apns,
32-
certfile: [
33-
dev: "/path/to/dev_cert.pem",
34-
prod: "/path/to/prod_cert.pem"
35-
]
36-
```
37-
- Optional config is the following:
3827
```elixir
3928
config :apns,
29+
# Here goes "global" config applied as default to all pools started if not overwritten by pool-specific value
4030
callback_module: APNS.Callback,
41-
keyfile: nil,
42-
cert_password: nil,
43-
timeout: 30000,
44-
feedback_timeout: 1200,
45-
reconnect_after: 1000
31+
timeout: 30,
32+
feedback_interval: 1200,
33+
reconnect_after: 1000,
34+
support_old_ios: true,
35+
# Here are pools configs. Any value from "global" config can be overwritten in any single pool config
36+
pools: [
37+
# app1_dev_pool is the pool_name
38+
app1_dev_pool: [
39+
env: :dev,push server)
40+
pool_size: 10,
41+
pool_max_overflow: 5,
42+
# and this is overwritten config key
43+
certfile: "/path/to/app1_dev.pem"
44+
],
45+
app1_prod_pool: [
46+
env: :prod,
47+
certfile: "/path/to/app1_prod.pem",
48+
pool_size: 100,
49+
pool_max_overflow: 50
50+
],
51+
]
4652
```
4753

48-
2. Start a :dev (for Apple sandbox server) or :prod (for Apple prod server) worker:
54+
### Config keys
4955

50-
```elixir
51-
{:ok, pid} = APNS.start :dev
52-
```
56+
Name | Default value | Description
57+
:----------------- | :------------- | :-------------------
58+
certfile | nil | Path to APNS certificate file
59+
cert_password | nil | APNS certificate password (if any)
60+
keyfile | nil | Path to APNS keyfile
61+
callback_module | APNS.Callback | This module will receive all error and feedback messages from APNS
62+
timeout | 30 | Connection timeout in seconds
63+
feedback_interval | 1200 | The app will check Apple feedback server every `feedback_interval` seconds
64+
reconnect_after | 1000 | Will reconnect after 1000 notifications sent
65+
support_old_ios | true | Push notifications are limited by 256 bytes (2kb if false), this option can be changed per message individually
66+
pools | [] | List of pools to start
67+
68+
### Pool keys
69+
70+
Pool key | Description
71+
:----------------- | :-------------
72+
env | :dev for Apple sandbox push server or :prod for Apple production push server
73+
pool_size | Maximum pool size
74+
pool_max_overflow | Maximum number of workers created if pool is empty
75+
76+
All pools defined in config will be started automatically
5377

54-
3. Start pushing your PNs via APNS.push/1 and APNS.push/3:
78+
From here and now you can start pushing your PNs via APNS.push/2 and APNS.push/3:
5579
```Elixir
5680
message = APNS.Message.new
5781
message = message
@@ -62,11 +86,11 @@ message = message
6286
"var1" => "val1",
6387
"var2" => "val2"
6488
})
65-
APNS.push pid, message
89+
APNS.push :app1_dev_pool, message
6690
```
6791
or
6892
```Elixir
69-
APNS.push pid, "0000000000000000000000000000000000000000000000000000000000000000", "Hello world!"
93+
APNS.push :app1_prod_pool, "0000000000000000000000000000000000000000000000000000000000000000", "Hello world!"
7094
```
7195

7296
## Handling APNS errors and feedback

mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule APNS.Mixfile do
44
def project do
55
[
66
app: :apns,
7-
version: "0.0.6",
7+
version: "0.0.7",
88
elixir: "~> 1.0",
99
build_embedded: Mix.env == :prod,
1010
start_permanent: Mix.env == :prod,

0 commit comments

Comments
 (0)