From b9fc9272f2241f2c2d567a6689f650accb8707fb Mon Sep 17 00:00:00 2001 From: Philipp Jahoda Date: Wed, 29 May 2019 12:11:06 +0200 Subject: [PATCH 1/5] Update README.md --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/README.md b/README.md index 91de5ea..d6f4ba2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,46 @@ # APNJWT Kotlin JWT implementation (Json Web Token) as required by APNs (Apple Push Notification Service) + + +## Sample Usage + +Create required encoders, decoders and JSON Mapper (e.g. Gson or equivalent). These are later used to properly encode or decode the token header and payload. + +```kotlin + val gson = GsonBuilder().create() + + val mapper = object : Mapper { + override fun jsonString(header: JWTAuthHeader): String { + return gson.toJson(header, JWTAuthHeader::class.java) + } + + override fun jsonString(payload: JWTAuthPayload): String { + return gson.toJson(payload, JWTAuthPayload::class.java) + } + } + + val encoder = object : Base64Encoder { + override fun encode(bytes: ByteArray): String { + return Base64.encodeBase64String(bytes) + } + } + + val decoder = object : Base64Decoder { + override fun decode(bytes: ByteArray): ByteArray { + return Base64.decodeBase64(bytes) + } + } +``` + +Create the token by providing the teamId, keyId and secret (private key excluding header and footer). The teamId can be obtained from the developer member center. The keyId can be obtained when you create your secret (private key). + +```kotlin + val token = JWT.token("teamId", "keyId", "secret", mapper, encoder, decoder) +``` + +Use the token in the authentication header: + +``` + 'authentication' 'bearer $token' +``` + From 5ad8c0fb7af475ae049df5240f288d85fa4e1256 Mon Sep 17 00:00:00 2001 From: Philipp Jahoda Date: Wed, 29 May 2019 12:12:23 +0200 Subject: [PATCH 2/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d6f4ba2..a8b064e 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Create the token by providing the teamId, keyId and secret (private key excludin val token = JWT.token("teamId", "keyId", "secret", mapper, encoder, decoder) ``` -Use the token in the authentication header: +Include the token in the authentication header when you make yor push notification request to APNs: ``` 'authentication' 'bearer $token' From 548f3badd0f6a2efb1efa4899dee3eae79854dfc Mon Sep 17 00:00:00 2001 From: Philipp Jahoda Date: Wed, 29 May 2019 12:13:21 +0200 Subject: [PATCH 3/5] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index a8b064e..0e68bfb 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,7 @@ Include the token in the authentication header when you make yor push notificati 'authentication' 'bearer $token' ``` +## Documentation + +For a detailed guide, please visit the [APNs documentation](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW1) page by Apple. + From 890269068266150f342ccfa1c904dd634287ed20 Mon Sep 17 00:00:00 2001 From: Philipp Jahoda Date: Wed, 29 May 2019 12:13:50 +0200 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e68bfb..b5d23d2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # APNJWT -Kotlin JWT implementation (Json Web Token) as required by APNs (Apple Push Notification Service) +Kotlin JWT implementation (Json Web Token) as required by APNs (Apple Push Notification Service), for use on Kotlin powered backend servers. ## Sample Usage From 8e80361733d783986edbf4123c6f87ae82d80064 Mon Sep 17 00:00:00 2001 From: Philipp Jahoda Date: Wed, 29 May 2019 13:05:39 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b5d23d2..cd84303 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # APNJWT Kotlin JWT implementation (Json Web Token) as required by APNs (Apple Push Notification Service), for use on Kotlin powered backend servers. +No other dependencies required. ## Sample Usage