Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(service): Apns2 integration #715

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
doc: wrote docs and readme
  • Loading branch information
saisumith770 committed Oct 8, 2023
commit 06e8e15ddf43f80ef73af335f6f97bd225c3f0d0
27 changes: 27 additions & 0 deletions service/apns2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# APNS2

[APNS2](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns) sending notifications through the apns server directly to iphone devices

## Usage

```go
// Create a apns2 service. `service.p12` or `service.pem` is generated when you install the application.
apns2Service := apns2.New(P12File("/cert/service.p12",""),"<com.myapp.topic>")
apns2Service = apns2.New(P12Bytes([]byte{},""),"<com.myapp.topic>")
apns2Service = apns2.New(PemFile("/cert/service.pem",""),"<com.myapp.topic>")
apns2Service = apns2.New(PemBytes([]byte{},""),"<com.myapp.topic>")

// Add devices
apns2Service.AddReceivers("<token1>","<token2>")

// Tell our notifier to use the apns2 service.
notify.UseServices(apns2Service)

// Send a test message.
_ = notify.Send(
context.Background(),
"Subject/Title",
"The actual message - Hello, you awesome gophers! :)",
)
```

39 changes: 39 additions & 0 deletions service/apns2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Package apns2 provides a service for sending notifications to ios.

Usage:

package main

import (
"context"
"log"

"github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/apns2"
)

func main() {

// Create a apns2 service. `service.p12` or `service.pem` is generated when you install the application.
apns2Service := apns2.New(P12File("/cert/service.p12",""),"<com.myapp.topic>")
apns2Service = apns2.New(P12Bytes([]byte{},""),"<com.myapp.topic>")
apns2Service = apns2.New(PemFile("/cert/service.pem",""),"<com.myapp.topic>")
apns2Service = apns2.New(PemBytes([]byte{},""),"<com.myapp.topic>")

// Add devices
apns2Service.AddReceivers("<token1>","<token2>")

// Tell our notifier to use the apns2 service.
notify.UseServices(apns2Service)

// Send a test message.
_ = notify.Send(
context.Background(),
"Subject/Title",
"The actual message - Hello, you awesome gophers! :)",
)

}
*/
package apns2