Skip to content

Commit 6e82204

Browse files
committed
Add Context description to README
1 parent bde4f17 commit 6e82204

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ if res.Sent() {
124124
}
125125
```
126126

127+
## Context & Timeouts
128+
129+
For better control over request cancelations and timeouts APNS/2 supports
130+
contexts. Using a context can be helpful if you want to cancel all pushes when
131+
the parent process is cancelled, or need finer grained control over individual
132+
push timeouts. See the [Google post](https://blog.golang.org/context) for more
133+
information on contexts.
134+
135+
```go
136+
ctx, cancel = context.WithTimeout(context.Background(), 10 * time.Second)
137+
res, err := client.PushWithContext(ctx, notification)
138+
defer cancel()
139+
```
140+
127141
## Command line tool
128142

129143
APNS/2 has a command line tool that can be installed with `go get github.com/sideshow/apns2/apns2`. Usage:

0 commit comments

Comments
 (0)